WordPress.org

Make WordPress Core

Ticket #23627: pre_wp_nav_menu-2.23627.diff

File pre_wp_nav_menu-2.23627.diff, 686 bytes (added by kasparsd, 5 years ago)

Use WP coding standards, return on echo.

  • wp-includes/nav-menu-template.php

    diff --git wp-includes/nav-menu-template.php wp-includes/nav-menu-template.php
    index 7aceb8f..87a1ce8 100644
    function wp_nav_menu( $args = array() ) { 
    231231        $args = apply_filters( 'wp_nav_menu_args', $args );
    232232        $args = (object) $args;
    233233
     234        // Allow plugins to short-circuit menu output
     235        $nav_menu = apply_filters( 'pre_wp_nav_menu', null, $args );
     236
     237        if ( ! empty( $nav_menu ) && $args->echo ) {
     238                echo $nav_menu;
     239                return;
     240        } elseif ( ! empty( $nav_menu ) ) {
     241                return $nav_menu;
     242        }
     243
    234244        // Get the nav menu based on the requested menu
    235245        $menu = wp_get_nav_menu_object( $args->menu );
    236246