WP_Navigation_Block_Renderer::get_navigation_name()
Gets the name of the current navigation, if it has one.
Метод класса: WP_Navigation_Block_Renderer{}
Хуков нет.
Возвращает
Строку
. Returns the name of the navigation.
Использование
$result = WP_Navigation_Block_Renderer::get_navigation_name( $attributes );
- $attributes(массив) (обязательный)
- The block attributes.
Список изменений
С версии 6.5.0 | Введена. |
Код WP_Navigation_Block_Renderer::get_navigation_name() WP Navigation Block Renderer::get navigation name WP 6.7.1
private static function get_navigation_name( $attributes ) { $navigation_name = $attributes['ariaLabel'] ?? ''; // Load the navigation post. if ( array_key_exists( 'ref', $attributes ) ) { $navigation_post = get_post( $attributes['ref'] ); if ( ! isset( $navigation_post ) ) { return $navigation_name; } // Only published posts are valid. If this is changed then a corresponding change // must also be implemented in `use-navigation-menu.js`. if ( 'publish' === $navigation_post->post_status ) { $navigation_name = $navigation_post->post_title; // This is used to count the number of times a navigation name has been seen, // so that we can ensure every navigation has a unique id. if ( isset( static::$seen_menu_names[ $navigation_name ] ) ) { ++static::$seen_menu_names[ $navigation_name ]; } else { static::$seen_menu_names[ $navigation_name ] = 1; } } } return $navigation_name; }