Пример #1
0
function mylinkorder_menu()
{
    add_links_page(__('My Link Order', 'mylinkorder'), __('My Link Order', 'mylinkorder'), 'manage_links', 'mylinkorder', 'mylinkorder');
}
Пример #2
0
function wp_default_links_menu()
{
    add_links_page('Default Links', 'Default Links', 'manage_options', 'wp-default-link', 'wp_default_links_options');
}
Пример #3
0
 /**
  * Create a WP Settings Page in the Links section
  * @todo Allow both menu page and options page?
  * @param string $page_title
  * @param string $page_subtitle
  * @param string $menu_title
  * @param string $capability
  * @param string $menu_slug
  * @param string|array $function
  * @param string $icon_url Optional
  * @param int|null $position Optional
  * @return WPSettingsPage
  */
 public function __construct($page_title, $page_subtitle, $menu_title, $capability, $menu_slug, $function)
 {
     // Call parent constructor to setup everything
     parent::__construct($page_title, $page_subtitle, $menu_title, $capability, $menu_slug, $function, null, null);
     // Add links page
     add_links_page($page_title, $menu_title, $capability, $menu_slug, $function);
     return $this;
 }
Пример #4
0
/**
 *
 */
function add_export_link()
{
    add_links_page('Download Links', 'Download Links', 'read', '../wp-content/plugins/datagov-custom/wp_download_links.php', 'pccf_render_form');
}
 /**
  * Loads the admin menu with user-defined flags.
  */
 function load_admin_menu()
 {
     switch ($this->menu_type) {
         case 'page':
             $hook = add_pages_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'link':
             $hook = add_links_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'comment':
             $hook = add_comments_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'management':
             $hook = add_management_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'option':
             $hook = add_options_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'theme':
             $hook = add_theme_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'plugin':
             $hook = add_plugins_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'user':
             $hook = add_users_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'dashboard':
             $hook = add_dashboard_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'post':
             $hook = add_posts_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         case 'media':
             $hook = add_media_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'));
             break;
         default:
             $hook = add_menu_page($this->plugin_title, $this->menu_title, $this->cap, $this->slug, array(&$this, 'render_options_page'), $this->icon, isset($this->menu_pos) ? $this->menu_pos : null);
             break;
     }
     $this->hook = $hook;
 }
Пример #6
0
 /**
  * Displays the menu entry on the WordPress Dashboard
  *
  * @return bool Returns `true` if successful, `false` otherwise.
  * @throws \Exception if the no title or callback function was specified
  */
 public function display()
 {
     if (empty($this->title) || empty($this->_properties['callback'])) {
         throw new \Exception('No title or callback function specified for menu entry');
     }
     $title = $this->title;
     $page_title = $this->page_title;
     $icon = $this->icon;
     $capability = $this->capability;
     $parent = $this->_properties['parent_slug'];
     $slug = $this->_properties['slug'];
     if (empty($slug)) {
         $_cb = $this->_properties['callback'];
         $slug = Helpers::makeSlug(is_array($_cb) ? $_cb[1] : (string) $_cb);
         // Since 1.0.5, slug is based on callback function name
         unset($_cb);
     }
     if (empty($page_title)) {
         $page_title = $title;
     }
     // Sanitize and add count to the title here (prior operations use a "clean" title)
     if ($this->count !== false) {
         $title = htmlspecialchars($title) . ' <span class="awaiting-mod"><span class="pending-count">' . $this->count . '</span></span>';
     } else {
         $title = htmlspecialchars($title);
     }
     // We call our own callback first
     $callback = array($this, 'onMenuCallback');
     switch ($this->_properties['type']) {
         case self::MT_CUSTOM:
             if (empty($capability)) {
                 $capability = 'read';
             }
             $this->hook = add_menu_page($page_title, $title, $capability, $slug, $callback, $icon);
             break;
         case self::MT_SUBMENU:
             if (empty($capability)) {
                 $capability = 'read';
             }
             if (!$this->_properties['use_subheaders']) {
                 $this->hook = add_submenu_page($parent, $page_title, $title, $capability, $slug, $callback);
             } else {
                 $this->hook = '';
             }
             break;
         case self::MT_COMMENTS:
             if (empty($capability)) {
                 $capability = 'moderate_comments';
             }
             $this->hook = add_comments_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_DASHBOARD:
             if (empty($capability)) {
                 $capability = 'read';
             }
             $this->hook = add_dashboard_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_LINKS:
             if (empty($capability)) {
                 $capability = 'manage_links';
             }
             $this->hook = add_links_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_TOOLS:
             if (empty($capability)) {
                 $capability = 'import';
             }
             $this->hook = add_management_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_MEDIA:
             if (empty($capability)) {
                 $capability = 'upload_files';
             }
             $this->hook = add_media_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_SETTINGS:
             if (empty($capability)) {
                 $capability = 'manage_options';
             }
             $this->hook = add_options_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_PAGES:
             if (empty($capability)) {
                 $capability = 'edit_pages';
             }
             $this->hook = add_pages_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_PLUGINS:
             if (empty($capability)) {
                 $capability = 'update_plugins';
             }
             $this->hook = add_plugins_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_POSTS:
             if (empty($capability)) {
                 $capability = 'edit_posts';
             }
             $this->hook = add_posts_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_THEMES:
             if (empty($capability)) {
                 $capability = 'edit_theme_options';
             }
             $this->hook = add_theme_page($page_title, $title, $capability, $slug, $callback);
             break;
         case self::MT_USERS:
             if (empty($capability)) {
                 $capability = 'edit_users';
             }
             $this->hook = add_users_page($page_title, $title, $capability, $slug, $callback);
             break;
         default:
             $this->hook = false;
             break;
     }
     $this->displayed = $this->hook !== false;
     if ($this->displayed) {
         // Write back any changes for future reference
         $this->_properties['slug'] = $slug;
         $this->capability = $capability;
         $this->page_title = $page_title;
     }
     return $this->displayed;
 }