-
-
Save Clorith/f411d04237328415d2fa60f7e192c9de to your computer and use it in GitHub Desktop.
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: Test plugin | |
* Description: Test settings page TinyMCE use | |
*/ | |
function wporg_settings_init() { | |
register_setting( 'wporg', 'wporg_options' ); | |
add_settings_section( | |
'wporg_section_developers', | |
__( 'The Matrix has you.', 'wporg' ), 'wporg_section_developers_callback', | |
'wporg' | |
); | |
add_settings_field( | |
'wporg_field_pill', | |
__( 'Pill', 'wporg' ), | |
'wporg_field_pill_cb', | |
'wporg', | |
'wporg_section_developers', | |
array( | |
'label_for' => 'wporg_field_pill', | |
'class' => 'wporg_row', | |
'wporg_custom_data' => 'custom', | |
) | |
); | |
} | |
add_action( 'admin_init', 'wporg_settings_init' ); | |
function wporg_section_developers_callback( $args ) { | |
?> | |
<p id="<?php echo esc_attr( $args['id'] ); ?>"><?php esc_html_e( 'Follow the white rabbit.', 'wporg' ); ?></p> | |
<?php | |
} | |
function wporg_field_pill_cb( $args ) { | |
wp_editor( '', 'my_custom_editor_id' ); | |
} | |
function wporg_options_page() { | |
add_menu_page( | |
'WPOrg', | |
'WPOrg Options', | |
'manage_options', | |
'wporg', | |
'wporg_options_page_html' | |
); | |
} | |
add_action( 'admin_menu', 'wporg_options_page' ); | |
function wporg_options_page_html() { | |
if ( ! current_user_can( 'manage_options' ) ) { | |
return; | |
} | |
if ( isset( $_GET['settings-updated'] ) ) { | |
add_settings_error( 'wporg_messages', 'wporg_message', __( 'Settings Saved', 'wporg' ), 'updated' ); | |
} | |
settings_errors( 'wporg_messages' ); | |
?> | |
<div class="wrap"> | |
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1> | |
<form action="options.php" method="post"> | |
<?php | |
settings_fields( 'wporg' ); | |
do_settings_sections( 'wporg' ); | |
submit_button( 'Save Settings' ); | |
?> | |
</form> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment