Saltus Framework helps you develop WordPress plugins that are based on Custom Post Types.
We built it to make things easier and faster for developers with different skills. Add metaboxes, settings pages and other enhancements with just a few lines of code.
See change log file for full details.
* Create Custom Post Types easily
* Control all labels and messages
* Add administration columns
* Add administration lists
* Add settings pages
* Add metaboxes
* Enable cloning
* Enable single entry export
* Enable drag&drop reordering
* Create Taxonomies easily
* Control labels
* Associate with any existing post type
* Add quick edit fields
Saltus Framework requires PHP 7.4+
Refer to the Framework Demo for a complete plugin example and to the Wiki for complete documentation.
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.
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'.
Currently there are 2 types of Model, one for Custom Post Types and another for Taxonomies. Depending what you define, you’ll have different parameters available.
| Parameter | Description |
|---|---|
| active | boolean - sets this model to active or inactive |
| type | string - type of model |
| name | string - identifier of the custom post type |
| features | array - Features that this CPT will support (More Info Soon) |
| supports | array - refer to the supports argument of the register_post_type function from WordPress |
| labels | array - Everything related with labels for this custom post type (More Info Soon) |
| options | array - Refer to the second argument in the register_post_type function from WordPress |
| block_editor | boolean - if the Block Editor should be enabled or not |
| meta | array - Information for the Metaboxes for this CPT (More Info Soon) |
| settings | array - Information for the Settings page of this CPT (More Info Soon) |
Example File for a CPT Model (Soon)
| Parameter | Description |
|---|---|
| type | string - ‘category’ // or 'tag' to set it to non-hierarchical automatically |
| name | string - identifier of this taxonomy |
| associations | string - to what CPT it should be associated |
| labels | array - Everything related with labels for this custom post type (More Info Soon) |
| options | array - Refer to the third parameter for register_taxonomy function from WordPress |
Example File for a Taxonomy Model (Soon)
Saltus Framework provides several hooks to customize its behavior.
| Hook | Description | Parameters |
|---|---|---|
saltus/framework/duplicate_post/after |
Triggered after a post is successfully duplicated. | string $post_type, int $original_post_id, int $new_post_id |
saltus/framework/admin_filters/filter_output/{$filter_id} |
Allows overriding the HTML output of a specific admin filter. | SaltusAdminFilters $instance, array $filter_args, string $element_id |
saltus/framework/drag_and_drop/update_menu_order |
Triggered after the menu order is updated via drag and drop. | None |
| Hook | Description | Parameters | Default |
|---|---|---|---|
saltus/framework/modeler/priority |
Filters the priority of the init hook used to register models. |
int $priority |
1 |
saltus/framework/services |
Filters the list of service classes to be registered. | array $services |
Core services array |
saltus/framework/models/path |
Filters the directory path where model files are located. | string $path |
{project_path}/src/models/ |
saltus/framework/models/extra_models |
Allows adding extra model configurations programmatically. | array $extra_models |
[] |
saltus/framework/admin_filters/category_list |
Filters the term name shown in taxonomy dropdown filters. | string $name, WP_Term $term |
$term->name |
saltus/framework/meta/matched_fields |
Filters the mapping between Saltus field types and Codestar field types. | array $field_map |
Built-in map |
saltus/framework/duplicate_post/args |
Filters the data used to create a new duplicated post. | array $args, int $original_post_id |
Copied post data |
saltus/framework/duplicate_post/excluded_meta_keys |
Filters meta keys that should not be copied during duplication. | array $keys |
['_wp_old_slug', '_edit_lock', '_edit_last'] |
saltus/framework/admin_filters/{$post_type}/filter_query/{$filter_id} |
Filters the query arguments for a specific admin filter. | array $vars, array $query, array $filter |
[] |
Includes a simplified version of SoberWP/Models. Their license is in lib/sobwewp/models/LICENSE.md. Is used to load php/json/yaml models of CPT.
Includes the Codestart Framework which is licensed under GPL.
Every time the Codestar Framework is updated, our custom fixes may be overwritten. To re-apply the patches located in lib/codestar-framework/patches, run the following command from the repository root:
for f in lib/codestar-framework/patches/*; do git apply "$f"; doneIncludes support for github-updater to keep track on updates through the WordPress backend.
- Download github-updater
- Clone github-updater to your sites plugins/ folder
- Activate via WordPress
As we move from 'files' to 'classmap', heed this:
Manual Updates: If you add new classes, you must regenerate the classmap by running composer dump-autoload.