ClassicPress Plugin Development: Get Options Page Title

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.

Over the last couple of posts in this series, I’ve discussed how options can be loaded and saved, loaded with defaults and loaded with multilevel defaults. Over the next couple of pages, I’m going to show how an options page can be created and the options saved, but first a quick post on how the options page title can be populated.

I’ve seen a lot of plugins where the options page title has been a string which has been echoed. However, when the options page is added to the settings main menu, the first parameter is the page title. So instead of echoing a new string, we can use the get_admin_page_title function to get the title set when the options page was added to the menu.

<h1>
	<?php
		esc_html_e(get_admin_page_title());
	?>
</h1>

As you can see from the example code, above, the call to get_admin_page_title has been wrapped with a esc_html_e to echo and escape the page title.

Click to show/hide the ClassicPress Plugin Development Series Index