Created
June 28, 2014 08:15
-
-
Save michaeluno/9311c7c1075b97096377 to your computer and use it in GitHub Desktop.
This shows how to set custom values to repeatable fields created by 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 - Setting Custom Repeatable Field Values */ | |
if ( ! class_exists( 'AdminPageFramework' ) ) { | |
include_once( dirname( __FILE__ ) . '/class/admin-page-framework.min.php' ); | |
} | |
class AFFTest_CustomRepeatableFieldValues extends AdminPageFramework { | |
public function setUp() { | |
$this->setRootMenuPage( 'Settings' ); // where to belong | |
$this->addSubMenuItem( | |
array( | |
'title' => __( 'Custom Repeatable Field Values', 'demo-custom-field-values' ), // page and menu title | |
'page_slug' => 'apf_demo_custom_repeatable_field_values' // page slug | |
) | |
); | |
$this->addSettingSections( | |
array( | |
'section_id' => 'custom_repeatable_values', | |
'page_slug' => 'apf_demo_custom_repeatable_field_values', | |
) | |
); | |
$this->addSettingFields( | |
'custom_repeatable_values', // the target section ID | |
array( | |
'field_id' => 'my_text_field', | |
'title' => __( 'Text Input', 'demo-custom-field-values' ), | |
'type' => 'text', | |
'repeatable' => true, | |
'value' => 'one', | |
array( | |
'value' => 'two', | |
), | |
array( | |
'value' => 'three', | |
) | |
) | |
); | |
} | |
/** | |
* Do something in the page. | |
* | |
* @remark This is a pre-defined framework method. | |
*/ | |
public function do_apf_demo_custom_repeatable_field_values() { // do_{page slug} | |
submit_button(); // Add a submit button | |
} | |
/** | |
* The pre-defined validation callback method. | |
* | |
* @remark This is a pre-defined framework method. | |
*/ | |
public function validation_apf_demo_custom_repeatable_field_values( $aInput, $aOldInput, $oAdminPage ) { // validation_{page slug} | |
// See the log file in the wp-content directory. | |
// AdminPageFramework_Debug::logArray( $aInput ); | |
$this->setSettingNotice( 'This is a test message.', 'updated' ); | |
return $aInput; | |
} | |
} | |
new AFFTest_CustomRepeatableFieldValues( ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment