Make WordPress Core

Changeset 34666


Ignore:
Timestamp:
09/28/2015 06:40:56 PM (9 years ago)
Author:
johnbillion
Message:

Add a nav_menu_item_title filter for filtering nav menu item titles.

Fixes #33447
Props paulwilde

File:
1 edited

Legend:

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

    r34630 r34666  
    161161        }
    162162
     163        /** This filter is documented in wp-includes/post-template.php */
     164        $title = apply_filters( 'the_title', $item->title, $item->ID );
     165
     166        /**
     167         * Filter a menu item's title.
     168         *
     169         * @since 4.4.0
     170         *
     171         * @param string $title The menu item's title.
     172         * @param object $item  The current menu item.
     173         * @param array  $args  An array of {@see wp_nav_menu()} arguments.
     174         * @param int    $depth Depth of menu item. Used for padding.
     175         */
     176        $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
     177
    163178        $item_output = $args->before;
    164179        $item_output .= '<a'. $attributes .'>';
    165         /** This filter is documented in wp-includes/post-template.php */
    166         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
     180        $item_output .= $args->link_before . $title . $args->link_after;
    167181        $item_output .= '</a>';
    168182        $item_output .= $args->after;
Note: See TracChangeset for help on using the changeset viewer.