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:
Dominik Schilling 2015-06-14 17:37:25 +00:00
parent 8dcd236ba3
commit df11970e18
2 changed files with 22 additions and 11 deletions

View File

@ -16,21 +16,32 @@
* @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 ) {
if ( ! $menu )
return false;
$menu_obj = false;
if ( $menu ) {
$menu_obj = get_term( $menu, 'nav_menu' );
$menu_obj = get_term( $menu, 'nav_menu' );
if ( ! $menu_obj ) {
$menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );
}
if ( ! $menu_obj )
$menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );
if ( ! $menu_obj ) {
$menu_obj = get_term_by( 'name', $menu, 'nav_menu' );
}
}
if ( ! $menu_obj )
$menu_obj = get_term_by( 'name', $menu, 'nav_menu' );
if ( ! $menu_obj )
if ( ! $menu_obj || is_wp_error( $menu_obj ) ) {
$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 );
}
/**

View File

@ -4,7 +4,7 @@
*
* @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.