Extending FunctionalityAction/Filter Hookswpfts_admin_menu

wpfts_admin_menu (Action)

The wpfts_admin_menu hook is called by the WP Fast Total Search plugin when building its admin menu. This allows developers to add their own menu items to the WPFTS settings section, providing convenient access to their extension’s settings.

When to Use

This hook is useful if your extension has settings that need to be modified through the admin interface. By adding your own menu item, you make your extension’s settings easily accessible to users.

Arguments

The wpfts_admin_menu hook does not accept any arguments.

Return Value

The wpfts_admin_menu hook should not return any value.

Example

/**
 * Adds a "My Addon Settings" menu item to the WPFTS settings section.
 */
add_action('wpfts_admin_menu', 'my_addon_admin_menu');
function my_addon_admin_menu() {
	add_submenu_page(
		'wpfts-options', // Parent menu item (WPFTS settings).
		'My Addon Settings', // Page title.
		'My Addon', // Menu title.
		'manage_options', // Capability (administrators only).
		'my-addon-settings', // Menu slug.
		'my_addon_settings_page' // Callback function.
	);
}
 
/**
 * Displays the addon settings page.
 */
function my_addon_settings_page() {
    // Code to display the settings page.
    echo '<h2>' . esc_html__('My Addon Settings', 'my-addon') . '</h2>';
    // ... settings form ...
}

Important Notes

  • The menu slug (my-addon-settings in the example) must be unique.
  • The function displaying the settings page (my_addon_settings_page in the example) should handle saving settings and display the settings form.
  • Make sure your code correctly handles nonce for protection against CSRF attacks.

Using the wpfts_admin_menu hook, you can integrate your extension’s settings into the WPFTS interface, making it more user-friendly.