function akismet_admin_init() { if ( function_exists( 'get_plugin_page_hook' ) ) $hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' ); else $hook = 'dashboard_page_akismet-stats-display'; add_action('admin_head-'.$hook, 'akismet_stats_script'); }
function akismet_admin_init() { global $wp_version; // all admin functions are disabled in old versions if ( !function_exists('is_multisite') && version_compare( $wp_version, '3.0', '<' ) ) { function akismet_version_warning() { echo " <div id='akismet-warning' class='updated fade'><p><strong>".sprintf(__('Akismet %s requires WordPress 3.0 or higher.'), AKISMET_VERSION) ."</strong> ".sprintf(__('Please <a href="%s">upgrade WordPress</a> to a current version, or <a href="%s">downgrade to version 2.4 of the Akismet plugin</a>.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). "</p></div> "; } add_action('admin_notices', 'akismet_version_warning'); return; } if ( function_exists( 'get_plugin_page_hook' ) ) $hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' ); else $hook = 'dashboard_page_akismet-stats-display'; add_action('admin_head-'.$hook, 'akismet_stats_script'); add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal'); wp_register_style('akismet.css', AKISMET_PLUGIN_URL . '/akismet.css'); wp_enqueue_style('akismet.css'); wp_register_script('akismet.js', AKISMET_PLUGIN_URL . '/akismet.js', array('jquery')); wp_enqueue_script('akismet.js'); }
function akismet_admin_init() { global $wp_version; // all admin functions are disabled in old versions if (!function_exists('is_multisite') && version_compare($wp_version, '3.0', '<')) { function akismet_version_warning() { echo ' <div id="akismet-warning" class="updated fade"><p><strong>' . sprintf(__('Akismet %s requires WordPress 3.0 or higher.'), AKISMET_VERSION) . '</strong> ' . sprintf(__('Please <a href="%s">upgrade WordPress</a> to a current version, or <a href="%s">downgrade to version 2.4 of the Akismet plugin</a>.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/') . '</p></div> '; } add_action('admin_notices', 'akismet_version_warning'); return; } if (function_exists('get_plugin_page_hook')) { $hook = get_plugin_page_hook('akismet-stats-display', 'index.php'); } else { $hook = 'dashboard_page_akismet-stats-display'; } add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal'); }
private static function is_hook_or_plugin_page($page_url, $parent_page_url = '') { if (empty($parent_page_url)) { $parent_page_url = 'admin.php'; } $pageFile = self::remove_query_from($page_url); //Files in /wp-admin are part of WP core so they're not plugin pages. if (self::is_wp_admin_file($pageFile)) { return false; } $hasHook = get_plugin_page_hook($page_url, $parent_page_url) !== null; if ($hasHook) { return true; } /* * Special case: Absolute paths. * * - add_submenu_page() applies plugin_basename() to the menu slug, so we don't need to worry about plugin * paths. However, absolute paths that *don't* point point to the plugins directory can be a problem. * * - Due to a known PHP bug, certain invalid paths can crash PHP. See self::is_safe_to_append(). * * - WP 3.9.2 and 4.0+ unintentionally break menu URLs like "foo.php?page=c:\a\b.php" because esc_url() * interprets the part before the colon as an invalid protocol. As a result, such links have an empty URL * on Windows (but they might still work on other OS). * * - Recent versions of WP won't let you load a PHP file from outside the plugins and mu-plugins directories * with "admin.php?page=filename". See the validate_file() call in /wp-admin/admin.php. However, such filenames * can still be used as unique slugs for menus with hook callbacks, so we shouldn't reject them outright. * Related: https://core.trac.wordpress.org/ticket/10011 */ $allowPathConcatenation = self::is_safe_to_append($pageFile); $pluginFileExists = $allowPathConcatenation && $page_url != 'index.php' && is_file(WP_PLUGIN_DIR . '/' . $pageFile); if ($pluginFileExists) { return true; } return false; }
// Pretend you didn't see this. $current_theme_actions = array(); if (is_array($submenu) && isset($submenu['themes.php'])) { foreach ((array) $submenu['themes.php'] as $item) { $class = ''; if ('themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos($item[2], 'customize.php')) { continue; } // 0 = name, 1 = capability, 2 = file if (strcmp($self, $item[2]) == 0 && empty($parent_file) || $parent_file && $item[2] == $parent_file) { $class = ' current'; } if (!empty($submenu[$item[2]])) { $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); if (file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) { $current_theme_actions[] = "<a class='button button-secondary{$class}' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; } else { $current_theme_actions[] = "<a class='button button-secondary{$class}' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; } } elseif (!empty($item[2]) && current_user_can($item[1])) { $menu_file = $item[2]; if (current_user_can('customize')) { if ('custom-header' === $menu_file) { $current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize{$class}' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>"; } elseif ('custom-background' === $menu_file) { $current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize{$class}' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>"; } } if (false !== ($pos = strpos($menu_file, '?'))) {
/** * Display menu. * * @access private * @since 2.7.0 * * @global string $self * @global string $parent_file * @global string $submenu_file * @global string $plugin_page * @global string $typenow * * @param array $menu * @param array $submenu * @param bool $submenu_as_parent */ function _wp_menu_output($menu, $submenu, $submenu_as_parent = true) { global $self, $parent_file, $submenu_file, $plugin_page, $typenow; $first = true; // 0 = menu_title, 1 = capability, 2 = menu_slug, 3 = page_title, 4 = classes, 5 = hookname, 6 = icon_url foreach ($menu as $key => $item) { $admin_is_parent = false; $class = array(); $aria_attributes = ''; $aria_hidden = ''; $is_separator = false; if ($first) { $class[] = 'wp-first-item'; $first = false; } $submenu_items = array(); if (!empty($submenu[$item[2]])) { $class[] = 'wp-has-submenu'; $submenu_items = $submenu[$item[2]]; } if ($parent_file && $item[2] == $parent_file || empty($typenow) && $self == $item[2]) { $class[] = !empty($submenu_items) ? 'wp-has-current-submenu wp-menu-open' : 'current'; } else { $class[] = 'wp-not-current-submenu'; if (!empty($submenu_items)) { $aria_attributes .= 'aria-haspopup="true"'; } } if (!empty($item[4])) { $class[] = esc_attr($item[4]); } $class = $class ? ' class="' . join(' ', $class) . '"' : ''; $id = !empty($item[5]) ? ' id="' . preg_replace('|[^a-zA-Z0-9_:.]|', '-', $item[5]) . '"' : ''; $img = $img_style = ''; $img_class = ' dashicons-before'; if (false !== strpos($class, 'wp-menu-separator')) { $is_separator = true; } /* * If the string 'none' (previously 'div') is passed instead of an URL, don't output * the default menu image so an icon can be added to div.wp-menu-image as background * with CSS. Dashicons and base64-encoded data:image/svg_xml URIs are also handled * as special cases. */ if (!empty($item[6])) { $img = '<img src="' . $item[6] . '" alt="" />'; if ('none' === $item[6] || 'div' === $item[6]) { $img = '<br />'; } elseif (0 === strpos($item[6], 'data:image/svg+xml;base64,')) { $img = '<br />'; $img_style = ' style="background-image:url(\'' . esc_attr($item[6]) . '\')"'; $img_class = ' svg'; } elseif (0 === strpos($item[6], 'dashicons-')) { $img = '<br />'; $img_class = ' dashicons-before ' . sanitize_html_class($item[6]); } } $arrow = '<div class="wp-menu-arrow"><div></div></div>'; $title = wptexturize($item[0]); // hide separators from screen readers if ($is_separator) { $aria_hidden = ' aria-hidden="true"'; } echo "\n\t<li{$class}{$id}{$aria_hidden}>"; if ($is_separator) { echo '<div class="separator"></div>'; } elseif ($submenu_as_parent && !empty($submenu_items)) { $submenu_items = array_values($submenu_items); // Re-index. $menu_hook = get_plugin_page_hook($submenu_items[0][2], $item[2]); $menu_file = $submenu_items[0][2]; if (false !== ($pos = strpos($menu_file, '?'))) { $menu_file = substr($menu_file, 0, $pos); } if (!empty($menu_hook) || 'index.php' != $submenu_items[0][2] && file_exists(WP_PLUGIN_DIR . "/{$menu_file}") && !file_exists(ABSPATH . "/wp-admin/{$menu_file}")) { $admin_is_parent = true; echo "<a href='admin.php?page={$submenu_items[0][2]}'{$class} {$aria_attributes}>{$arrow}<div class='wp-menu-image{$img_class}'{$img_style}>{$img}</div><div class='wp-menu-name'>{$title}</div></a>"; } else { echo "\n\t<a href='{$submenu_items[0][2]}'{$class} {$aria_attributes}>{$arrow}<div class='wp-menu-image{$img_class}'{$img_style}>{$img}</div><div class='wp-menu-name'>{$title}</div></a>"; } } elseif (!empty($item[2]) && current_user_can($item[1])) { $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); $menu_file = $item[2]; if (false !== ($pos = strpos($menu_file, '?'))) { $menu_file = substr($menu_file, 0, $pos); } if (!empty($menu_hook) || 'index.php' != $item[2] && file_exists(WP_PLUGIN_DIR . "/{$menu_file}") && !file_exists(ABSPATH . "/wp-admin/{$menu_file}")) { $admin_is_parent = true; echo "\n\t<a href='admin.php?page={$item[2]}'{$class} {$aria_attributes}>{$arrow}<div class='wp-menu-image{$img_class}'{$img_style}>{$img}</div><div class='wp-menu-name'>{$item[0]}</div></a>"; } else { echo "\n\t<a href='{$item[2]}'{$class} {$aria_attributes}>{$arrow}<div class='wp-menu-image{$img_class}'{$img_style}>{$img}</div><div class='wp-menu-name'>{$item[0]}</div></a>"; } } if (!empty($submenu_items)) { echo "\n\t<ul class='wp-submenu wp-submenu-wrap'>"; echo "<li class='wp-submenu-head' aria-hidden='true'>{$item[0]}</li>"; $first = true; // 0 = menu_title, 1 = capability, 2 = menu_slug, 3 = page_title, 4 = classes foreach ($submenu_items as $sub_key => $sub_item) { if (!current_user_can($sub_item[1])) { continue; } $class = array(); if ($first) { $class[] = 'wp-first-item'; $first = false; } $menu_file = $item[2]; if (false !== ($pos = strpos($menu_file, '?'))) { $menu_file = substr($menu_file, 0, $pos); } // Handle current for post_type=post|page|foo pages, which won't match $self. $self_type = !empty($typenow) ? $self . '?post_type=' . $typenow : 'nothing'; if (isset($submenu_file)) { if ($submenu_file == $sub_item[2]) { $class[] = 'current'; } // If plugin_page is set the parent must either match the current page or not physically exist. // This allows plugin pages with the same hook to exist under different parents. } elseif (!isset($plugin_page) && $self == $sub_item[2] || isset($plugin_page) && $plugin_page == $sub_item[2] && ($item[2] == $self_type || $item[2] == $self || file_exists($menu_file) === false)) { $class[] = 'current'; } if (!empty($sub_item[4])) { $class[] = esc_attr($sub_item[4]); } $class = $class ? ' class="' . join(' ', $class) . '"' : ''; $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); $sub_file = $sub_item[2]; if (false !== ($pos = strpos($sub_file, '?'))) { $sub_file = substr($sub_file, 0, $pos); } $title = wptexturize($sub_item[0]); if (!empty($menu_hook) || 'index.php' != $sub_item[2] && file_exists(WP_PLUGIN_DIR . "/{$sub_file}") && !file_exists(ABSPATH . "/wp-admin/{$sub_file}")) { // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir if (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/{$menu_file}") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") || file_exists($menu_file)) { $sub_item_url = add_query_arg(array('page' => $sub_item[2]), $item[2]); } else { $sub_item_url = add_query_arg(array('page' => $sub_item[2]), 'admin.php'); } $sub_item_url = esc_url($sub_item_url); echo "<li{$class}><a href='{$sub_item_url}'{$class}>{$title}</a></li>"; } else { echo "<li{$class}><a href='{$sub_item[2]}'{$class}>{$title}</a></li>"; } } echo "</ul>"; } echo "</li>"; } echo '<li id="collapse-menu" class="hide-if-no-js"><div id="collapse-button"><div></div></div>'; echo '<span>' . esc_html__('Collapse menu') . '</span>'; echo '</li>'; }
} } else { $$wpvar = $_POST["$wpvar"]; } } } $xfn_js = $sack_js = $list_js = $cat_js = $dbx_js = $editing = false; require(ABSPATH . '/wp-admin/menu.php'); // Handle plugin admin pages. if (isset($_GET['page'])) { $plugin_page = stripslashes($_GET['page']); $plugin_page = plugin_basename($plugin_page); $page_hook = get_plugin_page_hook($plugin_page, $pagenow); if ( $page_hook ) { if (! isset($_GET['noheader'])) require_once(ABSPATH . '/wp-admin/admin-header.php'); do_action($page_hook); } else { if ( validate_file($plugin_page) ) { die(__('Invalid plugin page')); } if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page")) die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); if (! isset($_GET['noheader']))
/** * Display menu. * * @access private * @since 2.7.0 * * @param array $menu * @param array $submenu * @param bool $submenu_as_parent */ function _wp_menu_output($menu, $submenu, $submenu_as_parent = true) { global $self, $parent_file, $submenu_file, $plugin_page, $pagenow; $first = true; // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src foreach ($menu as $key => $item) { $admin_is_parent = false; $class = array(); if ($first) { $class[] = 'wp-first-item'; $first = false; } if (!empty($submenu[$item[2]])) { $class[] = 'wp-has-submenu'; } if ($parent_file && $item[2] == $parent_file || strcmp($self, $item[2]) == 0) { if (!empty($submenu[$item[2]])) { $class[] = 'wp-has-current-submenu wp-menu-open'; } else { $class[] = 'current'; } } if (isset($item[4]) && !empty($item[4])) { $class[] = $item[4]; } $class = $class ? ' class="' . join(' ', $class) . '"' : ''; $tabindex = ' tabindex="1"'; $id = isset($item[5]) && !empty($item[5]) ? ' id="' . preg_replace('|[^a-zA-Z0-9_:.]|', '-', $item[5]) . '"' : ''; $img = ''; if (isset($item[6]) && !empty($item[6])) { if ('div' === $item[6]) { $img = '<br />'; } else { $img = '<img src="' . $item[6] . '" alt="" />'; } } $toggle = '<div class="wp-menu-toggle"><br /></div>'; echo "\n\t<li{$class}{$id}>"; if (false !== strpos($class, 'wp-menu-separator')) { echo '<a class="separator" href="?unfoldmenu=1"><br /></a>'; } elseif ($submenu_as_parent && !empty($submenu[$item[2]])) { $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); $menu_file = $submenu[$item[2]][0][2]; if (false !== ($pos = strpos($menu_file, '?'))) { $menu_file = substr($menu_file, 0, $pos); } if ('index.php' != $submenu[$item[2]][0][2] && file_exists(WP_PLUGIN_DIR . "/{$menu_file}") || !empty($menu_hook)) { $admin_is_parent = true; echo "<div class='wp-menu-image'><a href='admin.php?page={$submenu[$item[2]][0][2]}'>{$img}</a></div>{$toggle}<a href='admin.php?page={$submenu[$item[2]][0][2]}'{$class}{$tabindex}>{$item[0]}</a>"; } else { echo "\n\t<div class='wp-menu-image'><a href='{$submenu[$item[2]][0][2]}'>{$img}</a></div>{$toggle}<a href='{$submenu[$item[2]][0][2]}'{$class}{$tabindex}>{$item[0]}</a>"; } } else { if (current_user_can($item[1])) { $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); $menu_file = $item[2]; if (false !== ($pos = strpos($menu_file, '?'))) { $menu_file = substr($menu_file, 0, $pos); } if ('index.php' != $item[2] && file_exists(WP_PLUGIN_DIR . "/{$menu_file}") || !empty($menu_hook)) { $admin_is_parent = true; echo "\n\t<div class='wp-menu-image'><a href='admin.php?page={$item[2]}'>{$img}</a></div>{$toggle}<a href='admin.php?page={$item[2]}'{$class}{$tabindex}>{$item[0]}</a>"; } else { echo "\n\t<div class='wp-menu-image'><a href='{$item[2]}'>{$img}</a></div>{$toggle}<a href='{$item[2]}'{$class}{$tabindex}>{$item[0]}</a>"; } } } if (!empty($submenu[$item[2]])) { echo "\n\t<div class='wp-submenu'><div class='wp-submenu-head'>{$item[0]}</div><ul>"; $first = true; foreach ($submenu[$item[2]] as $sub_key => $sub_item) { if (!current_user_can($sub_item[1])) { continue; } $class = array(); if ($first) { $class[] = 'wp-first-item'; $first = false; } $menu_file = $item[2]; if (false !== ($pos = strpos($menu_file, '?'))) { $menu_file = substr($menu_file, 0, $pos); } if (isset($submenu_file)) { if ($submenu_file == $sub_item[2]) { $class[] = 'current'; } // If plugin_page is set the parent must either match the current page or not physically exist. // This allows plugin pages with the same hook to exist under different parents. } else { if (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($menu_file) || $item[2] == $self) || !isset($plugin_page) && $self == $sub_item[2]) { $class[] = 'current'; } } $class = $class ? ' class="' . join(' ', $class) . '"' : ''; $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); $sub_file = $sub_item[2]; if (false !== ($pos = strpos($sub_file, '?'))) { $sub_file = substr($sub_file, 0, $pos); } if ('index.php' != $sub_item[2] && file_exists(WP_PLUGIN_DIR . "/{$sub_file}") || !empty($menu_hook)) { // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir $parent_exists = !$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/{$menu_file}") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") || file_exists($menu_file); if ($parent_exists) { echo "<li{$class}><a href='{$item[2]}?page={$sub_item[2]}'{$class}{$tabindex}>{$sub_item[0]}</a></li>"; } elseif ('admin.php' == $pagenow || !$parent_exists) { echo "<li{$class}><a href='admin.php?page={$sub_item[2]}'{$class}{$tabindex}>{$sub_item[0]}</a></li>"; } else { echo "<li{$class}><a href='{$item[2]}?page={$sub_item[2]}'{$class}{$tabindex}>{$sub_item[0]}</a></li>"; } } else { echo "<li{$class}><a href='{$sub_item[2]}'{$class}{$tabindex}>{$sub_item[0]}</a></li>"; } } echo "</ul></div>"; } echo "</li>"; } }
function get_admin_page_title() { global $title; global $menu; global $submenu; global $pagenow; global $plugin_page; if ( isset( $title ) && !empty ( $title ) ) { return $title; } $hook = get_plugin_page_hook( $plugin_page, $pagenow ); $parent = $parent1 = get_admin_page_parent(); if ( empty ( $parent) ) { foreach ( $menu as $menu_array ) { if ( isset( $menu_array[3] ) ) { if ( $menu_array[2] == $pagenow ) { $title = $menu_array[3]; return $menu_array[3]; } else if ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) { $title = $menu_array[3]; return $menu_array[3]; } } else { $title = $menu_array[0]; return $title; } } } else { foreach (array_keys( $submenu ) as $parent) { foreach ( $submenu[$parent] as $submenu_array ) { if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) && (($parent == $pagenow ) || ($parent == $plugin_page ) || ($plugin_page == $hook ) || (($pagenow == 'admin.php' ) && ($parent1 != $submenu_array[2] ) ) ) ) { $title = $submenu_array[3]; return $submenu_array[3]; } if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page continue; if ( isset( $submenu_array[3] ) ) { $title = $submenu_array[3]; return $submenu_array[3]; } else { $title = $submenu_array[0]; return $title; } } } } return $title; }
/** * Convert a WP submenu structure to an associative array * * @param array $item An element of the $submenu array * @param integer $pos The position (index) of that element * @param string $parent Parent file that this menu item belongs to. * @return array */ function submenu2assoc($item, $pos = 0, $parent = '') { $item = array('menu_title' => $item[0], 'access_level' => $item[1], 'file' => $item[2], 'page_title' => isset($item[3]) ? $item[3] : '', 'position' => $pos); //Save the default parent menu $item['parent'] = $parent; //Flag plugin pages $item['is_plugin_page'] = get_plugin_page_hook($item['file'], $parent) != null; return array_merge($this->templates['basic_defaults'], $item); }
/** * Query if the menu subitem exists * * We probably want to use get_plugin_page_hook() * * @param string $menu_slug e.g. "oik_menu" * @param string $sub_item e.g. "oik_themes" * @return string|null the hookname it's registered */ function query_menu_subitem($menu_slug, $parent) { $hookname = get_plugin_page_hook($menu_slug, $parent); return $hookname; }
function wpjobads_add_admin_pages() { global $wpdb; global $plugin_page, $pagenow; $table_job = $wpdb->prefix . WPJOBADS_JOB; $unapproved = intval($wpdb->get_var("SELECT COUNT(id) AS unapproved FROM {$table_job} WHERE ad_approved = 0")); $submenu = array(); add_menu_page(__('WPJobAds for WordPress', 'wpjobads'), __('WPJobAds', 'wpjobads'), 10, __FILE__, 'wpjobads_admin_index'); $submenu['wpjobads_admin_load_jobs'] = add_submenu_page(__FILE__, __('WPJobAds Listings', 'wpjobads'), __('Jobs', 'wpjobads'), 10, 'wpjobads-admin-jobs', 'wpjobads_admin_jobs'); if ($unapproved or $_GET['page'] == 'wpjobads-admin-approvals' and isset($_GET['message'])) { $submenu['wpjobads_admin_load_approvals'] = add_submenu_page(__FILE__, __('WPJobAds Approvals', 'wpjobads'), sprintf(__('Awaiting Approval (%d)', 'wpjobads'), $unapproved), 10, 'wpjobads-admin-approvals', 'wpjobads_admin_approvals'); } $submenu['wpjobads_admin_load_categories'] = add_submenu_page(__FILE__, __('WPJobAds Categories', 'wpjobads'), __('Categories', 'wpjobads'), 10, 'wpjobads-admin-categories', 'wpjobads_admin_categories'); $submenu['wpjobads_admin_load_options'] = add_submenu_page(__FILE__, __('WPJobAds Options', 'wpjobads'), __('Options', 'wpjobads'), 10, 'wpjobads-admin-options', 'wpjobads_admin_options'); $submenu['wpjobads_admin_load_uninstall'] = add_submenu_page(__FILE__, __('WPJobAds Uninstall', 'wpjobads'), __('Uninstall', 'wpjobads'), 10, 'wpjobads-admin-uninstall', 'wpjobads_admin_uninstall'); foreach ($submenu as $handler => $page_hook) { if ($page_hook == get_plugin_page_hook($plugin_page, $pagenow)) { add_action('load-' . $page_hook, $handler); } } }
public function load_page($load_title = false) { global $plugin_page, $hook_suffix, $current_screen, $title, $menu, $submenu, $pagenow, $typenow; $pagenow = 'admin.php'; $typenow = ''; $this->init_load(); $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : ''; if ($page && wp_verify_nonce($_REQUEST['nonce'], 'mainwp_ajax')) { $plugin_page = stripslashes($page); $plugin_page = plugin_basename($plugin_page); if ($plugin_page) { $page_hook = get_plugin_page_hook($plugin_page, $pagenow); $hook_suffix = $page_hook; if ($load_title) { echo esc_html($this->get_title()); exit; } set_current_screen(); do_action('load-' . $page_hook); screen_meta($current_screen); // Back compatibility with 3.2 //$current_screen->render_screen_meta(); // For 3.3 do_action($page_hook); } } exit; }
function duoshuo_admin_initialize() { global $wp_version, $duoshuoPlugin, $plugin_page; //在admin界面内执行的action // wordpress2.8 以后都支持这个过滤器 add_filter('plugin_action_links_duoshuo/duoshuo.php', array($duoshuoPlugin, 'pluginActionLinks'), 10, 2); if (empty($duoshuoPlugin->shortName) || empty($duoshuoPlugin->secret)) { //你尚未安装这个插件。 function duoshuo_config_warning() { echo '<div class="updated"><p><strong>只要再<a href="' . admin_url('admin.php?page=duoshuo') . '">配置一下</a>多说帐号,多说就能开始为您服务了。</strong></p></div>'; } if ($plugin_page !== 'duoshuo') { add_action('admin_notices', 'duoshuo_config_warning'); } return; } add_action('admin_notices', array($duoshuoPlugin, 'notices')); add_action('switch_theme', array($duoshuoPlugin, 'updateSite')); // support from WP 2.9 //add_action('updated_option', array($duoshuoPlugin, 'updatedOption')); add_filter('post_row_actions', array($duoshuoPlugin, 'actionsFilter')); if (function_exists('get_post_types')) { // support from WP 2.9 $post_types = get_post_types(array('public' => true, 'show_in_nav_menus' => true), 'objects'); foreach ($post_types as $type => $object) { add_meta_box('duoshuo-sidebox', '同时发布到', array($duoshuoPlugin, 'syncOptions'), $type, 'side', 'high'); } } else { add_meta_box('duoshuo-sidebox', '同时发布到', array($duoshuoPlugin, 'syncOptions'), 'post', 'side', 'high'); add_meta_box('duoshuo-sidebox', '同时发布到', array($duoshuoPlugin, 'syncOptions'), 'page', 'side', 'high'); } //wp 3.0以下不支持此项功能 /** * TODO if ($post !== null && 'publish' == $post->post_status || 'private' == $post->post_status) add_meta_box('duoshuo-comments', '来自社交网站的评论(多说)', array($duoshuoPlugin,'managePostComments'), 'post', 'normal', 'low'); */ add_action('profile_update', array($duoshuoPlugin, 'syncUserToRemote')); add_action('user_register', array($duoshuoPlugin, 'syncUserToRemote')); add_action('wp_dashboard_setup', 'duoshuo_add_dashboard_widget'); //// backwards compatible (before WP 3.0) if (version_compare($wp_version, '3.0', '<') && current_user_can('administrator')) { function duoshuo_wp_version_notice() { echo '<div class="updated"><p>您的WordPress版本低于3.0,如果您能升级WordPress,多说就能更好地为您服务。</p></div>'; } add_action(get_plugin_page_hook('duoshuo', 'duoshuo'), 'duoshuo_wp_version_notice'); add_action(get_plugin_page_hook('duoshuo-preferences', 'duoshuo'), 'duoshuo_wp_version_notice'); add_action(get_plugin_page_hook('duoshuo-settings', 'duoshuo'), 'duoshuo_wp_version_notice'); } if (!is_numeric($duoshuoPlugin->getOption('synchronized')) && current_user_can('administrator')) { function duoshuo_unsynchronized_notice() { echo '<div class="updated"><p>上一次同步没有完成,<a href="' . admin_url('admin.php?page=duoshuo-settings') . '">点此继续同步</a></p></div>'; } add_action(get_plugin_page_hook('duoshuo', 'duoshuo'), 'duoshuo_unsynchronized_notice'); add_action(get_plugin_page_hook('duoshuo-preferences', 'duoshuo'), 'duoshuo_unsynchronized_notice'); add_action(get_plugin_page_hook('duoshuo-settings', 'duoshuo'), 'duoshuo_unsynchronized_notice'); } add_action('admin_head-edit-comments.php', array($duoshuoPlugin, 'originalCommentsNotice')); if (defined('DOING_AJAX')) { add_action('wp_ajax_duoshuo_export', array($duoshuoPlugin, 'export')); add_action('wp_ajax_duoshuo_sync_log', array($duoshuoPlugin, 'syncLogAction')); } duoshuo_common_initialize(); }
private static function is_hook_or_plugin_page($page_url, $parent_page_url = '') { if (empty($parent_page_url)) { $parent_page_url = 'admin.php'; } $pageFile = self::remove_query_from($page_url); /* * Special case: Absolute paths. * * - add_submenu_page() applies plugin_basename() to the menu slug, so we don't need to worry about plugin * paths. However, absolute paths that *don't* point point to the plugins directory can be a problem. * * - If we blindly append $pageFile to another path, we'll get something like "C:\a\b/wp-admin/C:\c\d.php". * PHP 5.2.5 has a known bug where calling file_exists() on that kind of an invalid filename will cause * a timeout and a crash in some configurations. See: https://bugs.php.net/bug.php?id=44412 * * - WP 3.9.2 and 4.0+ unintentionally break menu URLs like "foo.php?page=c:\a\b.php" because esc_url() * interprets the part before the colon as an invalid protocol. As a result, such links have an empty URL * on Windows (but they might still work on other OS). * * - Recent versions of WP won't let you load a PHP file from outside the plugins and mu-plugins directories * with "admin.php?page=filename". See the validate_file() call in /wp-admin/admin.php. However, such filenames * can still be used as unique slugs for menus with hook callbacks, so we shouldn't reject them outright. * Related: https://core.trac.wordpress.org/ticket/10011 */ $allowPathConcatenation = substr($pageFile, 1, 1) !== ':'; //Reject "C:\whatever" and similar. //Check our hard-coded list of admin pages first. It's measurably faster than //hitting the disk with is_file(). if (isset(self::$known_wp_admin_files[$pageFile])) { return false; } //Now actually check the filesystem. $adminFileExists = $allowPathConcatenation && is_file(ABSPATH . 'wp-admin/' . $pageFile); if ($adminFileExists) { return false; } $hasHook = get_plugin_page_hook($page_url, $parent_page_url) !== null; if ($hasHook) { return true; } //Note: We don't need to call plugin_basename() on $pageFile because add_submenu_page() already did that. $pluginFileExists = $allowPathConcatenation && $page_url != 'index.php' && is_file(WP_PLUGIN_DIR . '/' . $pageFile); if ($pluginFileExists) { return true; } return false; }
/** * Envato Updater HTML * * Creates the page used to verify themes for auto install/update * * @access private * @since 1.0 * @updated 1.4 * * @return string Returns the verification form & themes list */ public function _envato_menu_page() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.', 'envato')); } /* read in existing API value from database */ $options = get_option(EWPT_PLUGIN_SLUG); /* display environment errors */ if (!empty($options['env_errors'])) { foreach ($options['env_errors'] as $k => $v) { if (empty($options['dismissed_errors'][$k])) { echo '<div class="error">' . $v . '</div>'; } } } $user_name = isset($options['user_name']) ? $options['user_name'] : ''; $api_key = isset($options['api_key']) ? $options['api_key'] : ''; $this->protected_api = new Envato_Protected_API($user_name, $api_key); /* get purchased marketplace themes */ $themes = $this->protected_api->wp_list_themes(); /* display API errors */ if ($errors = $this->protected_api->api_errors()) { foreach ($errors as $k => $v) { if ($k !== 'http_code' && ($user_name || $api_key)) { echo '<div class="error"><p>' . $v . '</p></div>'; } } } /* display update messages */ if (empty($errors)) { echo isset($_GET['settings-updated']) ? '<div class="updated below-h2"><p><strong>' . __('User Settings Updated.', 'envato') . '</strong></p></div>' : ''; echo isset($_GET['activated']) ? '<div class="updated below-h2"><p><strong>' . __('Theme Activated.', 'envato') . '</strong></p></div>' : ''; echo isset($_GET['deleted']) ? '<div class="updated below-h2"><p><strong>' . __('Theme Deleted.', 'envato') . '</strong></p></div>' : ''; } /* execute theme actions */ if (isset($_GET['action']) && isset($_GET['theme'])) { if ('install-theme' == $_GET['action'] && is_array($themes)) { $this->_install_theme($_GET['theme'], $themes); } else { if ('upgrade-theme' == $_GET['action'] && isset($_GET['item_id'])) { $this->_upgrade_theme($_GET['theme'], $_GET['item_id']); } } /* display normal views */ } else { echo '<div class="wrap">'; echo '<div id="icon-themes" class="icon32"></div><h2>' . EWPT_PLUGIN_NAME . '</h2>'; echo ' <form name="verification_form" method="post" action="' . admin_url('options.php') . '" id="api-verification">'; wp_nonce_field('update-options'); settings_fields(EWPT_PLUGIN_SLUG); do_settings_sections(EWPT_PLUGIN_SLUG); echo ' <p class="submit"> <input type="submit" name="Submit" class="button-primary right" value="' . __('Save Settings', 'envato') . '" /> </p> </form>'; /* no errors & themes are available */ if (empty($errors) && count($themes) > 0) { /* get WP installed themes */ if (function_exists('wp_get_themes')) { $get_themes = wp_get_themes(); } else { $get_themes = get_themes(); } /* loop through the marketplace themes */ $premium_themes = array(); foreach ($themes as $theme) { /* setup the defaults */ $content = ''; $installed = false; $links = array(); $current_stylesheet = get_stylesheet(); $latest_version = $theme->version; $item_id = $theme->item_id; $template = ''; $stylesheet = ''; $title = $theme->theme_name; $version = ''; $description = $theme->description; $author = $theme->author_name; $parent_theme = ''; $tags = ''; /* setup the item details */ $item_details = $this->protected_api->item_details($item_id); if (!empty($item_details)) { /* get installed theme information */ foreach ($get_themes as $k => $v) { if ($get_themes[$k]['Title'] == $title && $get_themes[$k]['Author Name'] == $author && $template == '') { $template = $get_themes[$k]['Template']; $stylesheet = $get_themes[$k]['Stylesheet']; $title = $get_themes[$k]['Title']; $version = $get_themes[$k]['Version']; $description = $get_themes[$k]['Description']; $author = $get_themes[$k]['Author']; $screenshot = $get_themes[$k]['Screenshot']; $stylesheet_dir = $get_themes[$k]['Stylesheet Dir']; $template_dir = $get_themes[$k]['Template Dir']; $parent_theme = $get_themes[$k]['Parent Theme']; $theme_root = $get_themes[$k]['Theme Root']; $theme_root_uri = $get_themes[$k]['Theme Root URI']; $tags = $get_themes[$k]['Tags']; $installed = true; continue; } } $has_update = $installed && version_compare($version, $latest_version, '<') ? TRUE : FALSE; $details_url = htmlspecialchars(add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $item_details->url)); $activate_url = wp_nonce_url(network_admin_url('admin.php?page=' . EWPT_PLUGIN_SLUG . '&action=activate&template=' . urlencode($template) . '&stylesheet=' . urlencode($stylesheet)), 'switch-theme_' . $template); $preview_url = htmlspecialchars(add_query_arg(array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1, 'TB_iframe' => 'true'), trailingslashit(esc_url(get_option('home'))))); $delete_url = wp_nonce_url(network_admin_url('admin.php?page=' . EWPT_PLUGIN_SLUG . '&action=delete&template=' . $stylesheet), 'delete-theme_' . $stylesheet); $delete_onclick = 'onclick="if ( confirm(\'' . esc_js(sprintf(__("You're about to delete the '%s' theme. 'Cancel' to stop, 'OK' to update.", 'envato'), $title)) . '\') ) {return true;}return false;"'; $install_url = wp_nonce_url(network_admin_url('admin.php?page=' . EWPT_PLUGIN_SLUG . '&action=install-theme&theme=' . $item_id), 'install-theme_' . $item_id); $update_url = wp_nonce_url(network_admin_url('admin.php?page=' . EWPT_PLUGIN_SLUG . '&action=upgrade-theme&theme=' . $stylesheet . '&item_id=' . $item_id), 'upgrade-theme_' . $stylesheet); $update_onclick = 'onclick="if ( confirm(\'' . esc_js(__("Updating this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to update.", 'envato')) . '\') ) {return true;}return false;"'; /* Theme Title message */ $content .= '<h3>' . $title . ' ' . $version . ' by ' . $author . '</h3>'; /* Theme Description */ if ($description) { $content .= '<p class="description">' . $description . '</p>'; } /* Theme Backup URI */ $theme_backup_uri = $this->_get_theme_backup_uri($template); /* Links list */ if ($stylesheet && $template && $current_stylesheet !== $stylesheet) { $links[] = '<a href="' . $activate_url . '" class="activatelink" title="' . esc_attr(sprintf(__('Activate “%s”', 'envato'), $title)) . '">' . __('Activate', 'envato') . '</a>'; $links[] = '<a href="' . $preview_url . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview “%s”', 'envato'), $title)) . '">' . __('Preview', 'envato') . '</a>'; $links[] = '<a href="' . $delete_url . '" class="submitdelete deletion" title="' . esc_attr(sprintf(__('Delete “%s”', 'envato'), $title)) . '" ' . $delete_onclick . '>' . __('Delete') . '</a>'; $links[] = '<a href="' . $details_url . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('View version %1$s details', 'envato'), $latest_version)) . '">' . esc_attr(sprintf(__('View version %1$s details', 'envato'), $latest_version)) . '</a>'; if (!empty($theme_backup_uri)) { $links[] = '<a href="' . $theme_backup_uri . '" title="' . esc_attr(__('Download Backup', 'envato')) . '">' . esc_attr(__('Download Backup', 'envato')) . '</a>'; } $content .= '<div class="update-info">' . implode(' | ', $links) . '</div>'; } /** * This ugly code lists the current theme options * It was pulled from wp-admin/themes.php with minor tweaks */ if ($current_stylesheet == $stylesheet) { global $submenu; $parent_file = 'themes.php'; $options = array(); if (is_array($submenu) && isset($submenu['themes.php'])) { foreach ((array) $submenu['themes.php'] as $item) { if ('themes.php' == $item[2] || 'theme-editor.php' == $item[2]) { continue; } if (!empty($submenu[$item[2]])) { $submenu[$item[2]] = array_values($submenu[$item[2]]); $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); if (file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) { $options[] = "<a href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; } else { $options[] = "<a href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; } } else { if (current_user_can($item[1])) { if (file_exists(ABSPATH . 'wp-admin/' . $item[2])) { $options[] = "<a href='{$item[2]}'>{$item[0]}</a>"; } else { $options[] = "<a href='themes.php?page={$item[2]}'>{$item[0]}</a>"; } } } } } if (!empty($theme_backup_uri)) { $options[] = '<a href="' . $theme_backup_uri . '" title="' . esc_attr(__('Download Backup', 'envato')) . '">' . esc_attr(__('Download Backup', 'envato')) . '</a>'; } if (!empty($options)) { $content .= '<div class="update-info"><span>' . __('Options:', 'envato') . '</span> ' . implode(' | ', $options) . '</div>'; } } /* Theme path information */ if (current_user_can('edit_themes') && $installed) { if ($parent_theme) { $content .= '<p>' . sprintf(__('The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>. <strong>%4$s</strong> uses templates from <strong>%5$s</strong>. Changes made to the templates will affect both themes.', 'envato'), $title, str_replace(WP_CONTENT_DIR, '', $template_dir), str_replace(WP_CONTENT_DIR, '', $stylesheet_dir), $title, $parent_theme) . '</p>'; } else { $content .= '<p>' . sprintf(__('All of this theme’s files are located in <code>%2$s</code>.', 'envato'), $title, str_replace(WP_CONTENT_DIR, '', $template_dir), str_replace(WP_CONTENT_DIR, '', $stylesheet_dir)) . '</p>'; } } /* Tags list */ if ($tags) { $content .= '<p>' . __('Tags: ') . join(', ', $tags) . '</p>'; } /* Upgrade/Install message */ if ($has_update) { if (!current_user_can('update_themes')) { $content .= sprintf('<div class="updated below-h2"><p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox thickbox-preview" title="%1$s">View version %3$s details</a>.', 'envato') . '</strong></p></div>', $title, $details_url, $latest_version); } else { $content .= sprintf('<div class="updated below-h2"><p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox thickbox-preview" title="%1$s">View version %3$s details</a> or <a href="%4$s" %5$s>update automatically</a>.', 'envato') . '</strong></p></div>', $title, $details_url, $latest_version, $update_url, $update_onclick); } } else { if (!$installed) { if (!current_user_can('update_themes')) { $content .= sprintf('<div class="updated below-h2"><p><strong>' . __('%1$s has not been installed. <a href="%2$s" class="thickbox thickbox-preview" title="%1$s">View version %3$s details</a>.', 'envato') . '</strong></p></div>', $title, $details_url, $latest_version); } else { $content .= sprintf('<div class="updated below-h2"><p><strong>' . __('%1$s has not been installed. <a href="%2$s" class="thickbox thickbox-preview" title="%1$s">View version %3$s details</a> or <a href="%4$s">install automatically</a>.', 'envato') . '</strong></p></div>', $title, $details_url, $latest_version, $install_url); } } } /* put the HTML into a variable */ $list_item = ' <li> <div class="thumbnail"> <img src="' . $item_details->thumbnail . '" alt="' . $title . '" /> </div> <div class="item-details"> ' . $content . ' </div> </li>'; $premium_themes[] = array('current_theme' => $current_stylesheet == $stylesheet ? true : false, 'list_item' => $list_item); } } /** * Loop through all the premium themes. * Separate out the current one, display it, & remove from array * Display the other premium themes after edits to the array. */ if (!empty($premium_themes)) { $current_theme = array(); foreach ($premium_themes as $k => $v) { if ($premium_themes[$k]['current_theme'] == true) { $current_theme = $premium_themes[$k]; unset($premium_themes[$k]); } } /* list current premium theme */ if (!empty($current_theme)) { _e('<h3>Current Theme</h3>'); echo '<ul class="ewpu-item-list">'; echo $current_theme['list_item']; echo '</ul>'; } /* list premium themes */ _e('<h3>Available Themes</h3>'); echo '<ul class="ewpu-item-list">'; foreach ($premium_themes as $k => $v) { echo $premium_themes[$k]['list_item']; } echo '</ul>'; } } echo '</div>'; } }
/** * Alternative to get_current_screen() * @link http://wordpress.stackexchange.com/a/174596/22728 * * @param string $base * @param string $post_type * @return bool */ function theme_is_current_screen($base = null, $post_type = null) { if (!$base && !$post_type) { return false; } $screen = function_exists('get_current_screen') ? get_current_screen() : null; if (!$screen) { // Fake it. $screen = new StdClass(); $screen->post_type = $screen->base = ''; global $pagenow; if ($pagenow == 'admin-ajax.php') { if (isset($_REQUEST['action'])) { $screen->base = $_REQUEST['action']; } } else { $screen->post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : ''; if ($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') { $screen->base = preg_replace('/[^a-z].+$/', '', $pagenow); if (!$screen->post_type) { $screen->post_type = get_post_type(theme_get_post_id()); } } else { $page_hook = ''; global $plugin_page; if (!empty($plugin_page)) { if ($screen->post_type) { $the_parent = $pagenow . '?post_type=' . $screen->post_type; } else { $the_parent = $pagenow; } if (!($page_hook = get_plugin_page_hook($plugin_page, $the_parent))) { $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); } } $screen->base = $page_hook ? $page_hook : pathinfo($pagenow, PATHINFO_FILENAME); } } } // The base type of the screen. This is typically the same as $id but with any post types and taxonomies stripped. if ($base) { if (!is_array($base)) { $base = array($base); } if (!in_array($screen->base, $base)) { return false; } } if ($post_type) { if (!is_array($post_type)) { $post_type = array($post_type); } if (!in_array($screen->post_type, $post_type)) { return false; } } return true; }
/** * Display menu. * * @access private * @since 2.7.0 * * @param array $menu * @param array $submenu * @param bool $submenu_as_parent */ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow; $first = true; // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src foreach ( $menu as $key => $item ) { $admin_is_parent = false; $class = array(); if ( $first ) { $class[] = 'wp-first-item'; $first = false; } if ( !empty($submenu[$item[2]]) ) $class[] = 'wp-has-submenu'; if ( ( $parent_file && $item[2] == $parent_file ) || ( false === strpos($parent_file, '?') && $self == $item[2] ) ) { if ( !empty($submenu[$item[2]]) ) $class[] = 'wp-has-current-submenu wp-menu-open'; else $class[] = 'current'; } if ( ! empty($item[4]) ) $class[] = $item[4]; $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; $tabindex = ' tabindex="1"'; $id = ! empty($item[5]) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : ''; $img = ''; if ( ! empty($item[6]) ) { if ( 'div' === $item[6] ) $img = '<br />'; else $img = '<img src="' . $item[6] . '" alt="" />'; } $toggle = '<div class="wp-menu-toggle"><br /></div>'; $title = wptexturize($item[0]); echo "\n\t<li$class$id>"; if ( false !== strpos($class, 'wp-menu-separator') ) { echo '<a class="separator" href="?unfoldmenu=1"><br /></a>'; } elseif ( $submenu_as_parent && !empty($submenu[$item[2]]) ) { $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); $menu_file = $submenu[$item[2]][0][2]; if ( false !== $pos = strpos($menu_file, '?') ) $menu_file = substr($menu_file, 0, $pos); if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") ) || !empty($menu_hook)) { $admin_is_parent = true; echo "<div class='wp-menu-image'><a href='admin.php?page={$submenu[$item[2]][0][2]}'>$img</a></div>$toggle<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class$tabindex>$title</a>"; } else { echo "\n\t<div class='wp-menu-image'><a href='{$submenu[$item[2]][0][2]}'>$img</a></div>$toggle<a href='{$submenu[$item[2]][0][2]}'$class$tabindex>$title</a>"; } } else if ( current_user_can($item[1]) ) { $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); $menu_file = $item[2]; if ( false !== $pos = strpos($menu_file, '?') ) $menu_file = substr($menu_file, 0, $pos); if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") || !empty($menu_hook) ) { $admin_is_parent = true; echo "\n\t<div class='wp-menu-image'><a href='admin.php?page={$item[2]}'>$img</a></div>$toggle<a href='admin.php?page={$item[2]}'$class$tabindex>{$item[0]}</a>"; } else { echo "\n\t<div class='wp-menu-image'><a href='{$item[2]}'>$img</a></div>$toggle<a href='{$item[2]}'$class$tabindex>{$item[0]}</a>"; } } if ( !empty($submenu[$item[2]]) ) { echo "\n\t<div class='wp-submenu'><div class='wp-submenu-head'>{$item[0]}</div><ul>"; $first = true; foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) { if ( !current_user_can($sub_item[1]) ) continue; $class = array(); if ( $first ) { $class[] = 'wp-first-item'; $first = false; } $menu_file = $item[2]; if ( false !== $pos = strpos($menu_file, '?') ) $menu_file = substr($menu_file, 0, $pos); // Handle current for post_type=post|page|foo pages, which won't match $self. if ( !empty($typenow) ) $self_type = $self . '?post_type=' . $typenow; else $self_type = 'nothing'; if ( isset($submenu_file) ) { if ( $submenu_file == $sub_item[2] ) $class[] = 'current'; // If plugin_page is set the parent must either match the current page or not physically exist. // This allows plugin pages with the same hook to exist under different parents. } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($menu_file) || ($item[2] == $self) || ($item[2] == $self_type))) || (!isset($plugin_page) && $self == $sub_item[2]) ) { $class[] = 'current'; } $class = $class ? ' class="' . join( ' ', $class ) . '"' : ''; $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); $sub_file = $sub_item[2]; if ( false !== $pos = strpos($sub_file, '?') ) $sub_file = substr($sub_file, 0, $pos); $title = wptexturize($sub_item[0]); if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) { // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir if ( (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}")) || file_exists($menu_file) ) $sub_item_url = add_query_arg( array('page' => $sub_item[2]), $item[2] ); else $sub_item_url = add_query_arg( array('page' => $sub_item[2]), 'admin.php' ); $sub_item_url = esc_url($sub_item_url); echo "<li$class><a href='$sub_item_url'$class$tabindex>$title</a></li>"; } else { echo "<li$class><a href='{$sub_item[2]}'$class$tabindex>$title</a></li>"; } } echo "</ul></div>"; } echo "</li>"; } }
function json_oauth_admin_prerender() { $hook = get_plugin_page_hook('json-oauth', 'users.php'); add_action('load-' . $hook, 'json_oauth_admin_load'); }
continue; } if (isset($submenu_file)) { if ($submenu_file == $item[2]) { $class = ' class="current"'; } else { $class = ''; } } else { if (isset($plugin_page) && $plugin_page == $item[2] || !isset($plugin_page) && $self == $item[2]) { $class = ' class="current"'; } else { $class = ''; } } $menu_hook = get_plugin_page_hook($item[2], $parent_file); if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") || !empty($menu_hook)) { if ('admin.php' == $pagenow) { echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'{$class}>{$item[0]}</a></li>"; } else { echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$parent_file}?page={$item[2]}'{$class}>{$item[0]}</a></li>"; } } else { echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'{$class}>{$item[0]}</a></li>"; } } ?> </ul> <?php }
private static function is_hook_or_plugin_page($page_url, $parent_page_url = '') { if (empty($parent_page_url)) { $parent_page_url = 'admin.php'; } $pageFile = self::remove_query_from($page_url); //Check our hard-coded list of admin pages first. It's measurably faster than //hitting the disk with is_file(). if (isset(self::$known_wp_admin_files[$pageFile])) { return false; } //Now actually check the filesystem. $adminFileExists = is_file(ABSPATH . '/wp-admin/' . $pageFile); if ($adminFileExists) { return false; } $hasHook = get_plugin_page_hook($page_url, $parent_page_url) !== null; if ($hasHook) { return true; } $pluginFileExists = $page_url != 'index.php' && is_file(WP_PLUGIN_DIR . '/' . $pageFile); if ($pluginFileExists) { return true; } return false; }
function wp_ozh_adminmenu() { global $menu, $submenu, $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $wp_ozh_adminmenu; // echo "<pre>";print_r($menu);print_r($submenu);echo "</pre>"; // Plugins: hack $menu & $submenu before I butcher them $menu = apply_filters('pre_ozh_adminmenu_menu', $menu); $submenu = apply_filters('pre_ozh_adminmenu_submenu', $submenu); $ozh_menu = '<div id="ozhmenu_wrap"><ul id="ozhmenu">'; // Plugins: hack $ozh_menu before I start adding stuff to it $ozh_menu = apply_filters('pre_ozh_adminmenu_ozh_menu', $ozh_menu); if ($wp_ozh_adminmenu['minimode']) { $ozh_menu .= '<li id="oam_bloglink" class="ozhmenu_toplevel">' . wp_ozh_adminmenu_blogtitle() . '</li>'; } $first = true; // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src foreach ($_menu = $menu as $key => $item) { // Top level menu if (strpos($item[4], 'wp-menu-separator') !== false) { continue; } $admin_is_parent = false; $class = array(); if ($first) { $class[] = 'wp-first-item'; $first = false; } if (!empty($submenu[$item[2]])) { $class[] = 'wp-has-submenu'; } if ($parent_file && $item[2] == $parent_file || strcmp($self, $item[2]) == 0) { if (!empty($submenu[$item[2]])) { $class[] = 'wp-has-current-submenu current wp-menu-open'; } else { $class[] = 'current'; } } if (isset($item[4]) && !empty($item[4])) { $class[] = $item[4]; } $class = $class ? ' class="' . join(' ', $class) . '"' : ''; $id = isset($item[5]) && !empty($item[5]) ? 'oam_' . $item[5] : ''; $anchor = $item[0]; if ($wp_ozh_adminmenu['compact']) { $compactstyle = 'inline'; $fullstyle = 'none'; } else { $compactstyle = 'none'; $fullstyle = 'inline'; } if (isset($submenu_as_parent) && !empty($submenu[$item[2]])) { $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); if ('index.php' != $submenu[$item[2]][0][2] && file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) { $admin_is_parent = true; $href = "admin.php?page={$submenu[$item[2]][0][2]}"; } else { $href = $submenu[$item[2]][0][2]; } } else { if (current_user_can($item[1])) { $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); if ('index.php' != $item[2] && file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook)) { $admin_is_parent = true; $href = "admin.php?page={$item[2]}"; } else { $href = $item[2]; } } } $imgstyle = $wp_ozh_adminmenu['wpicons'] ? '' : 'style="display:none"'; $img = ''; if (isset($item[6]) && !empty($item[6])) { preg_match('/^dashicons/', $item[6], $matches); if ('none' === $item[6] || 'div' === $item[6]) { $img = '<div ' . $imgstyle . ' class="wp-menu-image"><br /></div>'; } elseif (!empty($matches)) { $img = '<div ' . $imgstyle . ' class="wp-menu-image dashicons-before ' . $item[6] . '"><br /></div>'; } else { $img = '<img ' . $imgstyle . ' class="wp-menu-image" src="' . $item[6] . '" alt="" />'; } } if ($wp_ozh_adminmenu['toplinks']) { $href = "href='{$href}'"; } else { $href = !empty($submenu[$item[2]]) ? '' : "href='{$href}'"; } $ozh_menu .= "\t<li class='ozhmenu_toplevel' id='{$id}'><a {$href} {$class}>{$img}<span class='compact' style='display:{$compactstyle}'> </span><span class='full' style='display:{$fullstyle}'>{$anchor}</span></a>"; // Sub level menus if (!empty($submenu[$item[2]])) { if (!isset($ulclass)) { $ulclass = ''; } $ozh_menu .= "\n\t\t<ul{$ulclass}><li class='toplevel_label'>{$anchor}</li>\n"; $first = true; foreach ($submenu[$item[2]] as $sub_key => $sub_item) { if (!current_user_can($sub_item[1])) { continue; } $class = array(); if ($first) { $class[] = 'wp-first-item'; $first = false; } if (isset($submenu_file)) { if ($submenu_file == $sub_item[2]) { $class[] = 'current'; } // If plugin_page is set the parent must either match the current page or not physically exist. // This allows plugin pages with the same hook to exist under different parents. } else { if (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($item[2]) || $item[2] == $self) || !isset($plugin_page) && $self == $sub_item[2]) { $class[] = 'current'; } } $subclass = $class ? ' class="' . join(' ', $class) . '"' : ''; $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); if ('index.php' != $sub_item[2] && file_exists(WP_PLUGIN_DIR . "/{$sub_item[2]}") || !empty($menu_hook)) { // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir $parent_exists = !$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/{$item[2]}") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") || file_exists($item[2]); if ($parent_exists) { $suburl = "{$item[2]}?page={$sub_item[2]}"; } elseif ('admin.php' == $pagenow || !$parent_exists) { $suburl = "admin.php?page={$sub_item[2]}"; } else { $suburl = "{$item[2]}?page={$sub_item[2]}"; } // Get icons? if ($wp_ozh_adminmenu['icons']) { $plugin_icon = apply_filters('ozh_adminmenu_icon', $sub_item[2]); $plugin_icon = apply_filters('ozh_adminmenu_icon_' . $sub_item[2], $sub_item[2]); if ($plugin_icon != $sub_item[2]) { // we have an icon: no default plugin class & we store the icon location $plugin_icons[wp_ozh_adminmenu_sanitize_id($sub_item[2])] = $plugin_icon; $icon = ''; } else { // no icon: default plugin class $icon = 'oam_plugin'; } } } else { $suburl = $sub_item[2]; } // Custom logout menu? if ($sub_item[2] == 'ozh_admin_menu_logout') { $suburl = wp_logout_url(); } $subid = 'oamsub_' . wp_ozh_adminmenu_sanitize_id($sub_item[2]); $subanchor = strip_tags($sub_item[0]); if (!isset($icon)) { $icon = ''; } $ozh_menu .= "\t\t\t<li class='ozhmenu_sublevel {$icon}' id='{$subid}'><a href='{$suburl}'{$subclass}>{$subanchor}</a></li>\n"; } $ozh_menu .= "</ul>"; } $ozh_menu .= "</li>"; } $ozh_menu .= "</ul></div>"; // Plugins: hack $ozh_menu now it's complete $ozh_menu = apply_filters('post_ozh_adminmenu_ozh_menu', $ozh_menu); if (isset($plugin_icons)) { global $text_direction; $align = $text_direction == 'rtl' ? 'right' : 'left'; echo "\n" . '<style type="text/css">' . "\n"; foreach ($plugin_icons as $hook => $icon) { $hook = plugin_basename($hook); //echo "#oamsub_$hook a {background-image:url($icon);}\n"; echo "#oamsub_{$hook} a {background:url({$icon}) center {$align} no-repeat;}\n"; } echo "</style>\n"; } echo $ozh_menu; }
function get_admin_page_title() { global $title; global $menu; global $submenu; global $pagenow; global $plugin_page; if (isset($title) && !empty($title)) { return $title; } $hook = get_plugin_page_hook($plugin_page, $pagenow); $parent = $parent1 = get_admin_page_parent(); if (empty($parent)) { foreach ($menu as $menu_array) { if (isset($menu_array[3])) { if ($menu_array[2] == $pagenow) { $title = $menu_array[3]; return $menu_array[3]; } else { if (isset($plugin_page) && $plugin_page == $menu_array[2] && $hook == $menu_array[3]) { $title = $menu_array[3]; return $menu_array[3]; } } } } } else { foreach (array_keys($submenu) as $parent) { foreach ($submenu[$parent] as $submenu_array) { if (isset($submenu_array[3])) { if ($submenu_array[2] == $pagenow) { $title = $submenu_array[3]; return $submenu_array[3]; } else { if (isset($plugin_page) && $plugin_page == $submenu_array[2] && ($parent == $pagenow || $parent == $plugin_page || $plugin_page == $hook || $pagenow == 'admin.php' && $parent1 != $submenu_array[2])) { $title = $submenu_array[3]; return $submenu_array[3]; } } } } } } return ''; }
private static function is_hook_or_plugin_page($page_url, $parent_page_url = '') { if (empty($parent_page_url)) { $parent_page_url = 'admin.php'; } $pageFile = self::remove_query_from($page_url); $hasHook = get_plugin_page_hook($page_url, $parent_page_url) !== null; $adminFileExists = is_file(ABSPATH . '/wp-admin/' . $pageFile); $pluginFileExists = $page_url != 'index.php' && is_file(WP_PLUGIN_DIR . '/' . $pageFile); return !$adminFileExists && ($hasHook || $pluginFileExists); }
* * This is roughly analogous to the more general 'init' hook, which fires earlier. * * @since 2.5.0 */ do_action('admin_init'); if (isset($plugin_page)) { if (!empty($typenow)) { $the_parent = $pagenow . '?post_type=' . $typenow; } else { $the_parent = $pagenow; } if (!($page_hook = get_plugin_page_hook($plugin_page, $the_parent))) { $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); // Backwards compatibility for plugins using add_management_page(). if (empty($page_hook) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php')) { // There could be plugin specific params on the URL, so we need the whole query string if (!empty($_SERVER['QUERY_STRING'])) { $query_string = $_SERVER['QUERY_STRING']; } else { $query_string = 'page=' . $plugin_page; } wp_redirect(admin_url('tools.php?' . $query_string)); exit; } } unset($the_parent); } $hook_suffix = ''; if (isset($page_hook)) { $hook_suffix = $page_hook;
/** * Display menu. * * @access private * @since 2.7.0 * * @param array $menu * @param array $submenu * @param bool $submenu_as_parent */ function _nxt_menu_output($menu, $submenu, $submenu_as_parent = true) { global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow; $first = true; // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src foreach ($menu as $key => $item) { $admin_is_parent = false; $class = array(); $aria_attributes = 'tabindex="1"'; if ($first) { $class[] = 'nxt-first-item'; $first = false; } $submenu_items = false; if (!empty($submenu[$item[2]])) { $class[] = 'nxt-has-submenu'; $submenu_items = $submenu[$item[2]]; } if ($parent_file && $item[2] == $parent_file || empty($typenow) && $self == $item[2]) { $class[] = !empty($submenu_items) ? 'nxt-has-current-submenu nxt-menu-open' : 'current'; } else { $class[] = 'nxt-not-current-submenu'; if (!empty($submenu_items)) { $aria_attributes .= ' aria-haspopup="true"'; } } if (!empty($item[4])) { $class[] = $item[4]; } $class = $class ? ' class="' . join(' ', $class) . '"' : ''; $id = !empty($item[5]) ? ' id="' . preg_replace('|[^a-zA-Z0-9_:.]|', '-', $item[5]) . '"' : ''; $img = ''; if (!empty($item[6])) { $img = 'div' === $item[6] ? '<br />' : '<img src="' . $item[6] . '" alt="" />'; } $arrow = '<div class="nxt-menu-arrow"><div></div></div>'; $title = nxttexturize($item[0]); echo "\n\t<li{$class}{$id}>"; if (false !== strpos($class, 'nxt-menu-separator')) { echo '<div class="separator"></div>'; } elseif ($submenu_as_parent && !empty($submenu_items)) { $submenu_items = array_values($submenu_items); // Re-index. $menu_hook = get_plugin_page_hook($submenu_items[0][2], $item[2]); $menu_file = $submenu_items[0][2]; if (false !== ($pos = strpos($menu_file, '?'))) { $menu_file = substr($menu_file, 0, $pos); } if (!empty($menu_hook) || 'index.php' != $submenu_items[0][2] && file_exists(nxt_PLUGIN_DIR . "/{$menu_file}")) { $admin_is_parent = true; echo "<div class='nxt-menu-image'><a href='admin.php?page={$submenu_items[0][2]}'>{$img}</a></div>{$arrow}<a href='admin.php?page={$submenu_items[0][2]}'{$class} {$aria_attributes}>{$title}</a>"; } else { echo "\n\t<div class='nxt-menu-image'><a href='{$submenu_items[0][2]}'>{$img}</a></div>{$arrow}<a href='{$submenu_items[0][2]}'{$class} {$aria_attributes}>{$title}</a>"; } } elseif (!empty($item[2]) && current_user_can($item[1])) { $menu_hook = get_plugin_page_hook($item[2], 'admin.php'); $menu_file = $item[2]; if (false !== ($pos = strpos($menu_file, '?'))) { $menu_file = substr($menu_file, 0, $pos); } if (!empty($menu_hook) || 'index.php' != $item[2] && file_exists(nxt_PLUGIN_DIR . "/{$menu_file}")) { $admin_is_parent = true; echo "\n\t<div class='nxt-menu-image'><a href='admin.php?page={$item[2]}'>{$img}</a></div>{$arrow}<a href='admin.php?page={$item[2]}'{$class} {$aria_attributes}>{$item[0]}</a>"; } else { echo "\n\t<div class='nxt-menu-image'><a href='{$item[2]}'>{$img}</a></div>{$arrow}<a href='{$item[2]}'{$class} {$aria_attributes}>{$item[0]}</a>"; } } if (!empty($submenu_items)) { echo "\n\t<div class='nxt-submenu'><div class='nxt-submenu-wrap'>"; echo "<div class='nxt-submenu-head'>{$item[0]}</div><ul>"; $first = true; foreach ($submenu_items as $sub_key => $sub_item) { if (!current_user_can($sub_item[1])) { continue; } $aria_attributes = 'tabindex="1"'; $class = array(); if ($first) { $class[] = 'nxt-first-item'; $first = false; } $menu_file = $item[2]; if (false !== ($pos = strpos($menu_file, '?'))) { $menu_file = substr($menu_file, 0, $pos); } // Handle current for post_type=post|page|foo pages, which won't match $self. $self_type = !empty($typenow) ? $self . '?post_type=' . $typenow : 'nothing'; if (isset($submenu_file)) { if ($submenu_file == $sub_item[2]) { $class[] = 'current'; } // If plugin_page is set the parent must either match the current page or not physically exist. // This allows plugin pages with the same hook to exist under different parents. } else { if (!isset($plugin_page) && $self == $sub_item[2] || isset($plugin_page) && $plugin_page == $sub_item[2] && ($item[2] == $self_type || $item[2] == $self || file_exists($menu_file) === false)) { $class[] = 'current'; } } $class = $class ? ' class="' . join(' ', $class) . '"' : ''; $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]); $sub_file = $sub_item[2]; if (false !== ($pos = strpos($sub_file, '?'))) { $sub_file = substr($sub_file, 0, $pos); } $title = nxttexturize($sub_item[0]); if (!empty($menu_hook) || 'index.php' != $sub_item[2] && file_exists(nxt_PLUGIN_DIR . "/{$sub_file}")) { // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir if (!$admin_is_parent && file_exists(nxt_PLUGIN_DIR . "/{$menu_file}") && !is_dir(nxt_PLUGIN_DIR . "/{$item[2]}") || file_exists($menu_file)) { $sub_item_url = add_query_arg(array('page' => $sub_item[2]), $item[2]); } else { $sub_item_url = add_query_arg(array('page' => $sub_item[2]), 'admin.php'); } $sub_item_url = esc_url($sub_item_url); echo "<li{$class}><a href='{$sub_item_url}'{$class} {$aria_attributes}>{$title}</a></li>"; } else { echo "<li{$class}><a href='{$sub_item[2]}'{$class} {$aria_attributes}>{$title}</a></li>"; } } echo "</ul></div></div>"; } echo "</li>"; } echo '<li id="collapse-menu" class="hide-if-no-js"><div id="collapse-button"><div></div></div>'; echo '<span>' . esc_html__('Collapse menu') . '</span>'; echo '</li>'; }
function get_admin_page_title() { global $title; global $menu; global $submenu; global $pagenow; global $plugin_page; global $typenow; if (!empty($title)) { return $title; } $hook = get_plugin_page_hook($plugin_page, $pagenow); $parent = $parent1 = get_admin_page_parent(); if (empty($parent)) { foreach ((array) $menu as $menu_array) { if (isset($menu_array[3])) { if ($menu_array[2] == $pagenow) { $title = $menu_array[3]; return $menu_array[3]; } else { if (isset($plugin_page) && $plugin_page == $menu_array[2] && $hook == $menu_array[3]) { $title = $menu_array[3]; return $menu_array[3]; } } } else { $title = $menu_array[0]; return $title; } } } else { foreach (array_keys($submenu) as $parent) { foreach ($submenu[$parent] as $submenu_array) { if (isset($plugin_page) && $plugin_page == $submenu_array[2] && ($parent == $pagenow || $parent == $plugin_page || $plugin_page == $hook || $pagenow == 'admin.php' && $parent1 != $submenu_array[2] || !empty($typenow) && $parent == $pagenow . '?post_type=' . $typenow)) { $title = $submenu_array[3]; return $submenu_array[3]; } if ($submenu_array[2] != $pagenow || isset($_GET['page'])) { // not the current page continue; } if (isset($submenu_array[3])) { $title = $submenu_array[3]; return $submenu_array[3]; } else { $title = $submenu_array[0]; return $title; } } } if (empty($title)) { foreach ($menu as $menu_array) { if (isset($plugin_page) && $plugin_page == $menu_array[2] && $pagenow == 'admin.php' && $parent1 == $menu_array[2]) { $title = $menu_array[3]; return $menu_array[3]; } } } } return $title; }
function gantry_add_meta_buttons() { add_meta_button('meta-preset-link', 'Presets', '#contextual-preset', array(get_plugin_page_hook('gantry-theme-settings', ''), get_plugin_page_hook('gantry-theme-overrides', 'gantry-theme-settings'))); $options = get_option(get_template() . "-template-options"); if ($options['cache']['enabled']) { add_meta_button('cache-clear', 'Clear Cache', '?clear-cache', array(get_plugin_page_hook('gantry-theme-settings', ''), get_plugin_page_hook('gantry-theme-overrides', 'gantry-theme-settings')), array('class' => 'clear-cache')); } }