Last active
December 25, 2015 03:31
-
-
Save michaeluno/c1ad334e2633ea567643 to your computer and use it in GitHub Desktop.
Demonstrates how to add page meta box specific to in-page tabs with Admin Page Framework. This is a sample plugin introduced in the tutorial Add a Page Meta Box Specific to an In-page Tab (http://en.michaeluno.jp/admin-page-framework/tutorials-v3/10-add-a-page-meta-box-specific-to-an-in-page-tab/).
This file contains hidden or 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 10 - Add a Page Meta Box Specific to an In-page Tab | |
| * Plugin URI: http://en.michaeluno.jp/admin-page-framework | |
| * Description: Adds a page meta box specific to in-page tab. | |
| * Author: Michael Uno | |
| * Author URI: http://michaeluno.jp | |
| * Version: 1.0.1 | |
| * Requirements: PHP 5.2.4 or above, WordPress 3.4 or above. Admin Page Framework 3.0.6 or above | |
| */ | |
| // Include the library file. Set your file path here. | |
| include( dirname( dirname( __FILE__ ) ) . '/admin-page-framework/apf/admin-page-framework.php' ); | |
| class APF_Tutorial_NormalPageMetaBox extends AdminPageFramework_PageMetaBox { | |
| /* | |
| * Use the setUp() method to define settings of this meta box. | |
| */ | |
| public function setUp() { | |
| /** | |
| * Adds setting fields in the meta box. | |
| */ | |
| $this->addSettingFields( | |
| array( | |
| 'field_id' => 'tutorial_normal_page_metabox_select', | |
| 'type' => 'select', | |
| 'title' => __( 'Select', 'admin-page-framework-tutorial' ), | |
| 'label' => array( | |
| 'a' => __( 'Apple', 'admin-page-framework-tutorial' ), | |
| 'b' => __( 'Banana', 'admin-page-framework-tutorial' ), | |
| 'c' => __( 'Cherry', 'admin-page-framework-tutorial' ), | |
| ), | |
| 'is_multiple' => true, | |
| 'attributes' => array( | |
| 'size' => 5, | |
| ), | |
| ), | |
| array( | |
| 'field_id' => 'tutorial_normal_page_metabox_textarea', | |
| 'type' => 'textarea', | |
| 'title' => __( 'Text Area', 'admin-page-framework-tutorial' ), | |
| 'repeatable' => true, | |
| ) | |
| ); | |
| } | |
| } | |
| new APF_Tutorial_NormalPageMetaBox( | |
| null, // meta box id - passing null will make it auto generate | |
| __( 'Normal Page Meta Box', 'admin-page-framework-tutorial' ), // title | |
| array( 'my_tabs' => array( 'my_tab_b' ) ), | |
| 'normal', // context | |
| 'default' // priority | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment