Created
October 18, 2014 10:36
-
-
Save michaeluno/9e45d68413324a4fbafd to your computer and use it in GitHub Desktop.
Demonstrates how to add repeatable tabbed sections in meta boxes with Admin Page Framework.
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 Demo - Repeatable Tabbed Sections in Meta Boxes | |
Plugin URI: http://en.michaeluno.jp/admin-page-framework | |
Description: Demonstrates how to add repeatable tabbed sections in meta boxes with Admin Page Framework. | |
Author: Michael Uno | |
Author URI: http://michaeluno.jp | |
Version: 1.0.0 | |
Requirements: Admin Page Framework | |
*/ | |
if ( ! class_exists( 'AdminPageFramework' ) ) { | |
include_once( dirname( dirname( __FILE__ ) ) . '/admin-page-framework/development/admin-page-framework.php' ); | |
// include_once( dirname( dirname( __FILE__ ) ) . '/admin-page-framework/library/admin-page-framework.min.php' ); | |
} | |
class APFDemo_RepeatableTabbedSectionsInMetaBoxes extends AdminPageFramework_MetaBox { | |
/** | |
* Do set-ups. | |
*/ | |
public function setUp() { | |
/* | |
* Create repetable tabbed sections. | |
*/ | |
$this->addSettingSections( | |
array( | |
'section_id' => 'repeatable_tabbed_sections_demo', | |
'section_tab_slug' => 'repeatable_tabbes_sections_demo', | |
'title' => __( 'Repeatable', 'admin-page-framework-demo' ), | |
'description' => __( 'It is possible to tab repeatable sections.', 'admin-page-framework-demo' ), | |
'repeatable' => true, // this makes the section repeatable | |
) | |
); | |
/* | |
* Add form fields that belong to the repeatable section. | |
*/ | |
$this->addSettingFields( | |
'repeatable_tabbed_sections_demo', | |
array( | |
'field_id' => 'tab_title', | |
'type' => 'section_title', | |
'label' => __( 'Name', 'admin-page-framework-demo' ), | |
'attributes' => array( | |
'size' => 10, | |
), | |
), | |
array( | |
'field_id' => 'text_field_in_tabbed_repeatable_section', | |
'title' => __( 'Text', 'admin-page-framework-demo' ), | |
'type' => 'text', | |
'default' => 'xyz', | |
), | |
array( | |
'field_id' => 'repeatable_field_in_tabbed_repetable_section', | |
'title' => __( 'Repeatable', 'admin-page-framework-demo' ), | |
'type' => 'text', | |
'repeatable' => true, | |
) | |
); | |
} | |
} | |
if ( is_admin() ) { | |
new APFDemo_RepeatableTabbedSectionsInMetaBoxes( | |
null, // meta box ID - can be null. If null is passed, the ID gets automatically generated and the class name with all lower case characters will be applied. | |
__( 'Repeatable Section Tabs', 'admin-page-framework-demo' ), // title | |
array( 'apf_posts' ), // post type slugs: post, page, etc. | |
'normal', // context (what kind of metabox this is) | |
'default' // priority | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment