WPSEO_Admin_Bar_Menu::add_root_menu()
Adds the admin bar root menu.
Метод класса: WPSEO_Admin_Bar_Menu{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->add_root_menu( $wp_admin_bar );
- $wp_admin_bar(WP_Admin_Bar) (обязательный)
- Admin bar instance to add the menu to.
Код WPSEO_Admin_Bar_Menu::add_root_menu() WPSEO Admin Bar Menu::add root menu Yoast 22.4
protected function add_root_menu( WP_Admin_Bar $wp_admin_bar ) { $title = $this->get_title(); $score = ''; $settings_url = ''; $counter = ''; $notification_popup = ''; $post = $this->get_singular_post(); if ( $post ) { $score = $this->get_post_score( $post ); } $term = $this->get_singular_term(); if ( $term ) { $score = $this->get_term_score( $term ); } $can_manage_options = $this->can_manage_options(); if ( $can_manage_options ) { $settings_url = $this->get_settings_page_url(); } if ( empty( $score ) && ! is_network_admin() && $can_manage_options ) { $counter = $this->get_notification_counter(); $notification_popup = $this->get_notification_popup(); } $admin_bar_menu_args = [ 'id' => self::MENU_IDENTIFIER, 'title' => $title . $score . $counter . $notification_popup, 'href' => $settings_url, 'meta' => [ 'tabindex' => ! empty( $settings_url ) ? false : '0' ], ]; $wp_admin_bar->add_menu( $admin_bar_menu_args ); if ( ! empty( $counter ) ) { $admin_bar_menu_args = [ 'parent' => self::MENU_IDENTIFIER, 'id' => 'wpseo-notifications', 'title' => __( 'Notifications', 'wordpress-seo' ) . $counter, 'href' => $settings_url, 'meta' => [ 'tabindex' => ! empty( $settings_url ) ? false : '0' ], ]; $wp_admin_bar->add_menu( $admin_bar_menu_args ); } }