public function admin_menu()
 {
     $this->slug = add_comments_page($this->title, $this->name, $this->capability, get_class(), array($this, 'show_page'));
     //help tabs
     add_action('load-' . $this->slug, array($this, '_help_tab'));
     add_action(get_class() . 'add_meta_boxes', array($this, 'add_meta_boxes'));
 }
function oaf_create_submenu()
{
    add_dashboard_page('OAF Settings', 'OAF Settings', 'manage_options', 'oaf_create_submenu_plugin', 'oaf_create_submenu_function');
    add_posts_page('OAF Settings', 'OAF Settings', 'manage_options', 'oaf_create_submenu_plugin', 'oaf_create_submenu_function');
    add_media_page('OAF Settings', 'OAF Settings', 'manage_options', 'oaf_create_submenu_plugin', 'oaf_create_submenu_function');
    add_pages_page('OAF Settings', 'OAF Settings', 'manage_options', 'oaf_create_submenu_plugin', 'oaf_create_submenu_function');
    add_comments_page('OAF Settings', 'OAF Settings', 'manage_options', 'oaf_create_submenu_plugin', 'oaf_create_submenu_function');
    add_theme_page('OAF Settings', 'OAF Settings', 'manage_options', 'oaf_create_submenu_plugin', 'oaf_create_submenu_function');
    add_users_page('OAF Settings', 'OAF Settings', 'manage_options', 'oaf_create_submenu_plugin', 'oaf_create_submenu_function');
    add_management_page('OAF Settings', 'OAF Settings', 'manage_options', 'oaf_create_submenu_plugin', 'oaf_create_submenu_function');
    add_options_page('OAF Settings', 'OAF Settings', 'manage_options', 'oaf_create_submenu_plugin', 'oaf_create_submenu_function');
}
function ct_add_comments_menu()
{
    if (current_user_can('activate_plugins')) {
        add_comments_page(__("Check for spam", 'cleantalk'), __("Check for spam", 'cleantalk'), 'read', 'ct_check_spam', 'ct_show_checkspam_page');
    }
}
 /**
  * Adds a link that will appear in the comments admin menu group on the
  * admin side of a student's blog that allows them to view all comments
  * that they have left on other students' blogs.
  *
  * @access private
  * @since 0.2
  */
 public function _add_student_comment_list()
 {
     if (ClassBlogs_Utils::on_student_blog_admin()) {
         add_comments_page(__('My Comments'), __('My Comments'), 'edit_posts', $this->get_uid() . '-my-comments', array($this, '_student_admin_page'));
     }
 }
<?php

/**
 * This test helper creates a bunch of admin menus in different locations.
 * Useful for testing the editor's ability to move/copy/add plugin menus.
 */
add_action('admin_menu', function () {
    add_options_page('Dummy Settings', 'Dummy Settings', 'read', 'dummy-settings', 'amt_output_page');
    add_comments_page('Dummy Comments', 'Dummy Comments', 'read', 'dummy-comments', 'amt_output_page');
    add_menu_page('Dummy Top Menu', 'Dummy Top Menu', 'read', 'dummy-top-menu', 'amt_output_page');
    add_submenu_page('dummy-top-menu', 'Dummy Submenu #1', 'Dummy Submenu #1', 'read', 'dummy-submenu-1', 'amt_output_page');
    add_submenu_page('dummy-top-menu', 'Dummy Submenu #2', 'Dummy Submenu #2', 'read', 'dummy-submenu-2', 'amt_output_page');
    add_dashboard_page('Dummy Dashboard', 'Dummy Dashboard', 'read', 'dummy-dashboard-page', 'amt_output_page');
    //A top-level menu with no submenus.
    add_menu_page('The Dummy', 'The Dummy', 'read', 'dummy-menu-with-no-items', 'amt_output_page');
});
function amt_output_page()
{
    echo 'This is a dummy page.';
}
 public function admin_menu()
 {
     $this->user_created_pages = SerializeStringToArray(get_option($this->prefix('user_created_pages')));
     if ($this->user_created_pages && count($this->user_created_pages) >= 1) {
         foreach ($this->user_created_pages as $page) {
             if (isset($page['page_slug']) && isset($page['page_title']) && isset($page['parent_menu'])) {
                 if ($page['parent_menu'] == 'new_menu') {
                     add_menu_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'dashboard') {
                     add_dashboard_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'posts') {
                     add_posts_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'media') {
                     add_media_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'pages') {
                     add_pages_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'comments') {
                     add_comments_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'theme') {
                     add_theme_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'plugins') {
                     add_plugins_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'users') {
                     add_users_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'management') {
                     add_management_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif ($page['parent_menu'] == 'options') {
                     add_options_page($page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 } elseif (array_key_exists($page['parent_menu'], $user_pages)) {
                     add_submenu_page($page['parent_menu'], $page['page_title'], $page['page_title'], 'manage_options', $page['page_slug'], array($this, 'user_created_menu_pages'));
                 }
             }
         }
     }
 }
Example #7
0
 /**
  * Create a WP Settings Page in the Comments 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 comments page
     add_comments_page($page_title, $menu_title, $capability, $menu_slug, $function);
     return $this;
 }
 /**
  * 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;
 }
Example #9
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;
 }
function exportador_comentarios_menu()
{
    add_comments_page('Exportar', 'Exportar', 'manage_options', 'exportador_comentarios', 'exportador_comentarios_page_callback_function');
}