Make WordPress Core

Changeset 27386


Ignore:
Timestamp:
03/03/2014 08:42:21 PM (12 years ago)
Author:
helen
Message:

Add the ability to short-circuit wp_nav_menu() via the pre_wp_nav_menu hook. props kasparsd, DrewAPicture, Rarst. fixes #23627.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu-template.php

    r27262 r27386  
    246246        $args = (object) $args;
    247247
     248        /**
     249         * Filter whether to short-circuit the wp_nav_menu() output.
     250         *
     251         * Returning a non-null value to the filter will short-circuit
     252         * wp_nav_menu(), echoing that value if $args->echo is true,
     253         * returning that value otherwise.
     254         *
     255         * @since 3.9.0
     256         *
     257         * @see wp_nav_menu()
     258         *
     259         * @param string|null $output Nav menu output to short-circuit with. Default null.
     260         * @param object      $args   An object containing wp_nav_menu() arguments.
     261         */
     262        $nav_menu = apply_filters( 'pre_wp_nav_menu', null, $args );
     263
     264        if ( null !== $nav_menu ) {
     265                if ( $args->echo ) {
     266                        echo $nav_menu;
     267                        return;
     268                }
     269
     270                return $nav_menu;
     271        }
     272
    248273        // Get the nav menu based on the requested menu
    249274        $menu = wp_get_nav_menu_object( $args->menu );
Note: See TracChangeset for help on using the changeset viewer.