-
Notifications
You must be signed in to change notification settings - Fork 1
saltus_models Filter
Carlos Moreira edited this page Jun 2, 2020
·
1 revision
The saltus_models
filter will allow you to add or edit models using a custom function.
Example:
add_filter('saltus_models', 'my_plugin_models');
function my_plugin_models( $models ){
// custom models for taxonomy and cpt.
$custom = [
[
'type' => 'category',
'name' => 'igm-countries',
'options' => [
'labels' => [
'menu_name' => __( 'Countries', 'igm-products' ),
'name' => __( 'Countries', 'igm-products' ),
'singular_name' => __( 'Countries', 'igm-products' ),
'all_items' => __( 'Countries', 'igm-products' ),
],
],
'associations' => [
'igm-products',
],
],
[
'type' => 'cpt',
'name' => 'igm-products',
'supports' => [
'title',
'editor',
'thumbnail',
'page-attributes',
],
'options' => [
'public' => true,
'publicly_queryable' => true,
'show_in_rest' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'can_export' => true,
'capability_type' => 'post',
'menu_icon' => 'dashicons-book',
'rewrite' => [
'slug' => 'products',
'with_front' => true,
'feeds' => true,
'pages' => true,
],
],
'block_editor' => false,
'labels' => [
'has_one' => __( 'Product', 'igm-products' ),
'has_many' => __( 'Products', 'igm-products' ),
'featured_image' => __( 'Product Image', 'igm-products' ),
],
'settings' => [
'product-settings' => [
'id' => 'product-settings',
'title' => __( 'Plugin Settings', 'igm-products' ),
'capability' => 'manage_options',
'menu_title' => __( 'Settings', 'igm-products' ),
'sections' => [
'general' => [
'title' => __( 'General', 'igm-products' ),
'desc' => __( 'Basic settings that affect the plugin behaviour', 'igm-products' ),
'icon' => 'fa fa-cog fa-lg',
'fields' => [
'igmp_excerpt_length' => [
'type' => 'text',
'title' => __( 'Excerpt Length', 'igm-products' ),
'desc' => __( 'Lenght of the excerpt to display when the product is clicked.', 'igm-products' ),
],
'igmp_truncate' => [
'type' => 'text',
'title' => __( 'Cutout Text', 'igm-products' ),
'default' => '...',
'desc' => __( 'What to display after the cutout text from excerpt', 'igm-products' ),
],
],
],
],
],
],
],
];
return array_merge( $model, $custom );
}