Nav menus: Introduce a `wp_get_nav_menu_object` filter in `wp_get_nav_menu_object()` to filter the retrieved nav_menu term.
props westonruter. fixes #32629. Built from https://develop.svn.wordpress.org/trunk@32764 git-svn-id: http://core.svn.wordpress.org/trunk@32735 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8dcd236ba3
commit
df11970e18
|
@ -16,21 +16,32 @@
|
||||||
* @return object|false False if $menu param isn't supplied or term does not exist, menu object if successful.
|
* @return object|false False if $menu param isn't supplied or term does not exist, menu object if successful.
|
||||||
*/
|
*/
|
||||||
function wp_get_nav_menu_object( $menu ) {
|
function wp_get_nav_menu_object( $menu ) {
|
||||||
if ( ! $menu )
|
$menu_obj = false;
|
||||||
return false;
|
if ( $menu ) {
|
||||||
|
|
||||||
$menu_obj = get_term( $menu, 'nav_menu' );
|
$menu_obj = get_term( $menu, 'nav_menu' );
|
||||||
|
|
||||||
if ( ! $menu_obj )
|
if ( ! $menu_obj ) {
|
||||||
$menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );
|
$menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $menu_obj )
|
if ( ! $menu_obj ) {
|
||||||
$menu_obj = get_term_by( 'name', $menu, 'nav_menu' );
|
$menu_obj = get_term_by( 'name', $menu, 'nav_menu' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $menu_obj )
|
if ( ! $menu_obj || is_wp_error( $menu_obj ) ) {
|
||||||
$menu_obj = false;
|
$menu_obj = false;
|
||||||
|
}
|
||||||
|
|
||||||
return $menu_obj;
|
/**
|
||||||
|
* Filter the nav_menu term retrieved for wp_get_nav_menu_object().
|
||||||
|
*
|
||||||
|
* @since 4.3.0
|
||||||
|
*
|
||||||
|
* @param object|false $menu_obj Term from nav_menu taxonomy, or false if nothing had been found.
|
||||||
|
* @param string $menu The menu ID, slug, or name passed to wp_get_nav_menu_object().
|
||||||
|
*/
|
||||||
|
return apply_filters( 'wp_get_nav_menu_object', $menu_obj, $menu );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-alpha-32763';
|
$wp_version = '4.3-alpha-32764';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue