private function actionHookIsValid($menuSlug, $parentSlug)
 {
     $menuSlug = plugin_basename($menuSlug);
     $parentSlug = plugin_basename($parentSlug);
     $hookname = get_plugin_page_hookname($menuSlug, $parentSlug);
     return !has_action($hookname);
 }
 /**
  * Revert the result of attach()
  *
  * @return void
  **/
 function detach()
 {
     parent::detach();
     $this->drop_unique_page();
     $page_hook = get_plugin_page_hookname($this->settings['file'], '');
     remove_action('load-' . $page_hook, array($this, '_save'));
 }
Ejemplo n.º 3
0
/**
 * In BuddyPress 1.1 - 1.2.x, this function provided a better version of add_menu_page()
 * that allowed positioning of menus. Deprecated in 1.5 in favour of a nxt core function.
 *
 * @deprecated 1.5
 * @deprecated Use add_menu_page().
 * @since 1.1
 */
function bp_core_add_admin_menu_page($args = '')
{
    global $_registered_pages, $admin_page_hooks, $menu;
    _deprecated_function(__FUNCTION__, '1.5', 'Use add_menu_page()');
    $defaults = array('access_level' => 2, 'file' => false, 'function' => false, 'icon_url' => false, 'menu_title' => '', 'page_title' => '', 'position' => 100);
    $r = nxt_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $file = plugin_basename($file);
    $hookname = get_plugin_page_hookname($file, '');
    $admin_page_hooks[$file] = sanitize_title($menu_title);
    if (!empty($function) && !empty($hookname)) {
        add_action($hookname, $function);
    }
    if (empty($icon_url)) {
        $icon_url = 'images/generic.png';
    } elseif (is_ssl() && 0 === strpos($icon_url, 'http://')) {
        $icon_url = 'https://' . substr($icon_url, 7);
    }
    do {
        $position++;
    } while (!empty($menu[$position]));
    $menu[$position] = array($menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url);
    $_registered_pages[$hookname] = true;
    return $hookname;
}
Ejemplo n.º 4
0
function add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null)
{
    global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
    $menu_slug = plugin_basename($menu_slug);
    $admin_page_hooks[$menu_slug] = sanitize_title($menu_title);
    $hookname = get_plugin_page_hookname($menu_slug, '');
    if (!empty($function) && !empty($hookname) && current_user_can($capability)) {
        add_action($hookname, $function);
    }
    if (empty($icon_url)) {
        $icon_url = 'dashicons-admin-generic';
        $icon_class = 'menu-icon-generic ';
    } else {
        $icon_url = set_url_scheme($icon_url);
        $icon_class = '';
    }
    $new_menu = array($menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url);
    if (null === $position) {
        $menu[] = $new_menu;
    } else {
        $menu = insertInArray($menu, $position, $new_menu);
    }
    $_registered_pages[$hookname] = true;
    // No parent as top level
    $_parent_pages[$menu_slug] = false;
    return $hookname;
}
 /**
  *  Adds additional management pages
  */
 public static function add_pages()
 {
     if (!current_user_can('manage_options')) {
         return;
     }
     global $_registered_pages;
     /** Template management page */
     $hookname = get_plugin_page_hookname('wp_cta_manage_templates', 'edit.php?post_type=wp-call-to-action');
     if (!empty($hookname)) {
         add_action($hookname, array(__CLASS__, 'display_management_page'));
     }
     $_registered_pages[$hookname] = true;
     /** Template upload page */
     $hookname = get_plugin_page_hookname('wp_cta_templates_upload', 'edit.php?post_type=wp-call-to-action');
     if (!empty($hookname)) {
         add_action($hookname, array(__CLASS__, 'display_upload_page'));
     }
     $_registered_pages[$hookname] = true;
     /** Template search page */
     $hookname = get_plugin_page_hookname('wp_cta_store', 'edit.php?post_type=wp-call-to-action');
     if (!empty($hookname)) {
         add_action($hookname, array(__CLASS__, 'display_store_search'));
     }
     $_registered_pages[$hookname] = true;
 }
	/**
	 * Register plugin menus
	 *
	 * @return void
	 */
	public function admin_menu() {
		// sublevel Export menu
		$export_page_hook_suffix = get_plugin_page_hookname( 'site-migration-export', 'site-migration-export' );
		add_action(
			'admin_print_scripts-' . $export_page_hook_suffix,
			array( $this, 'register_export_scripts_and_styles' )
		);

		// sublevel Import menu
		$import_page_hook_suffix = get_plugin_page_hookname( 'site-migration-import', 'site-migration-export' );
		add_action(
			'admin_print_scripts-' . $import_page_hook_suffix,
			array( $this, 'register_import_scripts_and_styles' )
		);

		// sublevel Settings menu
		$settings_page_hook_suffix = add_submenu_page(
			'site-migration-export',
			__( 'Google Drive Settings', AI1WMGE_PLUGIN_NAME ),
			__( 'Google Drive Settings', AI1WMGE_PLUGIN_NAME ),
			'export',
			'site-migration-gdrive-settings',
			'Ai1wmge_Settings_Controller::index'
		);
		add_action(
			'admin_print_scripts-' . $settings_page_hook_suffix,
			array( $this, 'register_settings_scripts_and_styles' )
		);
	}
