Last active
December 24, 2015 07:37
-
-
Save michaeluno/9272455 to your computer and use it in GitHub Desktop.
Creates an admin page with Admin Page Framework v3. This is an example plugin introduced in the tutorial, Create an Admin Page (http://en.michaeluno.jp/admin-page-framework/tutorials-v3/01-create-an-admin-page/).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Admin Page Framework Tutorial 01 - Create an Admin Page | |
Plugin URI: http://en.michaeluno.jp/admin-page-framework | |
Description: Creates an admin page with Admin Page Framework v3 | |
Author: Michael Uno | |
Author URI: http://michaeluno.jp | |
Version: 1.0.2 | |
Requirements: PHP 5.2.4 or above, WordPress 3.4 or above. Admin Page Framework 3.0.0 or above | |
*/ | |
include( dirname( __FILE__ ) . '/library/apf/admin-page-framework.php' ); | |
// Extend the class | |
class APF_CreatePage extends AdminPageFramework { | |
/** | |
* The set-up method which is triggered automatically with the 'wp_loaded' hook. | |
* | |
* Here we define the setup() method to set how many pages, page titles and icons etc. | |
*/ | |
public function setUp() { | |
// Create the root menu - specifies to which parent menu to add. | |
$this->setRootMenuPage( 'Settings' ); | |
// Add the sub menus and the pages. | |
$this->addSubMenuItems( | |
array( | |
'title' => '1. My First Setting Page', // page and menu title | |
'page_slug' => 'my_first_settings_page' // page slug | |
) | |
); | |
} | |
/** | |
* One of the pre-defined methods which is triggered when the page contents is going to be rendered. | |
* | |
* Notice that the name of the method is 'do_' + the page slug. | |
* So the slug should not contain characters which cannot be used in function names such as dots and hyphens. | |
*/ | |
public function do_my_first_settings_page() { | |
?> | |
<h3>Action Hook</h3> | |
<p>This is inserted by the 'do_' + page slug method.</p> | |
<?php | |
} | |
} | |
// Instantiate the class object. | |
new APF_CreatePage; | |
// That's it!! See, it's very short and easy, huh? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment