WP_Navigation_Fallback::get_fallback()
Gets (and/or creates) an appropriate fallback Navigation Menu.
Метод класса: WP_Navigation_Fallback{}
Хуки из метода
Возвращает
WP_Post|null
. the fallback Navigation Post or null.
Использование
$result = WP_Navigation_Fallback::get_fallback();
Список изменений
С версии 6.3.0 | Введена. |
Код WP_Navigation_Fallback::get_fallback() WP Navigation Fallback::get fallback WP 6.6.2
public static function get_fallback() { /** * Filters whether or not a fallback should be created. * * @since 6.3.0 * * @param bool $create Whether to create a fallback navigation menu. Default true. */ $should_create_fallback = apply_filters( 'wp_navigation_should_create_fallback', true ); $fallback = static::get_most_recently_published_navigation(); if ( $fallback || ! $should_create_fallback ) { return $fallback; } $fallback = static::create_classic_menu_fallback(); if ( $fallback && ! is_wp_error( $fallback ) ) { // Return the newly created fallback post object which will now be the most recently created navigation menu. return $fallback instanceof WP_Post ? $fallback : static::get_most_recently_published_navigation(); } $fallback = static::create_default_fallback(); if ( $fallback && ! is_wp_error( $fallback ) ) { // Return the newly created fallback post object which will now be the most recently created navigation menu. return $fallback instanceof WP_Post ? $fallback : static::get_most_recently_published_navigation(); } return null; }