Ejemplo n.º 7
0
 public function register_menu()
 {
     add_action('admin_init', array(&$this, 'register_options'));
     if (isset($this->help)) {
         add_contextual_help(get_plugin_page_hookname($this->slug, ''), $this->help);
     }
 }
Ejemplo n.º 8
0
 function add_hidden_pages()
 {
     global $_registered_pages;
     $menu_slug = 'tf_shortcodes_preview';
     $hookname = get_plugin_page_hookname($menu_slug, '');
     if (!empty($hookname)) {
         add_action($hookname, array($this, 'preview_shortcode'));
     }
     $_registered_pages[$hookname] = true;
 }
Ejemplo n.º 9
0
 public function add_non_menu_page($slug, $callback)
 {
     global $_registered_pages;
     $hookname = get_plugin_page_hookname($slug, '');
     if (!empty($hookname)) {
         add_action($hookname, $callback);
     }
     $_registered_pages[$hookname] = true;
     return $hookname;
 }
Ejemplo n.º 10
0
 /**
  * action hook for building admin menu
  */
 public function addAdminMenu()
 {
     // register the instructions page, only linked from plugin page
     global $_registered_pages;
     $hookname = get_plugin_page_hookname(self::MENU_PAGE . '-instructions', '');
     if (!empty($hookname)) {
         add_action($hookname, array($this, 'instructions'));
         $_registered_pages[$hookname] = true;
     }
 }
Ejemplo n.º 11
0
function marketplace_register_admin_page()
{
    global $_registered_pages;
    $menu_slug = plugin_basename('setcommision.php');
    $hookname = get_plugin_page_hookname($menu_slug, '');
    if (!empty($hookname)) {
        add_action($hookname, 'commision_setting_layout');
    }
    $_registered_pages[$hookname] = true;
}
 /**
  * Add Groups Import settings page
  *
  * @since 1.0.0
  */
 public function add_menu_items()
 {
     global $_registered_pages;
     // Register Import Groups page
     if (current_user_can('manage_woocommerce')) {
         // Modifies the `$_registered_pages` global directly
         $hookname = get_plugin_page_hookname('wc-memberships-import-groups', null);
         add_action($hookname, array($this, 'render_import_page'));
         $_registered_pages[$hookname] = true;
     }
 }
Ejemplo n.º 13
0
 public function add_menu()
 {
     global $Ktai_Style;
     add_menu_page(__('Ktai Style Configuration', 'ktai_style'), __('Mobile Output', 'ktai_style'), 'manage_options', self::OPTIONS, array($this, 'misc_page'), $Ktai_Style->get('plugin_url') . KtaiStyle::CONFIG_DIR . '/icon16.png');
     add_submenu_page(self::OPTIONS, __('Ktai Style Configuration', 'ktai_style'), __('Behavior', 'ktai_style'), 'manage_options', self::OPTIONS, array($this, 'misc_page'));
     add_submenu_page(self::OPTIONS, __('Theme for mobile', 'ktai_style'), __('Theme', 'ktai_style'), 'switch_themes', self::THEME_OPTIONS, array($this, 'theme_page'));
     add_action('load-' . get_plugin_page_hookname(self::THEME_OPTIONS, ''), array($this, 'theme_page_header'));
     add_action('load-' . get_plugin_page_hookname(self::THEME_OPTIONS, ''), array($this, 'update_common_theme'));
     add_submenu_page(self::OPTIONS, __('Mobile Theme Configuration', 'ktai_style'), __('Color & Format', 'ktai_style'), 'manage_options', self::COLOR_OPTIONS, array($this, 'color_page'));
     add_submenu_page(self::OPTIONS, __('Delete Configuration', 'ktai_style'), __('Delete Options', 'ktai_style'), 'manage_options', self::DELETE_OPTIONS, array($this, 'delete_page'));
     add_action('admin_print_styles', array($this, 'icon_style'));
 }
 /**
  * Create mp core install plugin page
  *
  * @access   public
  * @since    1.0.0
  * @see      get_plugin_page_hookname()
  * @see      add_action()
  * @return   void
  */
 public function mp_core_install_plugin_page()
 {
     // This WordPress variable is essential: it stores which admin pages are registered to WordPress
     global $_registered_pages;
     // Get the name of the hook for this plugin
     // We use "options-general.php" as the parent as we want our page to appear under "options-general.php?page=mp_core_install_plugin_page" .  $this->plugin_name_slug
     $hookname = get_plugin_page_hookname('mp_core_install_plugin_page_' . $this->plugin_name_slug, 'options-general.php');
     // Add the callback via the action on $hookname, so the callback function is called when the page "options-general.php?page=mp_core_install_plugin_page" .  $this->plugin_name_slug is loaded
     if (!empty($hookname)) {
         add_action($hookname, array($this, 'mp_core_install_check_callback'));
     }
     // Add this page to the registered pages
     $_registered_pages[$hookname] = true;
 }
Ejemplo n.º 15
0
function surveys_add_menu_links()
{
    global $wp_version, $_registered_pages;
    $view_level = 2;
    $page = 'edit.php';
    if ($wp_version >= '2.7') {
        $page = 'tools.php';
    }
    add_submenu_page($page, __('Manage Surveys', 'surveys'), __('Manage Surveys', 'surveys'), $view_level, 'surveys/survey.php');
    $code_pages = array('export.php', 'export_choose.php', 'individual_responses.php', 'question.php', 'question_form.php', 'responses.php', 'show_individual_response.php', 'survey_action.php', 'survey_form.php');
    foreach ($code_pages as $code_page) {
        $hookname = get_plugin_page_hookname("surveys/{$code_page}", '');
        $_registered_pages[$hookname] = true;
    }
}
Ejemplo n.º 16
0
 public function add_menu_pages()
 {
     global $_registered_pages;
     $menu_position = 12;
     $menu_position = apply_filters('mvc_menu_position', $menu_position);
     $admin_pages = MvcConfiguration::get('AdminPages');
     foreach ($this->admin_controller_names as $controller_name) {
         if (isset($admin_pages[$controller_name])) {
             if (empty($admin_pages[$controller_name]) || !$admin_pages[$controller_name]) {
                 continue;
             }
             $pages = $admin_pages[$controller_name];
         } else {
             $pages = null;
         }
         $processed_pages = $this->process_admin_pages($controller_name, $pages);
         $hide_menu = isset($pages['hide_menu']) ? $pages['hide_menu'] : false;
         if (!$hide_menu) {
             $controller_titleized = MvcInflector::titleize($controller_name);
             $admin_controller_name = 'admin_' . $controller_name;
             $top_level_handle = 'mvc_' . $controller_name;
             $method = $admin_controller_name . '_index';
             $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "' . $admin_controller_name . '", "action" => "index"));');
             add_menu_page($controller_titleized, $controller_titleized, 'administrator', $top_level_handle, array($this->dispatcher, $method), null, $menu_position);
             foreach ($processed_pages as $key => $admin_page) {
                 $method = $admin_controller_name . '_' . $admin_page['action'];
                 if (!method_exists($this->dispatcher, $method)) {
                     $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "' . $admin_controller_name . '", "action" => "' . $admin_page['action'] . '"));');
                 }
                 $page_handle = $top_level_handle . '-' . $key;
                 $parent_slug = empty($admin_page['parent_slug']) ? $top_level_handle : $admin_page['parent_slug'];
                 if ($admin_page['in_menu']) {
                     add_submenu_page($parent_slug, $admin_page['label'] . ' ‹ ' . $controller_titleized, $admin_page['label'], $admin_page['capability'], $page_handle, array($this->dispatcher, $method));
                 } else {
                     // It looks like there isn't a more native way of creating an admin page without
                     // having it show up in the menu, but if there is, it should be implemented here.
                     // To do: set up capability handling and page title handling for these pages that aren't in the menu
                     $hookname = get_plugin_page_hookname($page_handle, '');
                     if (!empty($hookname)) {
                         add_action($hookname, array($this->dispatcher, $method));
                     }
                     $_registered_pages[$hookname] = true;
                 }
             }
             $menu_position++;
         }
     }
 }
function sunshine_admin_menu()
{
    global $menu, $sunshine;
    $plugin_dir_path = dirname(__FILE__);
    add_menu_page('Sunshine', 'Sunshine', 'sunshine_manage_options', 'sunshine_admin', 'sunshine_dashboard_display', plugins_url('assets/images/sunshine-icon.png', $plugin_dir_path));
    //add_submenu_page('sunshine', 'Settings', 'Settings', 10,  'sunshine');
    add_submenu_page('sunshine_admin', __('Dashboard', 'sunshine'), __('Dashboard', 'sunshine'), 'sunshine_manage_options', 'sunshine_admin', 'sunshine_dashboard_display');
    add_submenu_page('sunshine_admin', __('Settings', 'sunshine'), __('Settings', 'sunshine'), 'sunshine_manage_options', 'admin.php?page=sunshine');
    $sunshine_admin_submenu = array();
    $sunshine_admin_submenu[9] = array(__('Orders', 'sunshine'), __('Orders', 'sunshine'), 'edit_sunshine_order', 'edit.php?post_type=sunshine-order');
    $sunshine_admin_submenu[10] = array(__('Galleries', 'sunshine'), __('Galleries', 'sunshine'), 'edit_sunshine_gallery', 'edit.php?post_type=sunshine-gallery');
    $sunshine_admin_submenu[20] = array(__('Product Categories', 'sunshine'), __('Product Categories', 'sunshine'), 'edit_sunshine_product', 'edit-tags.php?taxonomy=sunshine-product-category&post_type=sunshine-product');
    $sunshine_admin_submenu[30] = array(__('Products', 'sunshine'), __('Products', 'sunshine'), 'edit_sunshine_product', 'edit.php?post_type=sunshine-product');
    if (!$sunshine->is_pro()) {
        $sunshine_admin_submenu[110] = array(__('Add-Ons or Go Pro!', 'sunshine'), '<span id="sunshine-addons-link">' . __('Add-Ons or Go Pro!', 'sunshine') . '</span>', 'sunshine_manage_options', 'sunshine_addons', 'sunshine_addons');
    }
    $sunshine_admin_submenu[140] = array(__('Get Help', 'sunshine'), __('Get Help', 'sunshine'), 'sunshine_manage_options', 'sunshine_help', 'sunshine_help');
    $sunshine_admin_submenu[150] = array(__('System Info', 'sunshine'), __('System Info', 'sunshine'), 'sunshine_manage_options', 'sunshine_system_info', 'sunshine_system_info');
    $sunshine_admin_submenu = apply_filters('sunshine_admin_menu', $sunshine_admin_submenu);
    ksort($sunshine_admin_submenu);
    foreach ($sunshine_admin_submenu as $item) {
        add_submenu_page('sunshine_admin', $item[0], $item[1], $item[2], $item[3], !empty($item[4]) ? $item[4] : '');
    }
    if (isset($_GET['page']) && $_GET['page'] == 'sunshine_about') {
        add_dashboard_page(__('About Sunshine Photo Cart', 'sunshine'), __('About Sunshine Photo Cart', 'sunshine'), 'manage_options', 'sunshine_about', 'sunshine_about');
    }
    // "Hidden" page for image processor - allows us to make the page but not appear in menu
    // This WordPress variable is essential: it stores which admin pages are registered to WordPress
    global $_registered_pages;
    // Get the name of the hook for this plugin
    $hookname_image_processor = get_plugin_page_hookname('sunshine_image_processor', 'admin.php');
    $hookname_bulk_add_products = get_plugin_page_hookname('sunshine_bulk_add_products', 'admin.php');
    $hookname_invoice_display = get_plugin_page_hookname('sunshine_invoice_display', 'admin.php');
    // Add the callback via the action on $hookname, so the callback function is called when the page "options-general.php?page=my-plugin-hidden-page" is loaded
    if (!empty($hookname_image_processor)) {
        add_action($hookname_image_processor, 'sunshine_image_processor');
    }
    if (!empty($hookname_bulk_add_products)) {
        add_action($hookname_bulk_add_products, 'sunshine_bulk_add_products');
    }
    if (!empty($hookname_invoice_display)) {
        add_action($hookname_invoice_display, 'sunshine_invoice_display');
    }
    // Add this page to the registered pages
    $_registered_pages[$hookname_image_processor] = true;
    $_registered_pages[$hookname_bulk_add_products] = true;
    $_registered_pages[$hookname_invoice_display] = true;
}
Ejemplo n.º 18
0
/**
 * Get profile section slugs
 *
 * @since 0.1.7
 */
function wp_user_profiles_get_section_hooknames($section = '')
{
    // What slugs are we looking for
    $sections = !empty($section) ? array($section) : wp_list_pluck(wp_user_profiles_sections(), 'slug');
    // Get file
    $hooks = array();
    $file = wp_user_profiles_get_file();
    // Generate hooknames
    foreach ($sections as $slug) {
        $hookname = get_plugin_page_hookname($slug, $file);
        $hooks[] = $hookname;
    }
    // Network & user admin corrections
    array_walk($hooks, '_wp_user_profiles_walk_section_hooknames');
    return $hooks;
}
Ejemplo n.º 19
0
function eventr_add_menu_links()
{
    global $wp_version;
    $view_level = 2;
    $page = 'edit.php';
    if ($wp_version >= '2.7') {
        $page = 'tools.php';
    }
    add_submenu_page($page, __('Manage Events', 'eventr'), __('Manage Events', 'eventr'), $view_level, 'eventr/events.php');
    global $_registered_pages;
    $code_pages = array('attendee_form.php', 'attendees.php', 'event_form.php', 'export.php', 'export_choose.php', 'event_action.php');
    foreach ($code_pages as $code_page) {
        $hookname = get_plugin_page_hookname("eventr/{$code_page}", '');
        $_registered_pages[$hookname] = true;
    }
}
 /**
  * Add support for additional pages
  */
 public static function create_pages()
 {
     if (!current_user_can('manage_options')) {
         return;
     }
     global $_registered_pages;
     $hookname = get_plugin_page_hookname('lp_templates_upload', 'edit.php?post_type=landing-page');
     if (!empty($hookname)) {
         add_action($hookname, 'lp_templates_upload');
     }
     $_registered_pages[$hookname] = true;
     $hookname = get_plugin_page_hookname('lp_templates_search', 'edit.php?post_type=landing-page');
     /*echo $hookname;exit; */
     if (!empty($hookname)) {
         add_action($hookname, 'lp_templates_search');
     }
     $_registered_pages[$hookname] = true;
 }
Ejemplo n.º 21
0
 function append_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '')
 {
     global $submenu;
     global $menu;
     global $_wp_real_parent_file;
     global $_wp_submenu_nopriv;
     global $_registered_pages;
     global $_parent_pages;
     $menu_slug = plugin_basename($menu_slug);
     $parent_slug = plugin_basename($parent_slug);
     if (isset($_wp_real_parent_file[$parent_slug])) {
         $parent_slug = $_wp_real_parent_file[$parent_slug];
     }
     if (!current_user_can($capability)) {
         $_wp_submenu_nopriv[$parent_slug][$menu_slug] = true;
         return false;
     }
     // If the parent doesn't already have a submenu, add a link to the parent
     // as the first item in the submenu. If the submenu file is the same as the
     // parent file someone is trying to link back to the parent manually. In
     // this case, don't automatically add a link back to avoid duplication.
     if (!isset($submenu[$parent_slug]) && $menu_slug != $parent_slug) {
         foreach ((array) $menu as $parent_menu) {
             if ($parent_menu[2] == $parent_slug && current_user_can($parent_menu[1])) {
                 $submenu[$parent_slug][] = $parent_menu;
             }
         }
     }
     $mymenu = array();
     $mymenu[] = array($menu_title, $capability, $menu_slug, $page_title);
     $submenu[$parent_slug] = array_merge($mymenu, $submenu[$parent_slug]);
     $hookname = get_plugin_page_hookname($menu_slug, $parent_slug);
     if (!empty($function) && !empty($hookname)) {
         add_action($hookname, $function);
     }
     $_registered_pages[$hookname] = true;
     // backwards-compatibility for plugins using add_management page. See wp-admin/admin.php for redirect from edit.php to tools.php
     if ('tools.php' == $parent_slug) {
         $_registered_pages[get_plugin_page_hookname($menu_slug, 'edit.php')] = true;
     }
     // No parent as top level
     $_parent_pages[$menu_slug] = $parent_slug;
     return $hookname;
 }
Ejemplo n.º 22
0
function user_can_access_admin_page()
{
    global $pagenow;
    global $menu;
    global $submenu;
    global $_wp_menu_nopriv;
    global $_wp_submenu_nopriv;
    global $plugin_page;
    global $_registered_pages;
    $parent = get_admin_page_parent();
    if (!isset($plugin_page) && isset($_wp_submenu_nopriv[$parent][$pagenow])) {
        return false;
    }
    if (isset($plugin_page)) {
        if (isset($_wp_submenu_nopriv[$parent][$plugin_page])) {
            return false;
        }
        $hookname = get_plugin_page_hookname($plugin_page, $parent);
        if (!isset($_registered_pages[$hookname])) {
            return false;
        }
    }
    if (empty($parent)) {
        if (isset($_wp_menu_nopriv[$pagenow])) {
            return false;
        }
        if (isset($_wp_submenu_nopriv[$pagenow][$pagenow])) {
            return false;
        }
        if (isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page])) {
            return false;
        }
        if (isset($plugin_page) && isset($_wp_menu_nopriv[$plugin_page])) {
            return false;
        }
        foreach (array_keys($_wp_submenu_nopriv) as $key) {
            if (isset($_wp_submenu_nopriv[$key][$pagenow])) {
                return false;
            }
            if (isset($plugin_page) && isset($_wp_submenu_nopriv[$key][$plugin_page])) {
                return false;
            }
        }
        return true;
    }
    if (isset($plugin_page) && $plugin_page == $parent && isset($_wp_menu_nopriv[$plugin_page])) {
        return false;
    }
    if (isset($submenu[$parent])) {
        foreach ($submenu[$parent] as $submenu_array) {
            if (isset($plugin_page) && $submenu_array[2] == $plugin_page) {
                if (current_user_can($submenu_array[1])) {
                    return true;
                } else {
                    return false;
                }
            } else {
                if ($submenu_array[2] == $pagenow) {
                    if (current_user_can($submenu_array[1])) {
                        return true;
                    } else {
                        return false;
                    }
                }
            }
        }
    }
    foreach ($menu as $menu_array) {
        if ($menu_array[2] == $parent) {
            if (current_user_can($menu_array[1])) {
                return true;
            } else {
                return false;
            }
        }
    }
    return true;
}
function get_plugin_page_hook($plugin_page, $parent_page)
{
    global $wp_filter;
    $hook = get_plugin_page_hookname($plugin_page, $parent_page);
    if (isset($wp_filter[$hook])) {
        return $hook;
    } else {
        return '';
    }
}
Ejemplo n.º 24
0
 /**
  * Contextual help list filter
  *
  * @param string $list
  * @return string
  */
 function contextual_help_list($list)
 {
     w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/other.php');
     $faq = w3_parse_faq();
     if (isset($faq['Usage'])) {
         $columns = array_chunk($faq['Usage'], ceil(count($faq['Usage']) / 3));
         ob_start();
         include W3TC_INC_OPTIONS_DIR . '/common/help.php';
         $help = ob_get_contents();
         ob_end_clean();
         $hook = get_plugin_page_hookname($this->_page, 'w3tc_dashboard');
         $list[$hook] = $help;
     }
     return $list;
 }
