Get Started Five Basic Steps To create an option page with this framework, follow these steps. 1. Include the Library Class 12 if ( !class_exists( 'Admin_Page_Framework' ) ) include_once( '/classes/admin-page-framework.php' ); 2. Extend the Library Class Admin_Page_Framework is the class name defined by this framework. The extended class name is up to your choice. As an example, here, APF_CreateSettingPage is used. 12 class APF_CreateSettingPage extends Admin_Page_Framework {} 3. Define the SetUp() Method. The SetUp() method is a special method defined by this framework that is automatically loaded when the admin menu is about to be created (with the the admin_menu hook). So we just overwrite the method in the extended class. All settings need to be set within this method. 12345 function SetUp() { $this->SetRootMenu( 'Settings' ); // specifies to which parent menu to belong. $this->AddSubMenu( 'My First Setting Page', // page and menu title 'my_first_settings_page' ); // page slug} 4. Define methods for hooks. The method name is made up of the hook prefix + the page slug. Here, do_ is used as an example. There are lots of available hooks supported by this framework. 123456 function do_my_first_settings_page() { // do_ + pageslug ?> <h3>Say Something</h3> <p>This is my first admin page!</p> <?php} For available action hooks and filters, please refer to Hooks and Callbacks. 5. Instantiate the Class 1 new APF_CreateSettingPage; Simple Example Plugin 12345678910111213141516171819202122 <?php/* Plugin Name: Admin Page Framework - 0. Simple Example */ if ( !class_exists( 'Admin_Page_Framework' ) ) include_once( '/classes/admin-page-framework.php' ); class APF_MyClass extends Admin_Page_Framework { function Setup() { // The Setup() method must be defined $this->SetRootMenu( 'Settings' ); // specifies which top level menu to add the sub pages $this->AddSubMenu( 'My Page', // page and menu title 'mypage' ); // page slug } function do_mypage() { // do_ + pageslug ?> <h3>Hello!</h3> <p>This is my first admin page!</p> <?php }}new APF_MyClass; Screenshot Related PostsCreate an Admin PageCreate a Page GroupUse Section Tabs and Repeatable SectionsAdd a Meta Box in an Admin PageValidate Submitted Form Data of a Single Field
Dan May 15, 2013 at 10:39 pm Like the framework/guide! Made working with the settings so much easier! Good job! Reply ↓
Like the framework/guide! Made working with the settings so much easier! Good job!
Thanks!