Editor: opt out of Navigation fallback.

Allows developers to opt out of the auto-creation of the Navigation fallback through a filter.

Props get_dave, spacedmonkey, ramonopoly.
Fixes #58750.


git-svn-id: https://develop.svn.wordpress.org/trunk@56202 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Isabel Brison
2023-07-11 05:39:33 +00:00
parent eea94adc54
commit a02886a868
2 changed files with 30 additions and 1 deletions

View File

@@ -26,9 +26,18 @@ class WP_Navigation_Fallback {
*/
public static function get_fallback() {
/**
* Filters whether or not a fallback should be created.
*
* @since 6.3.0
*
* @param bool 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 ) {
if ( $fallback || ! $should_create_fallback ) {
return $fallback;
}