Ejemplo n.º 25
0
}
$post_type_object = get_post_type_object($post_type);
if ('post' == $post_type) {
    $parent_file = 'edit.php';
    $submenu_file = 'post-new.php';
} elseif ('attachment' == $post_type) {
    if (wp_redirect(admin_url('media-new.php'))) {
        exit;
    }
} else {
    $submenu_file = "post-new.php?post_type={$post_type}";
    if (isset($post_type_object) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true) {
        $parent_file = $post_type_object->show_in_menu;
        // What if there isn't a post-new.php item for this post type?
        if (!isset($_registered_pages[get_plugin_page_hookname("post-new.php?post_type={$post_type}", $post_type_object->show_in_menu)])) {
            if (isset($_registered_pages[get_plugin_page_hookname("edit.php?post_type={$post_type}", $post_type_object->show_in_menu)])) {
                // Fall back to edit.php for that post type, if it exists
                $submenu_file = "edit.php?post_type={$post_type}";
            } else {
                // Otherwise, give up and highlight the parent
                $submenu_file = $parent_file;
            }
        }
    } else {
        $parent_file = "edit.php?post_type={$post_type}";
    }
}
$title = $post_type_object->labels->add_new_item;
$editing = true;
if (!current_user_can($post_type_object->cap->edit_posts) || !current_user_can($post_type_object->cap->create_posts)) {
    wp_die(__('Cheatin&#8217; uh?'), 403);
Ejemplo n.º 26
0
 function CallHtmlShowHelpList($filterVal, $screen)
 {
     $id = get_plugin_page_hookname(GoogleSitemapGeneratorLoader::GetBaseName(), 'options-general.php');
     if ($screen == $id) {
         $links = array(__('Plugin Homepage', 'sitemap') => 'http://www.arnebrachhold.de/redir/sitemap-help-home/', __('My Sitemaps FAQ', 'sitemap') => 'http://www.arnebrachhold.de/redir/sitemap-help-faq/');
         $filterVal[$id] = '';
         $i = 0;
         foreach ($links as $text => $url) {
             $filterVal[$id] .= '<a href="' . $url . '">' . $text . '</a>' . ($i < count($links) - 1 ? '<br />' : '');
             $i++;
         }
     }
     return $filterVal;
 }
Ejemplo n.º 27
0
 public function add_menu_pages()
 {
     global $_registered_pages;
     $menu_position = 12;
     $menu_position = apply_filters('mvc_menu_position', $menu_position);
     $admin_pages = MvcConfiguration::get('AdminPages');
     foreach ($this->admin_controller_names as $controller_name) {
         if (isset($admin_pages[$controller_name])) {
             if (empty($admin_pages[$controller_name]) || !$admin_pages[$controller_name]) {
                 continue;
             }
             $pages = $admin_pages[$controller_name];
         } else {
             $pages = null;
         }
         $processed_pages = $this->process_admin_pages($controller_name, $pages);
         $hide_menu = isset($pages['hide_menu']) ? $pages['hide_menu'] : false;
         if (!$hide_menu) {
             $menu_icon = 'dashicons-admin-generic';
             /* check if there is a corresponding model with a menu_icon post type argument */
             try {
                 $model_name = MvcInflector::singularize(MvcInflector::camelize($controller_name));
                 $model = mvc_model($model_name);
                 if (isset($model->wp_post['post_type']['args']['menu_icon'])) {
                     $menu_icon = $model->wp_post['post_type']['args']['menu_icon'];
                 }
             } catch (Exception $e) {
                 //not every controller must have a corresponding model, continue silently
             }
             $controller_titleized = MvcInflector::titleize($controller_name);
             $admin_controller_name = 'admin_' . $controller_name;
             $top_level_handle = 'mvc_' . $controller_name;
             $method = $admin_controller_name . '_index';
             $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "' . $admin_controller_name . '", "action" => "index"));');
             $capability = $this->admin_controller_capabilities[$controller_name];
             add_menu_page($controller_titleized, $controller_titleized, $capability, $top_level_handle, array($this->dispatcher, $method), $menu_icon, $menu_position);
             foreach ($processed_pages as $key => $admin_page) {
                 $method = $admin_controller_name . '_' . $admin_page['action'];
                 if (!method_exists($this->dispatcher, $method)) {
                     $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "' . $admin_controller_name . '", "action" => "' . $admin_page['action'] . '"));');
                 }
                 $page_handle = $top_level_handle . '-' . $key;
                 $parent_slug = empty($admin_page['parent_slug']) ? $top_level_handle : $admin_page['parent_slug'];
                 if ($admin_page['in_menu']) {
                     add_submenu_page($parent_slug, $admin_page['label'] . ' &lsaquo; ' . $controller_titleized, $admin_page['label'], $admin_page['capability'], $page_handle, array($this->dispatcher, $method));
                 } else {
                     // It looks like there isn't a more native way of creating an admin page without
                     // having it show up in the menu, but if there is, it should be implemented here.
                     // To do: set up capability handling and page title handling for these pages that aren't in the menu
                     $hookname = get_plugin_page_hookname($page_handle, '');
                     if (!empty($hookname)) {
                         add_action($hookname, array($this->dispatcher, $method));
                     }
                     $_registered_pages[$hookname] = true;
                 }
             }
             $menu_position++;
         }
     }
 }
