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
79
11 unresolved threads
Hide all comments
Merged
Bartek Jaskulski
requested to merge
1.x
into
review
1 year ago
Overview
29
Commits
68
Pipelines
0
Changes
21
11 unresolved threads
Hide all comments
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
Compare
version 3
version 14
0dbe359a
1 year ago
version 13
c90f560d
1 year ago
version 12
d0ae395b
1 year ago
version 11
1eee2874
1 year ago
version 10
11f17f99
1 year ago
version 9
54c7abca
1 year ago
version 8
495d715f
1 year ago
version 7
ef3e3ace
1 year ago
version 6
04d3bf0b
1 year ago
version 5
97ef7576
1 year ago
version 4
f1cd022a
1 year ago
version 3
56b25b21
1 year ago
version 2
6decad77
1 year ago
version 1
9a91616d
1 year ago
review (base)
and
version 4
latest version
ddca3cac
68 commits,
1 year ago
version 14
0dbe359a
66 commits,
1 year ago
version 13
c90f560d
63 commits,
1 year ago
version 12
d0ae395b
58 commits,
1 year ago
version 11
1eee2874
58 commits,
1 year ago
version 10
11f17f99
56 commits,
1 year ago
version 9
54c7abca
50 commits,
1 year ago
version 8
495d715f
45 commits,
1 year ago
version 7
ef3e3ace
45 commits,
1 year ago
version 6
04d3bf0b
44 commits,
1 year ago
version 5
97ef7576
43 commits,
1 year ago
version 4
f1cd022a
41 commits,
1 year ago
version 3
56b25b21
30 commits,
1 year ago
version 2
6decad77
29 commits,
1 year ago
version 1
9a91616d
28 commits,
1 year ago
Show latest version
21 files
+
306
−
103
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
21
docs/configuration.md
0 → 100644
+
66
−
0
View file @ f1cd022a
Edit in single-file editor
Open in Web IDE
# Configuration
`wp-init`
relies on declarative configuration, which encapsulates process of attaching hooks to
WordPress life cycle and provides some additional features, like filling DI container with your
services definitions.
## `hook_resources_path`
Pass a path to the file/directory with your hook actions. Configuration accepts any valid path
string, relative or absolute, either
`hook_providers`
or
`__DIR__ . '/hook_providers/plugins_loaded.php'`
Files are mapped to hooks by name, so
`woocommerce_init.php`
is registered inside
`woocommerce_init`
action. The exception is
`index.php`
file which is flushed immediately.
Example of a hook resource content:
```
php
<?php
// plugins_loaded.php
return
[
MyCoolTitleChanger
::
class
,
AnotherHookAction
::
class
,
function
(
Dependency
$dep
)
{
// You can even use a closure, to execute simple actions.
// Arguments are injected by DI container.
$dep
->
one_off_action
();
},
function
(
Migarator
$migrator
)
{
$migrator
->
migrate
();
}
];
```
## `services`
As you add more services with increasing complexity, you will need to provide some kind of
definitions for a DI container to create objects. Pass a path to a file, which will hold such
definitions. Refer to
[
php-di documentation
](
https://php-di.org/doc/definitions.html
)
for more
information on such file content.
> Warning
> If you are using _shortcut_ functions from `php-di/php-di` (e.g. `DI\autowire`, `DI\create`), you
> must load them first. Add `require __DIR__ . '/vendor_prefixed/php-di/php-di/src/functions.php';`
> to your plugin file.
## `cache_path`
Plugin header data and compiled DI container is cached in a directory specified by this
setting. Defaults to
`generated`
.
## `requirements`
**This setting only works when `wpdesk/wp-basic-requirements` is installed.**
Enables your plugin to check an environment requirement before instantiation, e.g. PHP version or
active plugins. Refer to
[
wp-basic-requirements documentation
](
https:
//gitlab.wpdesk.dev/wpdesk/wp-basic-requirements)
for more information on setting structure.
## `plugin_class_name`
**This setting only works when `wpdesk/wp-builder` is installed.**
When a plugin is used in
[
legacy mode
](
legacy.md
)
,
`plugin_class_name`
is used to create an instance
of main plugin class. This setting is required to enable legacy mode. Despite that,
`WPDesk\Init\Plugin\Plugin`
is still accessible to your services.
Loading