-
Notifications
You must be signed in to change notification settings - Fork 1
Including the Framework
The supported way of installing Saltus is via Composer.
$ composer require SaltusDev/saltus-framework
Once the framework is included in your plugin, you can initialize it the following way:
if ( class_exists( \Saltus\WP\Framework\Core::class ) ) {
/*
* The path to the plugin root directory is mandatory,
* so it loads the models from a subdirectory.
*/
$framework = new \Saltus\WP\Framework\Core( dirname( __FILE__ ) );
$framework->register();
/**
* Initialize plugin after this
*/
}
The framework will search for a model file, by default in the folder src/models. This can be changed using a filter. You can name your model file whatever you want.
A model file should return one array or a multidimensional array of models to build the Custom Post Types or Taxonomies. Simple example:
return [
'type' => 'cpt',
'name' => 'movie',
];
The above example will create a Custom Post Type 'movie'.
Several models in same file:
return [
[
'type' => 'cpt',
'name' => 'movie',
],
[
'type' => 'category',
'name' => 'genre',
'associations' => [
‘movie’,
],
],
];
The above example will create a Custom Post Type 'movie' and a hierarchical Taxonomy 'genre' associated with the Custom Post Type 'movie'.
Refer to the other documentation pages for more information on models.