ClassicPress Plugin Development: Add Plugin Options Page to Security Main Menu

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

When developing a plugin, it is usual to create an options page to allow users to configure the plugin. The most common way of making the plugin options page available to users is to add it to the Settings menu in the admin dashboard; however, ClassicPress has a Security menu available which allows security plugins to be separated from the other settings on a site. This Security menu does not exist in WordPress so if you’re writing a plugin to be compatible with both ClassicPress and WordPress you will need to manage this when adding the options page.

This is done using the add_security_page function available with ClassicPress.

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


$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 (should be unique for this menu); 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: ''


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

The function above is made accessible using the add_action function along with a admin_menu tag.

The below is an example, including check for the security menu being available, of an options page using my vendor prefix of azrcrv and a plugin identifer of XXXX:

add_action('admin_menu', 'azrcrv_XXXX_add_options_page');

function azrcrv_XXXX_add_options_page() {
	if (function_exists('add_security_page')){
			esc_html__('XXXX Options', 'text-domain'),
			esc_html__('XXXX', 'text-domain'),
			dirname(plugin_basename(__FILE__ )),
		// add options in WordPress compatible way; possibly using the add_options_page function.

If the menu being added is for a network, rather than individual site, the $tag would be network_admin_menu instead of admin_menu.

When an options page is added to the Security menu, a plugin action link is automatically added:

Security plugin action link example

Click to show/hide the ClassicPress Plugin Development Series Index

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Leave a Reply

Your email address will not be published. Required fields are marked *