/** * Add a handy reminder to the toolbar. * @param object $toolbar The toolbar * @return null */ function toolbar_menu($toolbar) { if (!is_admin_bar_showing()) { return; } $toolbar->add_node(array('id' => 'is-dev-site', 'title' => 'Development Site', 'href' => site_url())); }
/** * Adds "WPForm" item to new-content admin bar menu item. * * @since 1.1.7.2 * @param object $wp_admin_bar */ public function admin_bar($wp_admin_bar) { if (!is_admin_bar_showing() || !current_user_can(apply_filters('wpforms_manage_cap', 'manage_options'))) { return; } $args = array('id' => 'wpform', 'title' => 'WPForm', 'href' => admin_url('admin.php?page=wpforms-builder'), 'parent' => 'new-content'); $wp_admin_bar->add_node($args); }
/** * Today's Conversion Rate. * * Adds today's conversion rate in the admin bar with * a direct link to the stats page. * * @since 1.2.2 * @param object $wp_admin_bar The global admin bar object * @return void */ function wpas_admin_bar_conversion_rate($wp_admin_bar) { /* Get today's conversion rate. */ $rate = wpbo_today_conversion(); /* Set the node parameters. */ $args = array('id' => 'wpbo_today_conversion', 'title' => sprintf(__('Today\'s Conversion: %s', 'betteroptin'), "{$rate}%"), 'href' => admin_url('edit.php?popup=all&period=today&post_type=wpbo-popup&page=wpbo-analytics'), 'meta' => array('class' => 'wpbo-today-conversion')); /* Add the new node. */ $wp_admin_bar->add_node($args); }
/** * Move the Customizer link from the Adminbar top-level to be a sub-item under the site-menu. * * @param object $wp_admin_bar The admin bar object. Gets passed by reference. */ function adminbar_no_customizer($wp_admin_bar) { $node = $wp_admin_bar->get_node('customize'); // Check if the customizer node exists. if ($node) { $args = $node; $args->parent = 'appearance'; $wp_admin_bar->add_node($args); } }
/** * Add link to agent's tickets. * * @since 3.0.0 * * @param object $wp_admin_bar The WordPress toolbar object * * @return void */ function wpas_toolbar_tickets_link($wp_admin_bar) { if (!current_user_can('edit_ticket')) { return; } $hide = (bool) wpas_get_option('hide_closed'); $agent_see_all = (bool) wpas_get_option('agent_see_all'); $admin_see_all = (bool) wpas_get_option('admin_see_all'); $args = array('post_type' => 'ticket'); // In case the current user can only see his own tickets if (current_user_can('administrator') && false === $admin_see_all || !current_user_can('administrator') && false === $agent_see_all) { global $current_user; $agent = new WPAS_Member_Agent($current_user->ID); $tickets_count = $agent->open_tickets(); } else { $tickets_count = count(wpas_get_tickets('open', $args)); } if (true === $hide) { $args['wpas_status'] = 'open'; } $node = array('id' => 'wpas_tickets', 'parent' => null, 'group' => null, 'title' => '<span class="ab-icon"></span> ' . $tickets_count, 'href' => add_query_arg($args, admin_url('edit.php')), 'meta' => array('target' => '_self', 'title' => esc_html__('Open tickets assigned to you', 'awesome-support'), 'class' => 'wpas-my-tickets')); $wp_admin_bar->add_node($node); }
/** * Adds the dev menu to the toolbar * * @since TabulaRasa 1.11 * @param object $admin_bar */ function dev_toolbar_items($admin_bar) { if (current_user_can('manage_options') && WP_DEBUG === true) { $admin_bar->add_node(array('id' => 'tr-dev-tools', 'title' => 'TabulaRasa Dev Tools', 'href' => '#', 'meta' => array('title' => __('Dev Tools')))); if (!is_admin()) { global $wp_query; $admin_bar->add_node(array('id' => 'tr-dev-grid-overlay', 'parent' => 'tr-dev-tools', 'title' => __('Grid Overlay'), 'href' => '#', 'meta' => array('title' => __('Show the grid overlay')))); $admin_bar->add_node(array('id' => 'tr-dev-current-template', 'parent' => 'tr-dev-tools', 'title' => __('Template') . ': ' . $this->dev['current_template'], 'href' => admin_url('theme-editor.php?file=' . $this->dev['current_template'] . '&theme=' . $this->theme->name), 'meta' => array('title' => __('Edit this template')))); } } }
/** * Customize the dropdown under "Dashboard" in admin bar on front-end * * @see admin_bar_menu * * @param object $wp_admin_bar admin bar main object. */ public function add_toolbar_links($wp_admin_bar) { // Abort if we're not on the front-end if (is_admin() || !current_user_can('edit_users')) { return; } $plugins = array('parent' => 'site-name', 'id' => 'plugins', 'title' => __('Plugins', 'evans-mu'), 'href' => admin_url('plugins.php')); $pages = array('parent' => 'site-name', 'id' => 'pages', 'title' => __('Pages', 'evans-mu'), 'href' => admin_url('edit.php?post_type=page')); $posts = array('parent' => 'site-name', 'id' => 'posts', 'title' => __('Posts', 'evans-mu'), 'href' => admin_url('edit.php?post_type=post')); // Add our nodes $wp_admin_bar->add_node($plugins); $wp_admin_bar->add_node($pages); $wp_admin_bar->add_node($posts); // Remove worthless nodes $wp_admin_bar->remove_node('customize'); $wp_admin_bar->remove_node('widgets'); $wp_admin_bar->remove_node('themes'); }
/** * This adds a "Theme Options" link to the WordPress admin bar under the menu * with the site name. Is only visible to users who can edit theme options. * * @param object $wp_admin_bar The wp_admin_bar object as supplied by WordPress * @return void */ public function admin_bar_links($wp_admin_bar) { if (current_user_can('edit_theme_options')) { $wp_admin_bar->add_node(array('id' => 'theme-options', 'parent' => 'site-name', 'title' => 'Theme Options', 'href' => theme::options_uri())); } }
/** * Adds the page builder button to the WordPress admin bar. * * @since 1.0 * @param object $wp_admin_bar An instance of the WordPress admin bar. * @return void */ public static function admin_bar_menu($wp_admin_bar) { global $wp_the_query; if (FLBuilderModel::is_post_editable()) { $wp_admin_bar->add_node(array('id' => 'fl-builder-frontend-edit-link', 'title' => '<style> #wp-admin-bar-fl-builder-frontend-edit-link .ab-icon:before { content: "\\f116" !important; top: 2px; margin-right: 3px; } </style><span class="ab-icon"></span>' . FLBuilderModel::get_branding(), 'href' => FLBuilderModel::get_edit_url($wp_the_query->post->ID))); } }
/** * Adds the `test schema` link to the admin toolbar * * @param object $wp_admin_bar the current admin bar */ public function schema_test($wp_admin_bar) { // No link on admin panel if (is_admin()) { return; } // only load on singles if (!is_singular()) { return; } //get some variables global $post; $link = get_permalink($post->ID); // set args for tab global $wp_admin_bar; $args = array('parent' => 'top-secondary', 'id' => 'schema-test', 'title' => _x('Test Schema', 'test the schema button title', 'schema'), 'href' => esc_url(__('http://www.google.com/webmasters/tools/richsnippets', 'schema') . '?q=' . urlencode($link)), 'meta' => array('class' => 'schema-test', 'target' => '_blank')); $wp_admin_bar->add_node($args); }
/** * Add Template menu to Admin Bar. * * @since 1.0.0 * @access public * @param object $wp_admin_bar */ public function add_admin_bar_menu($wp_admin_bar) { if (!TF_Model::is_tf_editor_active()) { return; } $args = array(array('id' => 'tf_template_admin_menu', 'title' => __('TF Template', 'themify-flow'), 'href' => '#'), array('id' => 'tf_template_admin_menu_options', 'parent' => 'tf_template_admin_menu', 'title' => __('Template Options', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_template_admin_menu_options')), array('id' => 'tf_template_admin_menu_global_styling', 'parent' => 'tf_template_admin_menu', 'title' => __('Global Styling', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_load_global_styling')), array('id' => 'tf_template_admin_menu_export', 'parent' => 'tf_template_admin_menu', 'title' => __('Export', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_template_admin_menu_export')), array('id' => 'tf_template_admin_menu_import', 'parent' => 'tf_template_admin_menu', 'title' => __('Replace (Import)', 'themify-flow'), 'href' => '#', 'meta' => array('class' => 'tf_template_admin_menu_import'))); if (TF_Model::is_tf_styling_active()) { unset($args[1]); unset($args[3]); unset($args[4]); } else { if (!is_singular($this->post_type)) { $args = array(); } } foreach ($args as $arg) { $wp_admin_bar->add_node($arg); } }
/** * Add admin bar menu users items * * @since 1.5 * @access public * @see 'vaa_admin_bar_menu' action * @param object $admin_bar * @return void */ public function admin_bar_menu_users($admin_bar) { if ($this->get_users() && 0 < count($this->get_users())) { $admin_bar->add_group(array('id' => 'users', 'parent' => 'view-as', 'meta' => array('class' => 'ab-sub-secondary'))); $admin_bar->add_node(array('id' => 'users-title', 'parent' => 'users', 'title' => self::do_icon('dashicons-admin-users') . __('Users', 'view-admin-as'), 'href' => false, 'meta' => array('class' => 'vaa-has-icon ab-vaa-title ab-vaa-toggle active'))); /** * Add items at the beginning of the users group * @see 'admin_bar_menu' action * @link https://codex.wordpress.org/Class_Reference/WP_Admin_Bar */ do_action('vaa_admin_bar_users_before', $admin_bar); if (true === $this->searchUsers) { $admin_bar->add_node(array('id' => 'searchuser', 'parent' => 'users', 'title' => '<input id="search" name="vaa-search" placeholder="' . esc_attr__('Search', 'view-admin-as') . ' (' . strtolower(__('Username', 'view-admin-as')) . ')" />', 'href' => false, 'meta' => array('class' => 'ab-vaa-search search-users', 'html' => '<ul id="vaa-searchuser-results" class="ab-sub-secondary ab-submenu"></ul>'))); } // Add the users foreach ($this->get_users() as $user_key => $user) { $href = '#'; $title = $user->data->display_name; $class = 'vaa-user-item'; // Check if this user is the current view if ($this->get_viewAs('user') && $this->get_viewAs('user') == $user->data->ID) { $class .= ' current'; $href = false; } $parent = 'users'; if (true === $this->groupUserRoles) { // Users grouped under roles foreach ($user->roles as $role) { $parent = 'role-' . $role; $admin_bar->add_node(array('id' => 'user-' . $user->data->ID . '-' . $role, 'parent' => $parent, 'title' => $title, 'href' => $href, 'meta' => array('title' => esc_attr__('View as', 'view-admin-as') . ' ' . $user->data->display_name, 'class' => $class, 'rel' => $user->data->ID))); } } else { // Users displayed as normal $all_roles = $this->get_roles(); $user_roles = array(); // Add the roles of this user in the name foreach ($user->roles as $role) { $user_roles[] = translate_user_role($all_roles[$role]->name); } $title = $title . ' <span class="user-role">(' . implode(', ', $user_roles) . ')</span>'; $admin_bar->add_node(array('id' => 'user-' . $user->data->ID, 'parent' => $parent, 'title' => $title, 'href' => $href, 'meta' => array('title' => esc_attr__('View as', 'view-admin-as') . ' ' . $user->data->display_name, 'class' => $class, 'rel' => $user->data->ID))); } } /** * Add items at the end of the users group * @see 'admin_bar_menu' action * @link https://codex.wordpress.org/Class_Reference/WP_Admin_Bar */ do_action('vaa_admin_bar_users_after', $admin_bar); } }
/** * Add admin bar menu's * * * @since 1.4 * @since 1.5.2 Changed hook to vaa_admin_bar_settings_after (previous: 'vaa_admin_bar_roles_before') * @access public * @see 'vaa_admin_bar_settings_after' action * * @param object $admin_bar * @return void */ public function admin_bar_menu($admin_bar) { $admin_bar->add_node(array('id' => 'role-defaults', 'parent' => 'view-as', 'title' => VAA_View_Admin_As_Admin_Bar::do_icon('dashicons-id-alt') . __('Role defaults', 'view-admin-as'), 'href' => false, 'meta' => array('class' => 'vaa-has-icon'))); $role_select_options = ''; foreach ($this->get_roles() as $role_key => $role) { $role_select_options .= '<option value="' . esc_attr($role_key) . '">' . translate_user_role($role->name) . '</option>'; } $admin_bar->add_node(array('id' => 'role-defaults-setting-register-enable', 'parent' => 'role-defaults', 'title' => '<input class="checkbox" value="1" id="vaa_role_defaults_register_enable" name="vaa_role_defaults_register_enable" type="checkbox" ' . checked($this->get_optionData('apply_defaults_on_register'), true, false) . '> <label for="vaa_role_defaults_register_enable">' . __('Automatically apply defaults to new users', 'view-admin-as') . '</label>', 'href' => false, 'meta' => array('class' => 'auto-height'))); $admin_bar->add_node(array('id' => 'role-defaults-setting-disable-user-screen-options', 'parent' => 'role-defaults', 'title' => '<input class="checkbox" value="1" id="vaa_role_defaults_disable_user_screen_options" name="vaa_role_defaults_disable_user_screen_options" type="checkbox" ' . checked($this->get_optionData('disable_user_screen_options'), true, false) . '> <label for="vaa_role_defaults_disable_user_screen_options">' . __('Disable screen options', 'view-admin-as') . '</label> <p class="description ab-item">' . __("Hide the screen options for all users who can't access role defaults", 'view-admin-as') . '</p>', 'href' => false, 'meta' => array('class' => 'auto-height'))); $admin_bar->add_node(array('id' => 'role-defaults-setting-lock-meta-boxes', 'parent' => 'role-defaults', 'title' => '<input class="checkbox" value="1" id="vaa_role_defaults_lock_meta_boxes" name="vaa_role_defaults_lock_meta_boxes" type="checkbox" ' . checked($this->get_optionData('lock_meta_boxes'), true, false) . '> <label for="vaa_role_defaults_lock_meta_boxes">' . __('Lock meta boxes', 'view-admin-as') . '</label> <p class="description ab-item">' . __("Lock meta box order and locations for all users who can't access role defaults", 'view-admin-as') . '</p>', 'href' => false, 'meta' => array('class' => 'auto-height'))); /** * Bulk actions */ if ($this->get_users()) { // Users select $admin_bar->add_group(array('id' => 'role-defaults-bulk-users', 'parent' => 'role-defaults', 'meta' => array('class' => 'ab-sub-secondary'))); $admin_bar->add_node(array('id' => 'role-defaults-bulk-users-title', 'parent' => 'role-defaults-bulk-users', 'title' => __('Apply defaults to users', 'view-admin-as'), 'href' => false, 'meta' => array('class' => 'ab-bold ab-vaa-toggle'))); $admin_bar->add_node(array('id' => 'role-defaults-bulk-users-filter', 'parent' => 'role-defaults-bulk-users', 'title' => '<input id="role-defaults-bulk-users-filter" name="vaa-filter" placeholder="' . esc_attr__('Filter', 'view-admin-as') . ' (' . strtolower(__('Username')) . ')" />', 'href' => false, 'meta' => array('class' => 'ab-vaa-filter'))); $bulk_users_select_content = ''; foreach ($this->get_users() as $user) { foreach ($user->roles as $role) { if ($role_data = $this->get_roles($role)) { $role_name = translate_user_role($role_data->name); $bulk_users_select_content .= '<div class="ab-item vaa-item"> <input class="checkbox" value="' . $user->ID . '|' . $role . '" id="role-defaults-bulk-users-select-' . $user->ID . '" name="role-defaults-bulk-users-select[]" type="checkbox"> <label for="role-defaults-bulk-users-select-' . $user->ID . '"><span class="user-name">' . $user->display_name . '</span> <span class="user-role">(' . $role_name . ')</span></label> </div>'; } } } $admin_bar->add_node(array('id' => 'role-defaults-bulk-users-select', 'parent' => 'role-defaults-bulk-users', 'title' => $bulk_users_select_content, 'href' => false, 'meta' => array('class' => 'ab-vaa-multipleselect max-height'))); $admin_bar->add_node(array('id' => 'role-defaults-bulk-users-apply', 'parent' => 'role-defaults-bulk-users', 'title' => '<button id="role-defaults-bulk-users-apply" class="button button-primary" name="role-defaults-bulk-users-apply">' . __('Apply', 'view-admin-as') . '</button>', 'href' => false, 'meta' => array('class' => 'vaa-button-container', 'html' => ''))); } if ($this->get_users() && $this->get_roles()) { // Roles select $admin_bar->add_group(array('id' => 'role-defaults-bulk-roles', 'parent' => 'role-defaults', 'meta' => array('class' => 'ab-sub-secondary'))); $admin_bar->add_node(array('id' => 'role-defaults-bulk-roles-title', 'parent' => 'role-defaults-bulk-roles', 'title' => __('Apply defaults to users by role', 'view-admin-as'), 'href' => false, 'meta' => array('class' => 'ab-bold ab-vaa-toggle'))); $admin_bar->add_node(array('id' => 'role-defaults-bulk-roles-select', 'parent' => 'role-defaults-bulk-roles', 'title' => '<select id="role-defaults-bulk-roles-select" name="role-defaults-bulk-roles-select"><option value=""> --- </option><option value="all">' . __('All roles', 'view-admin-as') . '</option>' . $role_select_options . '</select>', 'href' => false, 'meta' => array('class' => 'ab-vaa-select select-role', 'html' => ''))); $admin_bar->add_node(array('id' => 'role-defaults-bulk-roles-apply', 'parent' => 'role-defaults-bulk-roles', 'title' => '<button id="role-defaults-bulk-roles-apply" class="button button-primary" name="role-defaults-bulk-roles-apply">' . __('Apply', 'view-admin-as') . '</button>', 'href' => false, 'meta' => array('class' => 'vaa-button-container', 'html' => ''))); } if ($this->get_roles()) { /* Export actions */ $admin_bar->add_group(array('id' => 'role-defaults-export', 'parent' => 'role-defaults', 'meta' => array('class' => 'ab-sub-secondary'))); $admin_bar->add_node(array('id' => 'role-defaults-export-roles', 'parent' => 'role-defaults-export', 'title' => __('Export defaults for role', 'view-admin-as'), 'href' => false, 'meta' => array('class' => 'ab-bold ab-vaa-toggle'))); $admin_bar->add_node(array('id' => 'role-defaults-export-roles-select', 'parent' => 'role-defaults-export', 'title' => '<select id="role-defaults-export-roles-select" name="role-defaults-export-roles-select"><option value="all">' . __('All roles', 'view-admin-as') . '</option>' . $role_select_options . '</select>', 'href' => false, 'meta' => array('class' => 'ab-vaa-select select-role', 'html' => ''))); $admin_bar->add_node(array('id' => 'role-defaults-export-roles-export', 'parent' => 'role-defaults-export', 'title' => '<button id="role-defaults-export-roles-export" class="button button-secondary" name="role-defaults-export-roles-export">' . __('Export', 'view-admin-as') . '</button>', 'href' => false, 'meta' => array('class' => 'vaa-button-container', 'html' => ''))); /* Import actions */ $admin_bar->add_group(array('id' => 'role-defaults-import', 'parent' => 'role-defaults', 'meta' => array('class' => 'ab-sub-secondary'))); $admin_bar->add_node(array('id' => 'role-defaults-import-roles', 'parent' => 'role-defaults-import', 'title' => __('Import defaults for role', 'view-admin-as'), 'href' => false, 'meta' => array('class' => 'ab-bold ab-vaa-toggle'))); $admin_bar->add_node(array('id' => 'role-defaults-import-roles-input', 'parent' => 'role-defaults-import', 'title' => '<textarea id="role-defaults-import-roles-input" name="role-defaults-import-roles-input" placeholder="' . esc_attr__('Paste code here', 'view-admin-as') . '"></textarea>', 'href' => false, 'meta' => array('class' => 'ab-vaa-textarea input-role', 'html' => ''))); $admin_bar->add_node(array('id' => 'role-defaults-import-roles-import', 'parent' => 'role-defaults-import', 'title' => '<button id="role-defaults-import-roles-import" class="button button-secondary" name="role-defaults-import-roles-import">' . __('Import', 'view-admin-as') . '</button>', 'href' => false, 'meta' => array('class' => 'vaa-button-container', 'html' => ''))); /* Clear actions */ $admin_bar->add_group(array('id' => 'role-defaults-clear', 'parent' => 'role-defaults', 'meta' => array('class' => 'ab-sub-secondary vaa-sub-transparent'))); $admin_bar->add_node(array('id' => 'role-defaults-clear-roles', 'parent' => 'role-defaults-clear', 'title' => __('Remove defaults for role', 'view-admin-as'), 'href' => false, 'meta' => array('class' => 'ab-bold ab-vaa-toggle'))); $admin_bar->add_node(array('id' => 'role-defaults-clear-roles-select', 'parent' => 'role-defaults-clear', 'title' => '<select id="role-defaults-clear-roles-select" name="role-defaults-clear-roles-select"><option value=""> --- </option><option value="all">' . __('All roles', 'view-admin-as') . '</option>' . $role_select_options . '</select>', 'href' => false, 'meta' => array('class' => 'ab-vaa-select select-role', 'html' => ''))); $admin_bar->add_node(array('id' => 'role-defaults-clear-roles-apply', 'parent' => 'role-defaults-clear', 'title' => '<button id="role-defaults-clear-roles-apply" class="button button-secondary" name="role-defaults-clear-roles-apply">' . __('Apply', 'view-admin-as') . '</button>', 'href' => false, 'meta' => array('class' => 'vaa-button-container', 'html' => ''))); } }
/** * adds a new subnode to the basenode. * * will return a reference to it for further processing. * * @access public * @param string $nodename name of the new node * @param string $id id of the new node * @return object */ function &add_node($nodename, $id = '') { return $this->basenode->add_node($nodename, $id); }
/** * Add a menu to the WP admin toolbar * * @since 1.7 * @param object $wp_admin_bar */ public function admin_toolbar_menu($wp_admin_bar) { // Only display VFB toolbar if on a page with the shortcode if (!is_admin() && current_user_can('vfb_edit_forms')) { global $post; // If no post, exit if (!$post) { return; } $post_to_check = get_post(get_the_ID()); // Finds content with the vfb shortcode if (stripos($post_to_check->post_content, '[vfb') !== false) { preg_match_all('/id=[\'"]?(\\d+)[\'"]?/', $post_to_check->post_content, $matches); // If more than one form, display a new toolbar item with dropdown if (count($matches[1]) > 1) { global $wpdb; $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_edit_main', 'title' => 'Edit Forms', 'parent' => false, 'href' => admin_url('admin.php?page=visual-form-builder-pro'))); // Loop through the forms foreach ($matches[1] as $form_id) { $name = $wpdb->get_var($wpdb->prepare("SELECT form_title FROM {$this->form_table_name} WHERE form_id = %d", $form_id)); $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_edit_' . $form_id, 'title' => 'Edit ' . stripslashes($name), 'parent' => 'vfb_admin_toolbar_edit_main', 'href' => admin_url('admin.php?page=visual-form-builder-pro&action=edit&form=' . $form_id))); } } else { // A new toolbar item $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_edit_main', 'title' => 'Edit Form', 'parent' => false, 'href' => admin_url('admin.php?page=visual-form-builder-pro&action=edit&form=' . $matches[1][0]))); // An item added to the main VFB Pro menu $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_edit', 'title' => 'Edit Form', 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=visual-form-builder-pro&action=edit&form=' . $matches[1][0]))); } } } // Entire menu will be hidden if user does not have vfb_edit_forms cap if (isset($_REQUEST['page']) && in_array($_REQUEST['page'], array('visual-form-builder-pro')) && isset($_REQUEST['form']) && current_user_can('vfb_edit_forms')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_preview_form', 'title' => 'Preview Form', 'parent' => false, 'href' => esc_url(add_query_arg(array('form' => $_REQUEST['form'], 'preview' => 1), plugins_url('visual-form-builder-pro/form-preview.php'))), 'meta' => array('target' => '_blank'))); } // Entire menu will be hidden if user does not have vfb_edit_forms cap if (current_user_can('vfb_edit_forms')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar', 'title' => 'VFB Pro', 'parent' => false, 'href' => admin_url('admin.php?page=visual-form-builder-pro'))); } // Add New Form if (current_user_can('vfb_create_forms')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_add', 'title' => __('Add New Form', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-add-new'))); } // Entries if (current_user_can('vfb_view_entries')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_entries', 'title' => __('Entries', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-entries'))); } // Email Design if (current_user_can('vfb_edit_email_design')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_email', 'title' => __('Email Design', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-email-design'))); } // Analytics if (current_user_can('vfb_view_analytics')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_analytics', 'title' => __('Analytics', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-reports'))); } // Import if (current_user_can('vfb_import_forms')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_import', 'title' => __('Import', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-import'))); } // Export if (current_user_can('vfb_export_forms')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_export', 'title' => __('Export', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-export'))); } // Settings if (current_user_can('vfb_edit_settings')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_settings', 'title' => __('Settings', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-settings'))); } // Payments if (class_exists('VFB_Pro_Payments') && current_user_can('vfb_edit_forms')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_payments', 'title' => __('Payments', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-payments'))); } // Display Entries if (class_exists('VFB_Pro_Display_Entries') && current_user_can('vfb_edit_entries')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_display_entries', 'title' => __('Display Entries', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-addon-display-entries'))); } // Form Designer if (class_exists('VFB_Pro_Form_Designer') && current_user_can('vfb_edit_email_design')) { $wp_admin_bar->add_node(array('id' => 'vfb_admin_toolbar_form_designer', 'title' => __('Form Design', 'visual-form-builder-pro'), 'parent' => 'vfb_admin_toolbar', 'href' => admin_url('admin.php?page=vfb-addon-form-design'))); } }
/** * Registers the admin bar menu. * * @param object $wp_admin_bar * @return void */ function register_menu($wp_admin_bar) { $wp_admin_bar->add_node(array('id' => 'hook-flowchart', 'title' => 'Hook FlowChart', 'href' => '#')); }
/** * Adds the RQC node to the admin bar. * * @since 0.1.0 * @access private * * @param object $wp_admin_bar The admin bar object. */ function add_admin_bar_node($wp_admin_bar) { // Do not allow anyone aside from the admin to use this if ($this->current_role != 'administrator') { return; } $args = array('id' => 'rqc', 'title' => 'Role Quick Change', 'href' => '#'); $wp_admin_bar->add_node($args); }
/** * Registers the admin bar menu. * * @param object $wp_admin_bar * @return void */ function register_menu($wp_admin_bar) { $uri = plugins_url('assets/images/hookr-white.svg', HOOKR_PLUGIN_FILE); $wp_admin_bar->add_node(array('id' => $this->get_slug(), 'title' => sprintf('<img src="%s" />', $uri), 'href' => admin_url('tools.php?page=' . $this->get_slug()), 'meta' => array('title' => 'Click for additional settings'))); if ($this->is_enabled() && !$this->is_tools_page()) { $wp_admin_bar->add_node(array('parent' => $this->get_slug(), 'id' => sprintf('%s-search', $this->get_slug()), 'title' => '<input type="search" placeholder="Filter the things …" />')); } if (!is_admin()) { $wp_admin_bar->add_node(array('parent' => $this->get_slug(), 'id' => sprintf('%s-enabled', $this->get_slug()), 'title' => $this->get_render('fields/enable', array('settings' => (object) $this->get_settings())))); } }
/** * Add link to agent's tickets. * * @since 3.0.0 * @param object $wp_admin_bar The WordPress toolbar object * @return void */ public function toolbar_tickets_link($wp_admin_bar) { if (!current_user_can('edit_ticket')) { return; } $hide = boolval(wpas_get_option('hide_closed')); $args = array('post_type' => 'ticket'); if (true === $hide) { $args['wpas_status'] = 'open'; } $args = array('id' => 'wpas_tickets', 'title' => __('My Tickets', 'wpas'), 'href' => add_query_arg($args, admin_url('edit.php')), 'meta' => array('class' => 'wpas-my-tickets')); $wp_admin_bar->add_node($args); }
/** * Add 'Hits' section to admin bar on frontend for single posts * @param object $wp_admin_bar WordPress admin bar object * @return void */ public function display_post_views_admin_bar($wp_admin_bar) { if (is_single() || is_page()) { global $post; if (isset($post->ID)) { if ($this->count_post_type($post->post_type)) { $views = intval(get_post_meta($post->ID, $this->_field, true)); $args = array('id' => 'hit_counter', 'title' => sprintf(_n('1 Hit', '%s Hits', $views, 'post-hit-counter'), $views), 'href' => admin_url('options-general.php?page=post_hit_counter_settings'), 'meta' => array('class' => 'hit-counter', 'title' => __('Post Hit Counter settings', 'post-hit-counter'))); $wp_admin_bar->add_node($args); } } } }