本文整理汇总了PHP中MS_Controller_Plugin::base_slug方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Controller_Plugin::base_slug方法的具体用法?PHP MS_Controller_Plugin::base_slug怎么用?PHP MS_Controller_Plugin::base_slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS_Controller_Plugin
的用法示例。
在下文中一共展示了MS_Controller_Plugin::base_slug方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_menu_pages
/**
* Adds Dashboard navigation menus.
*
* @since 1.0.0
*/
public function add_menu_pages()
{
global $submenu;
$limited_mode = false;
$view = MS_Model_Settings::get_special_view();
if ($view) {
// A special view is displayed. Do not display other menu items.
$pages = array();
$limited_mode = true;
} elseif (MS_Plugin::is_wizard()) {
// Submenus definition: Wizard mode
$pages = $this->get_setup_menu_pages();
$limited_mode = true;
} else {
// Submenus definition: Normal mode
$pages = $this->get_default_menu_pages();
if (MS_Plugin::is_network_wide() && !is_network_admin()) {
$limited_mode = true;
}
}
/**
* Allow Add-ons and other plugins to add menu pages.
*
* A menu item is defined by an array containing the following members:
* 'title' => '...',
* 'slug' => '...',
* 'function' => callback
*
* @var array
*/
$pages = apply_filters('ms_plugin_menu_pages', $pages, $limited_mode, $this);
$page_keys = array_keys($pages);
$slug = '';
if (isset($page_keys[0]) && $pages[$page_keys[0]]) {
$slug = $pages[$page_keys[0]]['slug'];
}
if (empty($slug)) {
self::$base_slug = self::MENU_SLUG;
} else {
self::$base_slug = self::MENU_SLUG . '-' . $slug;
}
/*
* Create primary menu item: Membership.
*
* The menu title is not translatable because of a bug in WordPress core
* https://core.trac.wordpress.org/ticket/18857
* Until this bug is closed the title (2nd argument) can't be translated
*/
add_menu_page('Membership 2', 'Membership 2', $this->capability, self::$base_slug, null, 'dashicons-lock');
// Create submenus
foreach ($pages as $page) {
if (!is_array($page)) {
continue;
}
if (empty($page['link'])) {
$menu_link = false;
} else {
$menu_link = $page['link'];
}
$slug = self::MENU_SLUG;
if (!empty($page['slug'])) {
$slug .= '-' . $page['slug'];
}
add_submenu_page(self::$base_slug, strip_tags($page['title']), $page['title'], $this->capability, $slug, array($this, 'handle_submenu_request'));
/*
* WordPress does not support absolute URLs in the admin-menu.
* So we have to manny modify the menu-link href value if our slug
* is an absolute URL.
*/
if ($menu_link) {
$item = end($submenu[self::$base_slug]);
$key = key($submenu[self::$base_slug]);
$submenu[self::$base_slug][$key][2] = $menu_link;
}
}
do_action('ms_controller_plugin_add_menu_pages', $this);
// Setup the rest of the plugin after the menu was registered.
do_action('ms_plugin_admin_setup');
}