WordPress.org

Make WordPress Core

Ticket #24100: 24100.patch

File 24100.patch, 904 bytes (added by Clorith, 5 years ago)
  • nav-menu-template.php

     
    246246                $nav_menu .= '</' . $args->container . '>';
    247247
    248248        $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
     249   
     250    //  Filter out first/last occurrence of the before or after arguments
     251    $nav_menu = preg_replace( '/' . preg_quote( $args->before ) . '/', '', $nav_menu, 1 );
     252    $nav_menu = preg_replace( '/' . preg_quote( $args->link_before ) . '/', '', $nav_menu, 1 );
     253    $nav_menu = preg_replace( '/' . preg_quote( $args->after ) . '(?!.*' . preg_quote( $args->after ) . ')/', '', $nav_menu, 1 );
     254    $nav_menu = preg_replace( '/' . preg_quote( $args->link_after ) . '(?!.*' . preg_quote( $args->link_after ) . ')/', '', $nav_menu, 1 );
    249255
    250256        if ( $args->echo )
    251257                echo $nav_menu;