Last active
August 29, 2015 14:13
-
-
Save michaeluno/5c2d4c84c84e6e17f6e0 to your computer and use it in GitHub Desktop.
Tests user meta of Admin Page Framework v3.5.0.
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 Test - User Meta | |
Plugin URI: http://en.michaeluno.jp/admin-page-framework | |
Description: Tests the user meta factory class. | |
Author: Michael Uno | |
Author URI: http://michaeluno.jp | |
Version: 1.0.0 | |
Requirements: PHP 5.2.4 or above, WordPress 3.3 or above. Admin Page Framework 3.5.0 or above | |
*/ | |
// Include the library file. Set your file path here. | |
$_sLibraryPath = defined( 'WP_DEBUG' ) && WP_DEBUG | |
? dirname( dirname( __FILE__ ) ) . '/admin-page-framework/development/admin-page-framework.php' | |
: dirname( dirname( __FILE__ ) ) . '/admin-page-framework/library/admin-page-framework.min.php'; | |
if ( ! class_exists( 'AdminPageFramework' ) && ! include( $_sLibraryPath ) ) { | |
return; | |
} | |
if ( ! class_exists( 'AdminPageFramework_UserMeta' ) ) { | |
return; | |
} | |
// Extend the class | |
class APFTest_UserMeta extends AdminPageFramework_UserMeta { | |
// Define the setUp() method to set how many pages, page titles and icons etc. | |
public function setUp() { | |
$this->addSettingFields( | |
array( | |
'field_id' => 'text_field', | |
'type' => 'text', | |
'title' => __( 'Text', 'admin-page-framework-demo' ), | |
'repeatable' => true, | |
'sortable' => true, | |
'description' => 'Type something here.', | |
), | |
array( | |
'field_id' => 'text_area', | |
'type' => 'textarea', | |
'title' => __( 'Text Area', 'admin-page-framework-demo' ), | |
'default' => 'Hi there!', | |
), | |
array( | |
'field_id' => 'radio_buttons', | |
'type' => 'radio', | |
'title' => __( 'Radio', 'admin-page-framework-demo' ), | |
'label' => array( | |
'a' => 'A', | |
'b' => 'B', | |
'c' => 'C', | |
), | |
'default' => 'a', | |
), | |
array() | |
); | |
} | |
/** | |
* A pre-defined content output filter callback. | |
*/ | |
public function content( $sContent ) { | |
return $sContent | |
. "<p class='apf-demo-content-description'>" . __( 'This text is inserted with the <code>content()</code> method.', 'admin-page-framework-demo' ) . "<p>"; | |
} | |
/** | |
* A pre-defined inline CSS filter callback. | |
* | |
* @remark style_{instantiated class name} | |
*/ | |
public function style_APFTest_UserMeta( $sCSSRules ) { | |
return $sCSSRules | |
. " | |
.apf-demo-content-description { | |
font-weight: bold; | |
font-style: italic; | |
text-decoration: underline; | |
margin-bottom: 2em; | |
}"; | |
} | |
/** | |
* A pre-defined validation callback method. | |
*/ | |
public function validate( $aInput, $aOldInput, $oFactory ) { | |
return $aInput; | |
} | |
} | |
new APFTest_UserMeta; | |
class APFTest_UserMetaSectionTab extends AdminPageFramework_UserMeta { | |
// Define the setUp() method to set how many pages, page titles and icons etc. | |
public function setUp() { | |
/* | |
* Create tabbed sections. | |
*/ | |
$this->addSettingSections( | |
array( | |
'section_id' => 'section_tab_a', | |
'section_tab_slug' => 'tabbed_sections', | |
'title' => __( 'Section Tab A', 'admin-page-framework-demo' ), | |
'description' => __( 'This is the first item of the tabbed section.', 'admin-page-framework-demo' ), | |
), | |
array( | |
'section_id' => 'section_tab_b', | |
'section_tab_slug' => 'tabbed_sections', | |
'title' => __( 'Section Tab B', 'admin-page-framework-demo' ), | |
'description' => __( 'This is the second item of the tabbed section.', 'admin-page-framework-demo' ), | |
) | |
); | |
/* | |
* Add form fields into the meta box. | |
*/ | |
$this->addSettingFields( | |
'section_tab_a', | |
array( | |
// 'section_id' => 'sectin_tab_a', | |
'field_id' => 'color_field_in_tabbed_section', | |
'title' => __( 'Color', 'admin-page-framework-demo' ), | |
'type' => 'color', | |
), | |
array( | |
'field_id' => 'text_field_in_tabbed_sections', | |
'title' => __( 'Text Field', 'admin-page-framework-demo' ), | |
'type' => 'text', | |
'sortable' => true, | |
'repeatable' => true, | |
) | |
); | |
$this->addSettingFields( | |
'section_tab_b', | |
array( | |
// 'section_id' => 'section_tab_b', | |
'field_id' => 'size_in_tabbed_sections', | |
'title' => __( 'Size', 'admin-page-framework-demo' ), | |
'type' => 'size', | |
), | |
array( | |
'field_id' => 'select_in_tabbed_sections', | |
'title' => __( 'Select', 'admin-page-framework-demo' ), | |
'type' => 'select', | |
'default' => 'b', | |
'label' => array( | |
'a' => 'A', | |
'b' => 'B', | |
'c' => 'c', | |
), | |
) | |
); | |
} | |
} | |
new APFTest_UserMetaSectionTab; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment