
如何清除/刷新DNS缓存(Windows,Mac,Linux)
block_core_navigation_get_fallback_blocks ( No parameters )
block_core_navigation_get_fallback_blocks: 这个函数是用来获取导航块的后备块: 当没有导航块项目需要显示时,它就会被使用。
检索适当的回退,以便在没有为导航块分配菜单的情况下在网站前面使用。
这旨在反映wp_nav_menu的后退机制是如何工作的。见https://developer.wordpress.org/reference/functions/wp_nav_menu/#more-information。
function block_core_navigation_get_fallback_blocks() { $page_list_fallback = array( array( 'blockName' => 'core/page-list', ), ); $registry = WP_Block_Type_Registry::get_instance(); // If `core/page-list` is not registered then return empty blocks. $fallback_blocks = $registry->is_registered( 'core/page-list' ) ? $page_list_fallback : array(); // Default to a list of Pages. $navigation_post = block_core_navigation_get_most_recently_published_navigation(); // Prefer using the first non-empty Navigation as fallback if available. if ( $navigation_post ) { $maybe_fallback = block_core_navigation_filter_out_empty_blocks( parse_blocks( $navigation_post->post_content ) ); // Normalizing blocks may result in an empty array of blocks if they were all `null` blocks. // In this case default to the (Page List) fallback. $fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks; } /** * Filters the fallback experience for the Navigation block. * * Returning a falsey value will opt out of the fallback and cause the block not to render. * To customise the blocks provided return an array of blocks - these should be valid * children of the `core/navigation` block. * * @since 5.9.0 * * @param array[] default fallback blocks provided by the default block mechanic. */ return apply_filters( 'block_core_navigation_render_fallback', $fallback_blocks ); }