Permalink
Browse files

Added the Test example component.

Added the `ajax_test` custom field type.
  • Loading branch information...
michaeluno committed Jan 13, 2017
1 parent 19f510d commit f4e9c13225b264114e0b69a1a118814168cd4d94
@@ -57,7 +57,10 @@ private function _loadPostMetaBoxes() {
// Repeatable Collapsible Sections
include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/post_meta_box/APF_MetaBox_RepeatableCollapsibleSections.php' );
-
+
+ // For debugging
+ include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/post_meta_box/APF_PostMetaBox_TestAjaxField.php' );
+
}
/**
@@ -67,10 +70,12 @@ private function _loadTermMeta() {
if ( version_compare( $GLOBALS[ 'wp_version' ], '4.4', '>=' ) ) {
include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/term_meta/APF_TermMeta.php' );
+ include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/term_meta/APF_TermMetaTestAjaxField.php' );
return;
- }
+ }
include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/taxonomy_field/APF_TaxonomyField.php' );
-
+ include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/taxonomy_field/APF_TaxonomyFieldTestAjaxField.php' );
+
}
/**
@@ -96,14 +101,16 @@ private function _loadAdminPaeges() {
private function _loadUserMeta() {
include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/user_meta/APF_MyUserMeta.php' );
-
+ include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/user_meta/APF_UserMetaTestAjaxField.php' );
+
}
private function _loadWidgets() {
include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/widget/APF_Widget.php' );
include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/widget/APF_Widget_WithSection.php' );
-
+ include( AdminPageFrameworkLoader_Registry::$sDirPath . '/example/widget/APF_WidgetTestAjaxField.php' );
+
}
/**
@@ -104,6 +104,7 @@ public function setUp() {
new APF_Demo_ManageOptions;
new APF_Demo_HiddenPage;
new APF_Demo_Contact;
+ new APF_Demo_Test;
// Add an external link.
$this->addSubMenuItem(
@@ -28,7 +28,7 @@ public function __construct() {
'set_up_' . $this->_sClassName,
array( $this, 'replyToSetUp' )
);
-
+
}
/**
@@ -25,8 +25,6 @@ public function __construct() {
array( $this, 'replyToSetUp' )
);
-
-
}
/**
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Admin Page Framework Loader
+ *
+ * http://en.michaeluno.jp/admin-page-framework/
+ * Copyright (c) 2013-2017 Michael Uno; Licensed GPLv2
+ *
+ */
+
+/**
+ * Adds a page to the loader plugin.
+ *
+ * @since 3.8.14
+ * @package AdminPageFramework/Example
+ */
+class APF_Demo_Test {
+
+ private $_sClassName = 'APF_Demo';
+
+ private $_sPageSlug = 'apf_test_page';
+
+ /**
+ * Adds a page item and sets up hooks.
+ */
+ public function __construct() {
+
+ if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
+ return;
+ }
+
+ add_action(
+ 'set_up_' . $this->_sClassName,
+ array( $this, 'replyToSetUp' )
+ );
+
+ }
+
+ /**
+ * @callback action set_up_{instantiated class name}
+ */
+ public function replyToSetUp( $oFactory ) {
+// new AjaxTestCustomFieldType( $oFactory->oProp->sClassName );
+ /**
+ * ( required ) Add sub-menu items (pages or links)
+ */
+ $oFactory->addSubMenuItems(
+ array(
+ 'title' => __( 'Test', 'admin-page-framework-loader' ),
+ 'page_slug' => $this->_sPageSlug,
+ 'order' => 35,
+ )
+ );
+// new APF_Demo_Test_AjaxField( $oFactory, $this->_sPageSlug );
+ add_action( 'load_' . $this->_sPageSlug, array( $this, 'replyToLoadPage' ) );
+
+ }
+
+ /**
+ * @return void
+ * @callback action load_{page slug}
+ */
+ public function replyToLoadPage( $oFactory ) {
+
+ /**
+ * (optional) Add in-page tabs - here tabs are defined in the below classes.
+ */
+ $_aTabClasses = array(
+ 'APF_Demo_Test_AjaxField',
+ );
+ foreach ( $_aTabClasses as $_sTabClassName ) {
+ if ( ! class_exists( $_sTabClassName ) ) {
+ continue;
+ }
+ new $_sTabClassName( $oFactory, $this->_sPageSlug );
+ }
+
+ }
+
+}
@@ -0,0 +1,110 @@
+<?php
+/**
+ * Admin Page Framework Loader
+ *
+ * Demonstrates the usage of Admin Page Framework.
+ *
+ * http://en.michaeluno.jp/admin-page-framework/
+ * Copyright (c) 2013-2017 Michael Uno; Licensed GPLv2
+ *
+ */
+
+/**
+ * Adds a tab of the set page to the loader plugin.
+ *
+ * @since 3.8.14
+ */
+class APF_Demo_Test_AjaxField {
+
+ public $oFactory;
+
+ public $sClassName;
+
+ public $sPageSlug;
+
+ public $sTabSlug = 'ajax';
+
+ public function __construct( $oFactory, $sPageSlug ) {
+
+ $this->oFactory = $oFactory;
+ $this->sClassName = $oFactory->oProp->sClassName;
+ $this->sPageSlug = $sPageSlug;
+ $this->sSectionID = $this->sTabSlug;
+
+ $this->oFactory->addInPageTabs(
+ $this->sPageSlug, // target page slug
+ array(
+ 'tab_slug' => $this->sTabSlug,
+ 'title' => __( 'Ajax', 'admin-page-framework-loader' ),
+ )
+ );
+
+ // load + page slug + tab slug
+ add_action( 'load_' . $this->sPageSlug . '_' . $this->sTabSlug, array( $this, 'replyToLoadTab' ) );
+
+ }
+
+ /**
+ * Triggered when the tab starts loading.
+ *
+ * @callback action load_{page slug}_{tab slug}
+ */
+ public function replyToLoadTab( $oAdminPage ) {
+
+ new AjaxTestCustomFieldType( $this->sClassName );
+
+ // add_action( 'do_' . $this->sPageSlug . '_' . $this->sTabSlug, array( $this, 'replyToDoTab' ) );
+
+ $this->___addFormElements( $oAdminPage );
+
+ new APF_Demo_Test_PageMetaBoxSide(
+ null, // meta box id - passing null will make it auto generate
+ __( 'Side', 'admin-page-framework-loader' ), // title
+ array(
+ $this->sPageSlug => array(
+ 'ajax', // tab slugs
+ ),
+ ),
+ 'side', // context
+ 'default' // priority
+ );
+
+ }
+
+ private function ___addFormElements( $oAdminPage ) {
+
+ // Section
+ $oAdminPage->addSettingSections(
+ $this->sPageSlug, // the target page slug
+ array(
+ 'section_id' => $this->sSectionID,
+ 'tab_slug' => $this->sTabSlug,
+ 'title' => __( 'Ajax Field Test', 'admin-page-framework-loader' ),
+ 'description' => array(
+ __( 'Tests fields that use Ajax.', 'admin-page-framework-loader' ),
+ ),
+ )
+ );
+
+ // Fields
+ $oAdminPage->addSettingFields(
+ $this->sSectionID, // the target section id
+ array(
+ 'field_id' => 'ajax_test_filed',
+ 'type' => 'ajax_test',
+ 'title' => __( 'Ajax', 'admin-page-framework-loader' ),
+ 'label' => array(
+ 'a' => 'A',
+ 'b' => 'B',
+ 'c' => 'C',
+ ),
+ )
+ );
+
+ }
+
+ public function replyToDoTab() {
+ submit_button();
+ }
+
+}
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Admin Page Framework - Demo
+ *
+ * Demonstrates the usage of Admin Page Framework.
+ *
+ * http://en.michaeluno.jp/admin-page-framework/
+ * Copyright (c) 2013-2017 Michael Uno; Licensed GPLv2
+ *
+ */
+
+class APF_Demo_Test_PageMetaBoxSide extends AdminPageFramework_PageMetaBox {
+
+ /*
+ * ( optional ) Use the setUp() method to define settings of this meta box.
+ */
+ public function setUp() {
+
+ /*
+ * ( optional ) Adds setting fields into the meta box.
+ */
+ $this->addSettingFields(
+ array(
+ 'field_id' => 'ajax_test_in_page_meta_box',
+ 'type' => 'ajax_test',
+ 'title' => __( 'Ajax', 'admin-page-framework-loader' ),
+ 'label' => array(
+ 'a' => 'A',
+ 'b' => 'B',
+ 'c' => 'C',
+ ),
+ ),
+ array(
+ 'field_id' => 'submit_in_meta_box',
+ 'type' => 'submit',
+ 'show_title_column' => false,
+ 'label_min_width' => 0,
+ 'save' => false,
+ 'attributes' => array(
+ 'field' => array(
+ 'style' => 'float:right; width:auto;',
+ ),
+ ),
+ ),
+ array()
+ );
+
+ }
+
+ public function load() {
+ new AjaxTestCustomFieldType( $this->oProp->sClassName );
+ }
+
+}
@@ -90,8 +90,12 @@
"APF_Demo_PageMetaBox__WithFormSection"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/admin_page/page_meta_box/page_meta_box/APF_Demo_PageMetaBox__WithFormSection.php",
"APF_Demo_PageMetaBox__FirstTab"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/admin_page/page_meta_box/tab/APF_Demo_PageMetaBox__FirstTab.php",
"APF_Demo_PageMetaBox__SecondTab"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/admin_page/page_meta_box/tab/APF_Demo_PageMetaBox__SecondTab.php",
+ "APF_Demo_Test"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/admin_page/test/APF_Demo_Test.php",
+ "APF_Demo_Test_AjaxField"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/admin_page/test/APF_Demo_Test_AjaxField.php",
+ "APF_Demo_Test_PageMetaBoxSide"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/admin_page/test/page_meta_box/APF_Demo_Test_PageMetaBoxSide.php",
"APF_BasicUsage"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/basic_usage/APF_BasicUsage.php",
"AceCustomFieldType"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/library/ace-custom-field-type/AceCustomFieldType.php",
+ "AjaxTestCustomFieldType"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/library/ajax-test-custom-field-type/AjaxTestCustomFieldType.php",
"NoUISliderCustomFieldType"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/library/nouislider-custom-field-type/NoUISliderCustomFieldType.php",
"PathCustomFieldType"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/library/path-custom-field-type/PathCustomFieldType.php",
"jQueryFileTreePlus"=> AdminPageFrameworkLoader_Registry::$sDirPath . "/example/library/path-custom-field-type/connectors/jQueryFileTreePlus.php",
Oops, something went wrong.

0 comments on commit f4e9c13

Please sign in to comment.