gravityflow_menu_items

Description

The gravityflow_menu_items filter allows developers to modify the main navigation menu items in the Gravity Flow WordPress Admin menu.

add_filter( 'gravityflow_menu_items', 'custom_function',  10, 1);

Parameters

ParameterTypeDescription
$menu_itemsArrayAn array of menu item arrays, each containing navigation menu configuration.

Menu Item Structure

Each menu item in the array should have the following structure:

array(
    'name'       => 'unique-menu-name',
    'label'      => 'Display Label',
    'permission' => 'required_capability',
    'callback'   => array( $this, 'callback_method' ),
)

Examples

Add a custom menu item to the Gravity Flow menu.

add_filter( 'gravityflow_menu_items', 'gfw_custom_gravityflow_menu_item' );
function gfw_custom_gravityflow_menu_item( $menu_items ) {
    $custom_item = array(
        'name'       => 'gravityflow-custom',
        'label'      => esc_html__( 'Custom Page', 'text-domain' ),
        'permission' => 'gravityflow_custom_permission', // Set your custom capability.
        'callback'   => 'my_custom_gravityflow_page_callback', // Function to render the page.
    );
    $menu_items[] = $custom_item;
    return $menu_items;
}

/**
 * Callback function to display the custom page content.
 */
function my_custom_gravityflow_page_callback() {
    echo '<h2>' . esc_html__( 'Welcome to the Custom Page!', 'text-domain' ) . '</h2>';
    // Add your custom content here.
}
Image showing Custom Page menu item

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is included in class-gravity-flow.php