Skip to content

Including the Framework

Pedro de Carvalho edited this page Jul 29, 2026 · 4 revisions

The supported way of installing Saltus is via Composer.

composer require saltus/framework

Once the framework is included in your plugin, you can initialize it the following way:

$autoload = __DIR__ . '/vendor/autoload.php';
if ( is_readable( $autoload ) ) {
    require_once $autoload;
}

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.
     * The second parameter (plugin bootstrap file) enables
     * activation/deactivation hooks.
     */
    $framework = new \Saltus\WP\Framework\Core( dirname( __FILE__ ), __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.

Clone this wiki locally