WordPress.org

Make WordPress Core

Ticket #6772: fix_get_children_get_posts.diff

File fix_get_children_get_posts.diff, 2.0 KB (added by filosofo, 7 years ago)
  • wp-includes/post.php

     
    408408                'order' => 'DESC', 'include' => '', 
    409409                'exclude' => '', 'meta_key' => '', 
    410410                'meta_value' =>'', 'post_type' => 'post', 
    411                 'post_status' => 'publish', 'post_parent' => 0 
     411                'post_parent' => 0 
    412412        ); 
    413413 
    414414        $r = wp_parse_args( $args, $defaults ); 
     415        if ( empty( $r['post_status'] ) ) 
     416                $r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish'; 
    415417        if ( ! empty($r['numberposts']) ) 
    416418                $r['posts_per_page'] = $r['numberposts']; 
    417419        if ( ! empty($r['category']) ) 
  • wp-includes/media.php

     
    349349        } 
    350350 
    351351        extract(shortcode_atts(array( 
    352                 'orderby'    => 'menu_order ASC, ID ASC', 
     352                'order'      => 'ASC', 
     353                'orderby'    => 'menu_order ID', 
    353354                'id'         => $post->ID, 
    354355                'itemtag'    => 'dl', 
    355356                'icontag'    => 'dt', 
     
    359360        ), $attr)); 
    360361 
    361362        $id = intval($id); 
    362         $attachments = get_children("post_parent=$id&post_type=attachment&post_mime_type=image&orderby={$orderby}"); 
     363        $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); 
    363364 
    364365        if ( empty($attachments) ) 
    365366                return ''; 
     
    433434function adjacent_image_link($prev = true) { 
    434435        global $post; 
    435436        $post = get_post($post); 
    436         $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=menu_order ASC, ID ASC")); 
     437        $attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') )); 
    437438 
    438439        foreach ( $attachments as $k => $attachment ) 
    439440                if ( $attachment->ID == $post->ID )