Last active
December 21, 2015 09:18
-
-
Save michaeluno/6283702 to your computer and use it in GitHub Desktop.
This is a very simple sample plugin for Admin Page Framework v2 that adds form elements.
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 - Sample Form Elements | |
Plugin URI: http://en.michaeluno.jp/admin-page-framework | |
Description: Demonstrates adding a form elements for Admin Page Framework v2.0.0 or above. | |
Author: Michael Uno | |
Author URI: http://michaeluno.jp | |
Version: 0.0.1 | |
Requirements: PHP 5.2.4 or above, WordPress 3.2 or above, Admin Page Framework 2.0.0 or above. | |
*/ | |
if ( ! class_exists( 'AdminPageFramework' ) ) | |
include_once( dirname( __FILE__ ) . '/class/admin-page-framework.php' ); | |
class APF_Sample_Form_Elements extends AdminPageFramework { | |
public function setUp() { | |
$this->setRootMenuPage( 'APF Form' ); // specifies to which parent menu to belong. | |
$this->addSubMenuItems( | |
array( | |
'strPageTitle' => 'Form Fields', | |
'strPageSlug' => 'apf_form_fields', | |
'numOrder' => 1, | |
) | |
); | |
$this->addSettingSections( | |
array( | |
'strSectionID' => 'text_fields', | |
'strPageSlug' => 'apf_form_fields', | |
'strTitle' => 'Text Fields', | |
'strDescription' => 'These are text type fields.', | |
'numOrder' => 10, | |
), | |
array( | |
'strSectionID' => 'selectors', | |
'strPageSlug' => 'apf_form_fields', | |
'strTitle' => 'Selectors', | |
) | |
); | |
$this->addSettingFields( | |
array( // Single text field | |
'strFieldID' => 'text', | |
'strSectionID' => 'text_fields', | |
'strTitle' => 'Text', | |
'strDescription' => 'Type something here.', | |
'strType' => 'text', | |
'numOrder' => 1, | |
'vDefault' => 123456, | |
'vSize' => 40, | |
), | |
array( // Text Area | |
'strFieldID' => 'textarea', | |
'strSectionID' => 'text_fields', | |
'strTitle' => 'Single Text Area', | |
'strDescription' => 'Type a text string here.', | |
'strType' => 'textarea', | |
'vDefault' => 'Hello World! This is set as the default string.', | |
'vRows' => 6, | |
'vCols' => 80, | |
), | |
array( // Single Dropdown List | |
'strFieldID' => 'select', | |
'strSectionID' => 'selectors', | |
'strTitle' => 'Dropdown List', | |
'strDescription' => 'This is a drop down list.', | |
'strType' => 'select', | |
'vDefault' => 2, | |
'vLabel' => array( 'red', 'blue', 'yellow', 'orange' ) | |
), | |
array( // Submit button | |
'strFieldID' => 'submit_button', | |
'strSectionID' => 'selectors', | |
'strType' => 'submit', | |
'vLabel' => __( 'Save Changes' ), | |
) | |
); | |
} | |
} | |
if ( is_admin() ) | |
new APF_Sample_Form_Elements; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment