-
Notifications
You must be signed in to change notification settings - Fork 1
Plugin(s)
This library requires creating a very simple plugin to use it.
And there are 2 possibilities to use this composer library:
- install it globally to the site
- install it in the folder of a plugin… but globally is better
In the first case, it is possible to create 1 plugin per entity or per entity category and all the plugins will have access to the library since it will be loaded globally. This solution is recommended since it will be possible to deactivate one feature and not the others.
It is thus possible to make 1 plugin for the CPTs, 1 plugin for the CTs, 1 plugin for the options pages, or 1 plugin for the CPTs and the CTs, 1 for the options…
In the second case, only the plugin will have access to the library, which means that all the declarations will have to be made in one and the same plugin.
Simply add the library to the global composer with:
composer require webaxones/core
Initialize composer inside the plugin folder with composer init
or create a composer.json
file manually and add this inside:
{
"name": "my-site/my-example-plugin",
"description": "Custom declarations",
"license": "GPL-2.0",
"authors": [
{
"name": "My name",
"email": "[email protected]"
}
],
"type" : "wordpress-plugin",
"minimum-stability": "dev",
"prefer-stable": true
}
Then add the library to it with this command inside the plugin folder:
composer require webaxones/core
Choose the entity to be created, refer to the menu in the Wiki sidebar and add desired content declarations to the main file of the plugin.
In summary the plugin must contain:
3 lines to load the autoload if the library is in the plugin, otherwise these 3 lines should not be added:
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
require __DIR__ . '/vendor/autoload.php';
}
use Webaxones\Core\Entities\Entities;
Webaxones\Core\Library::init( 'webaxones-content' );
The slug to use in the Library init
method must be the text-domain
of the plugin declaring the entity.
And the .po .mo files should then be in the official /languages/plugins/
folder.
[
'entity' => 'Webaxones\Core\Classification\PostType',
'labels' => [
...
],
'settings' => [
...
],
];
Entities::process( $declarations );