wpfts_admin_menu_items (Filter)
The wpfts_admin_menu_items
filter in WP Fast Total Search allows developers to modify the plugin’s menu items displayed in the WordPress admin panel. This enables adding, removing, or modifying existing WPFTS menu items.
When to Use
This filter is useful in the following cases:
- Adding menu items for addon settings: You can add a new menu item that will lead to your addon’s settings page.
- Removing unnecessary menu items: If you want to hide certain WPFTS menu items, you can use this filter to remove them.
- Modifying existing menu items: You can change the title or display order of existing menu items.
Arguments
$menu_items
(array): An associative array of menu items. The array keys are the menu item slugs, and the values are arrays containing the title and other parameters of the menu item.
Return Value
$menu_items
(array): The modified array of menu items.
Example (Adding a Menu Item)
add_filter('wpfts_admin_menu_items', 'add_my_addon_menu_item');
function add_my_addon_menu_item($menu_items) {
$menu_items['my-addon-settings'] = array(
__('My Addon Settings', 'my-addon'), // Menu item title.
'my_addon_settings_page' // Callback function
);
return $menu_items;
}
Example (Removing a Menu Item)
add_filter('wpfts_admin_menu_items', 'remove_sandbox_menu_item');
function remove_sandbox_menu_item($menu_items) {
unset($menu_items['wpfts-options-sandbox-area']); // Removes the "Sandbox Area" menu item.
return $menu_items;
}
Important Notes
- The
wpfts_admin_menu_items
filter is called when the WPFTS menu is built in the admin panel. - Make sure the slugs of your menu items are unique.
- If you add a new menu item, you will also need to create a function that will display the contents of the settings page.
The wpfts_admin_menu_items
filter provides developers with the ability to flexibly manage the WP Fast Total Search plugin menu in the WordPress admin panel.