Ticket #25229: nav-menu-template.2.diff
File nav-menu-template.2.diff, 5.4 KB (added by , 11 years ago) |
---|
-
nav-menu-template.php
72 72 $classes = empty( $item->classes ) ? array() : (array) $item->classes; 73 73 $classes[] = 'menu-item-' . $item->ID; 74 74 75 /** 76 * Filter the CSS class(es) applied to a menu item's <li>. 77 * 78 * @since 3.0.0 79 * 80 * @param array $classes The CSS classes that are applied to the menu item's <li>. 81 * @param object $item The current menu item. 82 * @param array $args Arguments from {@see wp_nav_menu()}. 83 */ 75 84 $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); 76 85 $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; 77 86 87 /** 88 * Filter the ID applied to a menu item's <li>. 89 * 90 * @since 3.0.1 91 * 92 * @param string The ID that is applied to the menu item's <li>. 93 * @param object $item The current menu item. 94 * @param array $args Arguments from {@see wp_nav_menu()}. 95 */ 78 96 $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args ); 79 97 $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; 80 98 … … 86 104 $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; 87 105 $atts['href'] = ! empty( $item->url ) ? $item->url : ''; 88 106 107 /** 108 * Filter the HTML attributes applied to a menu item's <a>. 109 * 110 * @since 3.6.0 111 * 112 * @param array $atts { 113 * The HTML attributes applied to the menu item's <a>, empty strings are ignored. 114 * 115 * @type string $title The title attribute. 116 * @type string $target The target attribute. 117 * @type string $rel The rel attribute. 118 * @type string $href The href attribute. 119 * } 120 * @param object $item The current menu item. 121 * @param array $args Arguments from {@see wp_nav_menu()}. 122 */ 89 123 $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ); 90 124 91 125 $attributes = ''; … … 98 132 99 133 $item_output = $args->before; 100 134 $item_output .= '<a'. $attributes .'>'; 135 //duplicate_hook 101 136 $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; 102 137 $item_output .= '</a>'; 103 138 $item_output .= $args->after; 104 139 140 /** 141 * Filter a menu item's starting output. 142 * 143 * The menu item's starting output only includes $args->before, the opening <a>, 144 * the menu item's title, the closing </a>, and $args->after. Currently, there is 145 * no filter for modifying the opening and closing <li> for a menu item. 146 * 147 * @since 3.0.0 148 * 149 * @param string The menu item's starting HTML output. 150 * @param object $item The current menu item. 151 * @param int $depth From {@see Walker_Nav_Menu::start_el}. 152 * @param array $args Arguments from {@see wp_nav_menu()}. 153 */ 105 154 $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); 106 155 } 107 156 … … 152 201 'depth' => 0, 'walker' => '', 'theme_location' => '' ); 153 202 154 203 $args = wp_parse_args( $args, $defaults ); 204 /** 205 * Filter the arguments used to display a navigation menu. 206 * 207 * @since 3.0.0 208 * 209 * @param array $args Arguments from {@see wp_nav_menu()}. 210 */ 155 211 $args = apply_filters( 'wp_nav_menu_args', $args ); 156 212 $args = (object) $args; 157 213 … … 196 252 197 253 $show_container = false; 198 254 if ( $args->container ) { 255 /** 256 * Filter the list of HTML tags that are valid for use as menu containers. 257 * 258 * @since 3.0.0 259 * 260 * @param array The acceptable HTML tags for use as menu containers, defaults as 'div' and 'nav'. 261 */ 199 262 $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ); 200 263 if ( in_array( $args->container, $allowed_tags ) ) { 201 264 $show_container = true; … … 214 277 215 278 unset($menu_items); 216 279 280 /** 281 * Filter the sorted list of menu item objects before generating the menu's HTML. 282 * 283 * @since 3.1.0 284 * 285 * @param array $sorted_menu_items The menu items, sorted by each menu item's menu order. 286 */ 217 287 $sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args ); 218 288 219 289 $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args ); … … 235 305 236 306 $wrap_class = $args->menu_class ? $args->menu_class : ''; 237 307 238 // Allow plugins to hook into the menu to add their own <li>'s 308 /** 309 * Filter the HTML list content for navigation menus. 310 * 311 * @since 3.0.0 312 * 313 * @param string $items The HTML list content for the menu items. 314 * @param array $args Arguments from {@see wp_nav_menu()}. 315 */ 239 316 $items = apply_filters( 'wp_nav_menu_items', $items, $args ); 317 /** 318 * Filter the HTML list content for a specific navigation menu. 319 * 320 * @since 3.0.0 321 * 322 * @param string $items The HTML list content for the menu items. 323 * @param array $args Arguments from {@see wp_nav_menu()}. 324 */ 240 325 $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args ); 241 326 242 327 // Don't print any markup if there are no items at this point. … … 249 334 if ( $show_container ) 250 335 $nav_menu .= '</' . $args->container . '>'; 251 336 337 /** 338 * Filter the HTML content for navigation menus 339 * 340 * @since 3.0.0 341 * 342 * @param string $nav_menu The HTML content for the navigation menu. 343 * @param array $args Arguments from {@see wp_nav_menu()}. 344 */ 252 345 $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args ); 253 346 254 347 if ( $args->echo )