Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-init
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-init
Merge requests
!2
1.x
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
1.x
1.x
into
review
Overview
29
Commits
68
Pipelines
0
Changes
1
Merged
Bartek Jaskulski
requested to merge
1.x
into
review
1 year ago
Overview
14
Commits
68
Pipelines
0
Changes
1
Basic implementation of plugin initializer
docs: improve documentation
docs: improve API method documentation
chore: improve composer package definition and readme
feat(wip): allow private hooks calls
improve into wp-hook and some additional unfinished things
feat: moving toward actual implementation
refactor: hookable driver should belong to separate package
refactor: HookProvider also belongs to another package
refactor: remove PluginHeaderData
feat: add VERY simple command to cache plugin data
refactor: rename header parser implementation
refactor: simplify package
refactor: remove unused tests
chore: add static analysis
feat: add initial bindings for wp-builder compatibility
chore: add editorconfig
fix: passthrough container definitions argument
fix: use absolute cache path
fix: don't use hook and global variable
refactor: remove method, which can be replaced with get_path
refactor: reorder definition loading, change config key name
fix: correct cache path
feat: add hook driver backward compatible with wp-builder
fix: throw exception on failed load
feat: add check for optional package
chore: add config files
feat: large rework, needs followup
0
0
Merge request reports
Viewing commit
56b25b21
Prev
Next
Show latest version
1 file
+
15
−
11
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Verified
56b25b21
refactor: minor readme update
· 56b25b21
Bartek Jaskulski
authored
1 year ago
Signed-off-by:
Bart Jaskulski
<
bjaskulski@protonmail.com
>
README.md
0 → 100644
+
87
−
0
View file @ ddca3cac
Edit in single-file editor
Open in Web IDE
# WordPress plugin initializer
Boot your plugin with superpowers.
## Installation
To use this library in your project, add it to
`composer.json`
:
```
sh
composer require wpdesk/wp-init
```
## Creating a Plugin
Preferred method of using this library exercise Object Oriented Programming and organizing your
actions and filters in a multiple classes, although it isn't the only way you can interact (and
benefit from this library).
The plugin initialization consists of the following steps:
1.
Create a regular main plugin file, following
[
header requirements
](
https://developer.wordpress.org/plugins/plugin-basics/header-requirements/
)
1.
Prepare DI container definitions for your services.
1.
Declare all classes included in hook binding.
The above limits your main plugin file to a short and simple structure.
```
php
<?php
/**
* Plugin Name: Example Plugin
*/
use
WPDesk\Init\Init
;
require
__DIR__
.
'/vendor/autoload.php'
;
Init
::
setup
(
'config.php'
)
->
boot
();
```
### Plugin configuration
For plugin configuration, you may focus on succinct, declarative configuration.
[
Supported configuration
](
docs/configuration.md
)
:
```
php
<?php
return
[
'hook_resources_path'
=>
'config/hook_providers'
,
'services'
=>
'config/services.inc.php'
,
'cache_path'
=>
'generated'
,
'requirements'
=>
[
'plugins'
=>
[
'name'
=>
'woocommerce/woocommerce.php'
,
'nice_name'
=>
'WooCommerce'
,
]
],
'plugin_class_name'
=>
'Example\Plugin'
,
];
```
## Usage with `wpdesk/wp-builder`
As a legacy support, it is possible to power up your existing codebase, which uses
`wpdesk/wp-builder`
with this library capabilities, as autowired services.
The only change, you have to do (besides configuration of services) is adding _hookables_ as class
string, ready for handling by DI container:
```
diff
- $this->add_hookable( new \WPDesk\Init\Provider\I18n() );
+ $this->add_hookable( \WPDesk\Init\Provider\I18n::class );
```
## Credits
This package is heavily inspired by Cedaro's
[
`wp-plugin`
](
https://github.com/cedaro/wp-plugin/
)
and Alain Schlesser's
[
`basic-scaffold`
](
https://github.com/mwpd/basic-scaffold
)
.
## License
Copyright (c) 2024 WPDesk
This library is licensed under MIT.
Loading