WordPress.org

Make WordPress Core

Changeset 22234


Ignore:
Timestamp:
10/15/12 14:19:45 (3 years ago)
Author:
nacin
Message:

In nav menus, avoid firing the magic WP_Post getter for potentially non-existent properties, which results in a metadata cache hit. see #22189.

File:
1 edited

Legend:

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

    r22019 r22234  
    248248        $output .= '<label class="menu-item-title">'; 
    249249        $output .= '<input type="checkbox" class="menu-item-checkbox'; 
    250         if ( ! empty( $item->_add_to_top ) ) { 
     250        if ( property_exists( $item, 'front_or_home' ) && $item->front_or_home ) { 
     251            $title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $item->post_title ); 
    251252            $output .= ' add-to-top'; 
    252253        } 
    253254        $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> '; 
    254         $output .= empty( $item->label ) ? esc_html( $item->title ) : esc_html( $item->label ); 
     255        $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title ); 
    255256        $output .= '</label>'; 
    256257 
     
    728729                    if ( ! empty( $front_page ) ) { 
    729730                        $front_page_obj = get_post( $front_page ); 
    730                         $front_page_obj->_add_to_top = true; 
    731                         $front_page_obj->label = sprintf( _x('Home: %s', 'nav menu front page title'), $front_page_obj->post_title ); 
     731                        $front_page_obj->front_or_home = true; 
    732732                        array_unshift( $posts, $front_page_obj ); 
    733733                    } else { 
    734734                        $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; 
    735735                        array_unshift( $posts, (object) array( 
    736                             '_add_to_top' => true, 
     736                            'front_or_home' => true, 
    737737                            'ID' => 0, 
    738738                            'object_id' => $_nav_menu_placeholder, 
Note: See TracChangeset for help on using the changeset viewer.