Ejemplo n.º 28
0
function qs_init()
{
    global $q_config;
    if ($q_config['qtranslate_services']) {
        /* disabled for meta box
        		add_filter('qtranslate_toolbar',			'qs_toobar');
        		add_filter('qtranslate_modify_editor_js',	'qs_editor_js');
        	*/
        add_meta_box('translatediv', __('Translate to', 'qtranslate'), 'qs_translate_box', 'post', 'side', 'core');
        add_meta_box('translatediv', __('Translate to', 'qtranslate'), 'qs_translate_box', 'page', 'side', 'core');
        add_action('qtranslate_languageColumn', 'qs_translateButtons', 10, 2);
        // add plugin page without menu link for users with permission
        if (current_user_can('edit_published_posts')) {
            //add_posts_page(__('Translate','qtranslate'), __('Translate','qtranslate'), 'edit_published_posts', 'qtranslate_services', 'qs_service');
            global $_registered_pages;
            $hookname = get_plugin_page_hookname('qtranslate_services', 'edit.php');
            add_action($hookname, 'qs_service');
            $_registered_pages[$hookname] = true;
        }
    }
}
 /**
  * Find plugin's admin dashboard main menu item.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.2
  *
  * @return string[]|false
  */
 private function find_top_level_menu()
 {
     global $menu;
     $position = -1;
     $found_menu = false;
     $menu_slug = $this->get_original_menu_slug();
     $hook_name = get_plugin_page_hookname($menu_slug, '');
     foreach ($menu as $pos => $m) {
         if ($menu_slug === $m[2]) {
             $position = $pos;
             $found_menu = $m;
             break;
         }
     }
     if (false === $found_menu) {
         return false;
     }
     return array('menu' => $found_menu, 'position' => $position, 'hook_name' => $hook_name);
 }
Ejemplo n.º 30
0
function get_plugin_page_hook($plugin_page, $parent_page)
{
    $hook = get_plugin_page_hookname($plugin_page, $parent_page);
    if (has_action($hook)) {
        return $hook;
    } else {
        return null;
    }
}