Skip to content

Instantly share code, notes, and snippets.

@dimd13
Created October 25, 2018 09:50
Show Gist options
  • Save dimd13/ebbb79021b60ef8e951a6aaab8fb72e7 to your computer and use it in GitHub Desktop.
Save dimd13/ebbb79021b60ef8e951a6aaab8fb72e7 to your computer and use it in GitHub Desktop.
<?php
add_action( 'admin_menu', 'register_my_settings_page' );
function register_my_settings_page() {
add_submenu_page( 'edit.php?post_type=gallery', 'Media Selector', 'Media Selector', 'manage_options', 'gallery-settings', 'media_selector_settings_page_callback' );
//add_submenu_page( '<PARENT SLUG>', '<PAGE TITLE>', '<MENU TITLE>', '<ROLE>', '<MENU SLUG>', '<CALLBACK NAME>' );
}
function media_selector_settings_page_callback() {
?>
<div class="wrap">
<h2>Your Plugin Name</h2>
<form method="post" action="options.php">
<?php settings_fields( 'gallery-settings' ); ?>
<input type="text" name="new_option_name" value="<?php echo get_option('new_option_name'); ?>" />
<?php ?>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php
}
add_action( 'admin_init', 'register_my_settings' );
function register_my_settings () {
register_setting( 'gallery-settings', 'new_option_name' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment