Make WordPress Core

Ticket #13822: 13822.diff

File 13822.diff, 1.6 KB (added by wpmuguru, 15 years ago)

A patch to kick around

  • wp-includes/nav-menu.php

     
    471471                $fetched[$menu->term_id] = true;
    472472                $posts = array();
    473473                $terms = array();
    474                 foreach ( $items as $item ) {
     474                foreach ( $items as $key => $item ) {
    475475                        $object_id = get_post_meta( $item->ID, '_menu_item_object_id', true );
    476476                        $object    = get_post_meta( $item->ID, '_menu_item_object',    true );
    477477                        $type      = get_post_meta( $item->ID, '_menu_item_type',      true );
    478478
    479                         if ( 'post_type' == $type )
     479                        if ( 'post_type' == $type ) {
    480480                                $posts[$object][] = $object_id;
    481                         elseif ( 'taxonomy' == $type)
     481                                $items[$key]->post_object_id = $object_id;
     482                        } elseif ( 'taxonomy' == $type)
    482483                                $terms[$object][] = $object_id;
     484
     485                        $items[$key]->object_type = $object;
    483486                }
    484487
    485488                if ( ! empty( $posts ) ) {
    486489                        foreach ( array_keys($posts) as $post_type ) {
    487                                 get_posts( array('post__in' => $posts[$post_type], 'post_type' => $post_type, 'nopaging' => true, 'update_post_term_cache' => false) );
     490                                $_posts = get_posts( array('post__in' => $posts[$post_type], 'post_type' => $post_type, 'nopaging' => true, 'update_post_term_cache' => false, 'post_status' => 'publish' ) );
     491                                foreach ( $items as $key => $item ) {
     492                                        if ( $item->object_type == $post_type ) {
     493                                                $found = false;
     494                                                foreach ( $_posts as $p ) {
     495                                                        if ( $p->ID == $item->post_object_id ) {
     496                                                                $found = true;
     497                                                                break;
     498                                                        }
     499                                                }
     500                                                if ( !$found )
     501                                                        unset( $items[$key] );
     502                                        }
     503                                }
    488504                        }
    489505                }
    490506                unset($posts);