function mytheme_add_admin() { global $themename, $options; if ($_GET['page'] == basename(__FILE__)) { if ('save' == $_REQUEST['action']) { foreach ($options as $value) { update_option($value['id'], $_REQUEST[$value['id']]); } /* foreach ($options as $value) { if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } */ header("Location: admin.php?page=themeset.php&saved=true"); die; } else { if ('reset' == $_REQUEST['action']) { foreach ($options as $value) { delete_option($value['id']); } header("Location: admin.php?page=themeset.php&reset=true"); die; } } } add_theme_page($themename . " Options", $themename . "设置", 'edit_themes', basename(__FILE__), 'mytheme_admin'); }
/** * Add new menu in theme.php */ public function add_appearance_menu() { /** * @link https://codex.wordpress.org/Function_Reference/add_theme_page */ add_theme_page(__('ItalyStrap Theme Options', 'ItalyStrap'), __('Theme Options', 'ItalyStrap'), $this->capability, 'italystrap-option-page', array($this, 'italystrap_callback_function')); }
function mytheme_add_admin() { global $themename, $shortname, $options; if ($_GET['page'] == basename(__FILE__)) { if ('save' == $_REQUEST['action']) { foreach ($options as $value) { if ($value['type'] != 'header') { update_option($value['id'], $_REQUEST[$value['id']]); } } foreach ($options as $value) { if (isset($_REQUEST[$value['id']])) { update_option($value['id'], $_REQUEST[$value['id']]); } else { delete_option($value['id']); } } header("Location: themes.php?page=settings.php&saved=true"); die; } else { if ('reset' == $_REQUEST['action']) { foreach ($options as $value) { delete_option($value['id']); } header("Location: themes.php?page=settings.php&reset=true"); die; } } } add_theme_page($themename . " Settings", "Theme Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin'); }
function addAdminPage() { // global $themename, $shortname, $options; if ($_GET['page'] == basename(__FILE__)) { if ('save' == $_REQUEST['action']) { foreach ($this->options as $value) { update_option($value['id'], $_REQUEST[$value['id']]); } foreach ($this->options as $value) { if (isset($_REQUEST[$value['id']])) { update_option($value['id'], $_REQUEST[$value['id']]); } else { delete_option($value['id']); } } header("Location: themes.php?page=" . basename(__FILE__) . "&saved=true"); die; } else { if ('reset' == $_REQUEST['action']) { foreach ($this->options as $value) { delete_option($value['id']); } header("Location: themes.php?page=" . basename(__FILE__) . "&reset=true"); die; } } } add_theme_page($this->themename . " Options", $this->themename . " Options", 'edit_themes', basename(__FILE__), array(&$this, 'adminPage')); }
/** * Initializes all the theme settings page functionality. This function is used to create the theme settings * page, then use that as a launchpad for specific actions that need to be tied to the settings page. * * @since 0.7.0 * @global string $hybrid The global theme object. * @return void */ function hybrid_settings_page_init() { global $hybrid; /* Get theme information. */ $theme = wp_get_theme(get_template(), get_theme_root(get_template_directory())); $prefix = hybrid_get_prefix(); /* Register theme settings. */ register_setting("{$prefix}_theme_settings", "{$prefix}_theme_settings", 'hybrid_save_theme_settings'); /* Create the theme settings page. */ $hybrid->settings_page = add_theme_page(sprintf(esc_html__('%s Theme Settings', 'hybrid-core'), $theme->get('Name')), esc_html__('Theme Settings', 'hybrid-core'), hybrid_settings_page_capability(), 'theme-settings', 'hybrid_settings_page'); /* Check if the settings page is being shown before running any functions for it. */ if (!empty($hybrid->settings_page)) { /* Filter the settings page capability so that it recognizes the 'edit_theme_options' cap. */ add_filter("option_page_capability_{$prefix}_theme_settings", 'hybrid_settings_page_capability'); /* Add help tabs to the theme settings page. */ add_action("load-{$hybrid->settings_page}", 'hybrid_settings_page_help'); /* Load the theme settings meta boxes. */ add_action("load-{$hybrid->settings_page}", 'hybrid_load_settings_page_meta_boxes'); /* Create a hook for adding meta boxes. */ add_action("load-{$hybrid->settings_page}", 'hybrid_settings_page_add_meta_boxes'); /* Load the JavaScript and stylesheets needed for the theme settings screen. */ add_action('admin_enqueue_scripts', 'hybrid_settings_page_enqueue_scripts'); add_action('admin_enqueue_scripts', 'hybrid_settings_page_enqueue_styles'); add_action("admin_footer-{$hybrid->settings_page}", 'hybrid_settings_page_load_scripts'); } }
/** * Add the admin menu entries */ function siteorigin_panels_admin_menu() { if (!siteorigin_panels_setting('home-page')) { return; } add_theme_page(__('Custom Home Page Builder', 'siteorigin-panels'), __('Home Page', 'siteorigin-panels'), 'edit_theme_options', 'so_panels_home_page', 'siteorigin_panels_render_admin_home_page'); }
function test_menu_page_url() { $current_user = get_current_user_id(); wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); update_option( 'siteurl', 'http://example.com' ); // add some pages add_options_page( 'Test Settings', 'Test Settings', 'manage_options', 'testsettings', 'mt_settings_page' ); add_management_page( 'Test Tools', 'Test Tools', 'manage_options', 'testtools', 'mt_tools_page' ); add_menu_page( 'Test Toplevel', 'Test Toplevel', 'manage_options', 'mt-top-level-handle', 'mt_toplevel_page' ); add_submenu_page( 'mt-top-level-handle', 'Test Sublevel', 'Test Sublevel', 'manage_options', 'sub-page', 'mt_sublevel_page' ); add_submenu_page( 'mt-top-level-handle', 'Test Sublevel 2', 'Test Sublevel 2', 'manage_options', 'sub-page2', 'mt_sublevel_page2' ); add_theme_page( 'With Spaces', 'With Spaces', 'manage_options', 'With Spaces', 'mt_tools_page' ); add_pages_page( 'Appending Query Arg', 'Test Pages', 'edit_pages', 'testpages', 'mt_pages_page' ); $expected['testsettings'] = 'http://example.com/wp-admin/options-general.php?page=testsettings'; $expected['testtools'] = 'http://example.com/wp-admin/tools.php?page=testtools'; $expected['mt-top-level-handle'] = 'http://example.com/wp-admin/admin.php?page=mt-top-level-handle'; $expected['sub-page'] = 'http://example.com/wp-admin/admin.php?page=sub-page'; $expected['sub-page2'] = 'http://example.com/wp-admin/admin.php?page=sub-page2'; $expected['not_registered'] = ''; $expected['With Spaces'] = 'http://example.com/wp-admin/themes.php?page=WithSpaces'; $expected['testpages'] = 'http://example.com/wp-admin/edit.php?post_type=page&page=testpages'; foreach ($expected as $name => $value) { $this->assertEquals( $value, menu_page_url( $name, false ) ); } wp_set_current_user( $current_user ); }
function admin_menu() { if (current_user_can('manage_options') || current_user_can($this->capability)) { $plugin_page = add_theme_page('edit.php?post_type=csshortcode', __('Options', 'sws'), __('Options', 'sws'), 0, 'shortcode-options', array(&$this, 'shortcode_options')); add_action('admin_head-' . $plugin_page, array(&$this, 'options_head')); } }
/** * Load up the menu page */ function theme_options_add_page() { add_theme_page(__('Takelage einstellen', 'piratenkleider'), __('Takelage einstellen', 'piratenkleider'), 'edit_theme_options', 'theme_options', 'theme_options_do_page'); add_theme_page(__('Segel setzen', 'piratenkleider'), __('Segel setzen', 'piratenkleider'), 'edit_theme_options', 'theme_defaultbilder', 'theme_defaultbilder_do_page'); add_theme_page(__('Captn & Crew', 'piratenkleider'), __('Captn & Crew', 'piratenkleider'), 'edit_theme_options', 'theme_kontaktinfos', 'theme_kontaktinfos_do_page'); add_theme_page(__('Klüverbaum', 'piratenkleider'), __('Klüverbaum', 'piratenkleider'), 'edit_theme_options', 'theme_designspecials', 'theme_designspecials_do_page'); }
function admin_menu() { // Add the theme page add_theme_page(__('Maera Addons', 'maera'), __('Maera Addons', 'maera'), 'install_plugins', 'maera-ri', array($this, 'settings_page')); // Remove the menu item for that page remove_submenu_page('themes.php', 'maera-ri'); }
/** * Add our theme options page to the admin menu, including some help documentation. * * This function is attached to the admin_menu action hook. * * @since Twenty Eleven 1.0 */ function twentyeleven_theme_options_add_page() { $theme_page = add_theme_page( __( 'Theme Options', 'twentyeleven' ), // Name of page __( 'Theme Options', 'twentyeleven' ), // Label in menu 'edit_theme_options', // Capability required 'theme_options', // Menu slug, used to uniquely identify the page 'theme_options_render_page' // Function that renders the options page ); if ( ! $theme_page ) return; $help = '<p>' . __( 'Some themes provide customization options that are grouped together on a Theme Options screen. If you change themes, options may change or disappear, as they are theme-specific. Your current theme, Twenty Eleven, provides the following Theme Options:', 'twentyeleven' ) . '</p>' . '<ol>' . '<li>' . __( '<strong>Color Scheme</strong>: You can choose a color palette of "Light" (light background with dark text) or "Dark" (dark background with light text) for your site.', 'twentyeleven' ) . '</li>' . '<li>' . __( '<strong>Link Color</strong>: You can choose the color used for text links on your site. You can enter the HTML color or hex code, or you can choose visually by clicking the "Select a Color" button to pick from a color wheel.', 'twentyeleven' ) . '</li>' . '<li>' . __( '<strong>Default Layout</strong>: You can choose if you want your site’s default layout to have a sidebar on the left, the right, or not at all.', 'twentyeleven' ) . '</li>' . '</ol>' . '<p>' . __( 'Remember to click "Save Changes" to save any changes you have made to the theme options.', 'twentyeleven' ) . '</p>' . '<p><strong>' . __( 'For more information:', 'twentyeleven' ) . '</strong></p>' . '<p>' . __( '<a href="http://codex.wordpress.org/Appearance_Theme_Options_Screen" target="_blank">Documentation on Theme Options</a>', 'twentyeleven' ) . '</p>' . '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>', 'twentyeleven' ) . '</p>'; add_contextual_help( $theme_page, $help ); }
/** * Add Admin Menu item for plugin * * Plugin needs its own Page in the Settings section of the Admin menu. * */ function jr_mt_admin_hook() { // Add Settings Page for this Plugin global $jr_mt_plugin_data; add_theme_page($jr_mt_plugin_data['Name'], 'Multiple Themes plugin', 'switch_themes', 'jr_mt_settings', 'jr_mt_settings_page'); add_options_page($jr_mt_plugin_data['Name'], 'Multiple Themes plugin', 'switch_themes', 'jr_mt_settings', 'jr_mt_settings_page'); }
/** * Create Options page * * @uses add_theme_page() * @uses add_action() * * @since 1.0.0 */ function optionsframework_add_admin() { $of_page = add_theme_page(THEMENAME, 'Theme Options', 'edit_theme_options', 'optionsframework', 'optionsframework_options_page'); // Add framework functionaily to the head individually add_action("admin_print_scripts-{$of_page}", 'of_load_only'); add_action("admin_print_styles-{$of_page}", 'of_style_only'); }
function et_pb_export_layouts_page() { add_theme_page(esc_html__('Export Page Builder Layouts', 'Divi'), esc_html__('Export Page Builder Layouts', 'Divi'), 'export', 'et_pb_export_layouts', 'et_pb_export_layouts_interface'); if (isset($_GET['page']) && 'et_divi_homepage_builder' === $_GET['page'] && isset($_POST['et_hb_action'])) { et_homepage_builder_save_data(); } }
function sampression_theme_options() { $samp_menu = add_theme_page(__('Sampression Theme Option', 'sampression'), __('Theme Options', 'sampression'), 'edit_theme_options', 'sampression-options', 'sampression_build_options'); //$samp_menu = add_menu_page(__("Sampression Theme Options",'sampression'), __("Sampression",'sampression'), 'edit_theme_options', 'sampression-options', 'sampression_build_options'); add_action('admin_print_scripts-' . $samp_menu, 'sampression_admin_enqueue_scripts'); add_action('admin_print_styles-' . $samp_menu, 'sampression_admin_enqueue_styles'); }
/** * Add our theme options page to the admin menu, including some help documentation. * * This function is attached to the admin_menu action hook. * */ function oriental_theme_options_add_page() { $theme_page = add_theme_page(__('Theme Options', 'oriental'), __('Theme Options', 'oriental'), 'edit_theme_options', 'theme_options', 'oriental_theme_options_render_page'); if (!$theme_page) { return; } }
function mytheme_add_admin() { global $themename, $shortname, $options, $blog_id; if ($_GET['page'] == basename(__FILE__)) { if ('save' == $_REQUEST['action']) { foreach ($options as $value) { update_option($value['id'], $_REQUEST[$value['id']]); } foreach ($options as $value) { if (isset($_REQUEST[$value['id']])) { update_option($value['id'], $_REQUEST[$value['id']]); } else { delete_option($value['id']); } } header("Location: themes.php?page=theme-options.php&saved=true"); die; } else { if ('reset' == $_REQUEST['action']) { foreach ($options as $value) { delete_option($value['id']); } header("Location: themes.php?page=theme-options.php&reset=true"); die; } else { if ('resetwidgets' == $_REQUEST['action']) { update_option('sidebars_widgets', NULL); header("Location: themes.php?page=theme-options.php&resetwidgets=true"); die; } } } } add_theme_page($themename . " Options", "Thematic Options", 'edit_themes', basename(__FILE__), 'mytheme_admin'); }
/** * Registers a submenu page to access the AMP template editor panel in the Customizer. */ function amp_add_customizer_link() { // Teensy little hack on menu_slug, but it works. No redirect! $menu_slug = add_query_arg(array('autofocus[panel]' => AMP_Template_Customizer::PANEL_ID, 'return' => rawurlencode(admin_url()), AMP_CUSTOMIZER_QUERY_VAR => true), 'customize.php'); // Add the theme page. $page = add_theme_page(__('AMP', 'amp'), __('AMP', 'amp'), 'edit_theme_options', $menu_slug); }
/** * Add the custom CSS editor to the admin menu. */ function siteorigin_custom_css_admin_menu() { add_theme_page(__('Custom CSS', 'vantage'), __('Custom CSS', 'vantage'), 'edit_theme_options', 'siteorigin_custom_css', 'siteorigin_custom_css_page'); if (current_user_can('edit_theme_options') && isset($_POST['siteorigin_custom_css_save'])) { check_admin_referer('custom_css', '_sononce'); $theme = basename(get_template_directory()); // Sanitize CSS input. Should keep most tags, apart from script and style tags. $custom_css = siteorigin_custom_css_clean(filter_input(INPUT_POST, 'custom_css')); $current = get_option('siteorigin_custom_css[' . $theme . ']'); if ($current === false) { add_option('siteorigin_custom_css[' . $theme . ']', $custom_css, '', 'no'); } else { update_option('siteorigin_custom_css[' . $theme . ']', $custom_css); } // If this has changed, then add a revision. if ($current != $custom_css) { $revisions = get_option('siteorigin_custom_css_revisions[' . $theme . ']'); if (empty($revisions)) { add_option('siteorigin_custom_css_revisions[' . $theme . ']', array(), '', 'no'); $revisions = array(); } $revisions[time()] = $custom_css; // Sort the revisions and cut off any old ones. krsort($revisions); $revisions = array_slice($revisions, 0, 15, true); update_option('siteorigin_custom_css_revisions[' . $theme . ']', $revisions); } } }
/** * Add our theme options page to the admin menu, including some help documentation. * * This function is attached to the admin_menu action hook. * * @since Sundance 1.0 */ function sundance_theme_options_add_page() { $theme_page = add_theme_page(__('Theme Options', 'sundance'), __('Theme Options', 'sundance'), 'edit_theme_options', 'theme_options', 'sundance_theme_options_render_page'); if (!$theme_page) { return; } }
function roots_theme_options_add_page() { $theme_page = add_theme_page(__('Theme Options', 'roots'), __('Theme Options', 'roots'), 'edit_theme_options', 'theme_options', 'roots_theme_options_render_page'); if (!$theme_page) { return; } }
function okfnwp_add_admin() { global $themename, $shortname, $options; if (array_key_exists('page', $_GET) && $_GET['page'] == basename(__FILE__)) { if (array_key_exists('action', $_REQUEST) && 'save' == $_REQUEST['action']) { foreach ($options as $value) { update_option($value['id'], $_REQUEST[$value['id']]); } foreach ($options as $value) { if (isset($_REQUEST[$value['id']])) { update_option($value['id'], $_REQUEST[$value['id']]); } else { delete_option($value['id']); } } header("Location: themes.php?page=theme-options.php&saved=true"); die; } elseif (array_key_exists('action', $_REQUEST) && 'reset' == $_REQUEST['action']) { foreach ($options as $value) { delete_option($value['id']); } header("Location: themes.php?page=theme-options.php&reset=true"); die; } } add_theme_page('Theme Options', 'Theme Options', 'switch_themes', basename(__FILE__), 'okfnwp_admin'); }
function init() { $page = add_theme_page(__('Custom Image Header'), __('Custom Image Header'), 'edit_themes', 'custom-header', array(&$this, 'admin_page')); add_action("admin_print_scripts-$page", array(&$this, 'js_includes')); add_action("admin_head-$page", array(&$this, 'js'), 50); add_action("admin_head-$page", $this->admin_header_callback, 51); }
/** * Add a subpage called "Theme Options" to the appearance menu. * * @since 1.0.0 */ function add_custom_options_page() { $menu = $this->menu_settings(); // If you want a top level menu, see this Gist: // https://gist.github.com/devinsays/884d6abe92857a329d99 $this->options_screen = add_theme_page($menu['page_title'], $menu['menu_title'], $menu['capability'], $menu['menu_slug'], array($this, 'options_page')); }
/** * add menu of vicuna options */ function add_vicuna_config_menu() { if (!current_user_can('switch_themes')) { return; } add_theme_page('Vicuna Config', 'Vicuna Config', 0, basename(__FILE__), 'vicuna_config_menu'); }
function bfa_ata_add_admin() { global $options, $bfa_ata; if (isset($_GET['page'])) { if ($_GET['page'] == "atahualpa-options") { if (isset($_REQUEST['action'])) { if ('save' == $_REQUEST['action']) { foreach ($options as $value) { if ($value['category'] == $_REQUEST['category']) { if (isset($value['escape'])) { if (isset($_REQUEST[$value['id']])) { // Since 3.6.8 removed bfa_escape //$bfa_ata[ $value['id'] ] = stripslashes(bfa_escape($_REQUEST[ $value['id'] ] )); $bfa_ata[$value['id']] = stripslashes($_REQUEST[$value['id']]); } else { unset($bfa_ata[$value['id']]); } } elseif (isset($value['stripslashes'])) { if ($value['stripslashes'] == "no") { if (isset($_REQUEST[$value['id']])) { $bfa_ata[$value['id']] = $_REQUEST[$value['id']]; } else { unset($bfa_ata[$value['id']]); } } } else { if (isset($_REQUEST[$value['id']])) { $bfa_ata[$value['id']] = stripslashes($_REQUEST[$value['id']]); } else { unset($bfa_ata[$value['id']]); } } } } update_option('bfa_ata4', $bfa_ata); header("Location: themes.php?page=atahualpa-options&saved=true"); die; } else { if ('reset' == $_REQUEST['action']) { if ("reset-all" == $_REQUEST['category']) { delete_option('bfa_ata4'); } else { foreach ($options as $value) { if ($value['category'] == $_REQUEST['category']) { $bfa_ata[$value['id']] = $value['std']; } } update_option('bfa_ata4', $bfa_ata); } header("Location: themes.php?page=atahualpa-options&reset=true"); die; } } } } } $atapage = add_theme_page("Atahualpa Options", "Atahualpa Theme Options", 'edit_theme_options', 'atahualpa-options', 'bfa_ata_admin'); // Since 3.6.8: add_action("admin_print_styles-{$atapage}", 'bfa_ata_admin_enqueue'); }
function siteorigin_plugin_activation_page() { if (!isset($_GET[sanitize_key('siteorigin-pa-install')])) { return; } add_theme_page(__('Install Theme Plugin', 'vantage'), __('Install Theme Plugin', 'vantage'), 'install_plugins', 'siteorigin_plugin_activation', 'siteorigin_plugin_activation_render_page'); }
/** add option menu update and call to init register wp option */ function clean_theme_settings_grunt_menu() { //add_options_page( 'Grunt Settings', 'Grunt Settings', 'manage_options', 'clean-theme-grunt-settings', 'clean_theme_settings_grunt_options_call_back' ); add_theme_page('Grunt Settings', 'Grunt Settings', 'manage_options', 'clean-theme-grunt-settings', 'clean_theme_settings_grunt_options_call_back'); //call register settings function add_action('admin_init', 'register_grunt_settings'); }
function webriti_admin_menu_pannel() { $page2 = add_theme_page('webriti_themes', 'Webriti Themes', 'edit_theme_options', 'webriti_themes', 'webriti_themes_function'); //add_action('admin_print_styles-'.$page2, 'webriti_theme_admin_enqueue_script'); wp_enqueue_style('responsive', get_template_directory_uri() . '/functions/webriti/css/bootstrap-responsive.css'); wp_enqueue_style('bootstrap', get_template_directory_uri() . '/functions/webriti/css/webriti_theme.css'); }
/** * Add our theme options page to the admin menu, including some help documentation. */ function forever_theme_options_add_page() { $theme_page = add_theme_page(__('Theme Options', 'forever'), __('Theme Options', 'forever'), 'edit_theme_options', 'theme_options', 'forever_theme_options_render_page'); if (!$theme_page) { return; } }