add_security_page( string $page_title, string $menu_title, string $menu_slug, callable $function = '' )

Add submenu page to the Security main menu.


Description

The function which is hooked in to handle the output of the page must check that the user has at least ‘manage_options’ capability.


Parameters

$page_title

(string) (Required) The text to be displayed in the title tags of the page when the menu is selected.

$menu_title

(string) (Required) The text to be used for the menu.

$menu_slug

(string) (Required) The slug name to refer to this menu by; must match an active plugin or mu-plugin slug.

$function

(callable) (Optional) The function to be called to output the content for this page.

Default value: ''


Return

(false|string) The resulting page's hook_suffix, or false if the user does not have the 'manage_options' capability.


Source

File: wp-admin/includes/plugin.php

function add_security_page( $page_title, $menu_title, $menu_slug, $function = '' ) {
	$mu_plugins = get_mu_plugins();
	$plugins    = array_merge(
		array_keys( (array) get_site_option( 'active_sitewide_plugins', [] ) ),
		(array) get_option( 'active_plugins', [] ),
		array_keys( $mu_plugins )
	);
	if ( is_network_admin() ) {
		$filter     = 'network_admin_plugin_action_links_';
		$capability = 'manage_network_options';
	} else {
		$filter     = 'plugin_action_links_';
		$capability = 'manage_options';
	}
	foreach ( $plugins as $path ) {
		$parts = explode( '/', $path );
		if ( $menu_slug === $parts[0] ) {
			add_filter( $filter . $path, '_security_page_action_links', PHP_INT_MAX, 4 );
			return add_submenu_page( 'security.php', $page_title, $menu_title, $capability, $menu_slug, $function );
		}
	}

	_doing_it_wrong( __METHOD__, '$menu_slug must match an active plugin or mu-plugin slug; ' . $menu_slug, '1.1.0' );
}