Created
September 25, 2012 06:58
-
-
Save aprakasa/3780367 to your computer and use it in GitHub Desktop.
wp_editor() and Genesis Admin Page
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 | |
class Test_Setting_Admin extends Genesis_Admin_Boxes { | |
/** | |
* Create an admin menu item and settings page. | |
* | |
* @since 1.0 | |
*/ | |
function __construct() { | |
$page_id = 'test_setting_admin'; | |
$menu_ops = array( | |
'submenu' => array( | |
'parent_slug' => 'genesis', | |
'page_title' => __( 'Genesis - Test Setting Admin', 'text-domain' ), | |
'menu_title' => __( 'Test Setting Icon', 'text-domain' ) | |
) | |
); | |
$page_ops = array( | |
'screen_icon' => 'plugins', | |
); | |
$settings_field = TEST_SETTING_FIELD; | |
$default_settings = array( | |
'content_bar' => 'Hello World', | |
); | |
/** Create the page */ | |
$this->create( $page_id, $menu_ops, $page_ops, $settings_field, $default_settings ); | |
} | |
/** | |
* Load the necessary scripts for this admin page. | |
* | |
* @since 1.0 | |
* | |
*/ | |
function scripts() { | |
/** Load parent scripts as well as Genesis admin scripts */ | |
parent::scripts(); | |
genesis_load_admin_js(); | |
} | |
/** | |
* Register meta boxes. | |
* | |
* @since 1.0 | |
* | |
*/ | |
function metaboxes() { | |
add_meta_box( 'test-general-settings', __( 'General Settings', 'text-domain' ), array( $this, 'test_general_settings' ), $this->pagehook, 'main' ); | |
} | |
/** | |
* Callback function for test_general_settings | |
* | |
* @since 0.1 | |
* | |
*/ | |
function test_general_settings() { | |
?> | |
<p> | |
<label for="<?php echo $this->get_field_id( 'content_bar' ); ?>"><?php _e( 'Your conent', 'text-domain' ); ?></label> | |
<?php wp_editor( get_field_value( 'content_bar' ) , $this->get_field_id( 'content_bar' ), array( 'textarea_name' => 'content', 'media_buttons' => false, 'textarea_rows' => 8 ) ); ?> | |
</p> | |
<?php | |
} | |
} | |
add_action( 'genesis_admin_menu', 'test_setting_admin' ); | |
/** | |
* Instantiate the class to create the menu. | |
* | |
* @since 1.0 | |
*/ | |
function test_setting_admin() { | |
new Test_Setting_Admin; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment