Add to menu - 10quality/wpmvc-addon-administrator GitHub Wiki

Only Settings Models with tabs and fields will be added to the WordPress admin dashboard menu.

The model will be added by default to the menu root if the conditions above are present.

Change menu options

Edit the menu array inside the model's init() method to change where and how the model should be displayed within the menu hierarchy, for example:

// Namespace and use statement...

class Settings extends Model
{
    // Class properties...

    protected function init()
    {
        $this->menu = [

            // Add the parent key to indicate that the settings should display under a parent menu,
            // Use 'options-general.php' to add the setting within WordPress "Settings".
            // Or use any other page ID, or another existing settings model ID.
            'parent' => 'parent_page_id',

            // Use this to change the default menu title. Default: Model's title.
            'title' => __( 'Menu title' ),

            // Use the position to change the order in which this will display within the menu.
            'position' => 5,

            // Use this to change the default capability. Default: manage_options
            'capability' => 'manage_options',

            // Use this to set the menu icon.
            'icon' => 'dashicons',

        ];
    }
}

NOTE: All these menu options are optional.

Change page ID

By default, the menu ID is the model ID, this can be changed with the property page_slug inside the init() method, for example:

// Namespace and use statement...

class Settings extends Model
{
    // Class properties...

    protected function init()
    {
        $this->page_slug = 'new_page_id';
        $this->menu = [...];
    }
}