Created
April 26, 2015 07:31
-
-
Save michaeluno/edb2706f10ca50caf9eb to your computer and use it in GitHub Desktop.
Tests form capabilities in 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 Test - Form Capability | |
Plugin URI: http://en.michaeluno.jp/admin-page-framework | |
Description: Tests form capabilities. | |
Author: Michael Uno | |
Author URI: http://michaeluno.jp | |
Version: 1.0.0 | |
*/ | |
// 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/admin-page-framework.php'; | |
if ( ! class_exists( 'AdminPageFramework' ) && ! include( $_sLibraryPath ) ) { | |
return; | |
} | |
class APF_Test_Capability_AdminPage extends AdminPageFramework { | |
public function setUp() { | |
$this->setRootMenuPage( | |
'Capability' // menu name | |
); | |
$this->addSubMenuItems( | |
array( | |
'title' => 'Test Capability', // page title | |
'page_slug' => 'test_capability', // page slug | |
'capability' => 'publish_posts', | |
) | |
); | |
} | |
public function load_test_capability( $oAdminPage ) { | |
$this->addSettingSections( | |
'test_capability', | |
array( | |
'section_id' => 'main', | |
'title' => 'Form Capability Test', | |
'capability' => 'publish_posts' | |
) | |
); | |
$this->addSettingFields( | |
'main', | |
array ( | |
'field_id' => 'text', | |
'type' => 'text', | |
'title' => __( 'Text', 'plugin' ), | |
'capability' => 'manage_options', | |
), | |
array ( | |
'field_id' => 'choices', | |
'type' => 'checkbox', | |
'title' => __( 'Choices', 'plugin' ), | |
'capability' => 'publish_posts', | |
'label' => array( | |
'one' => 'One', | |
'two' => 'Two', | |
), | |
), | |
array( | |
'field_id' => 'submit', | |
'type' => 'submit', | |
'capability' => 'publish_posts', | |
) | |
); | |
} | |
} | |
new APF_Test_Capability_AdminPage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment