WordPress.org

Make WordPress Core

Ticket #23044: 23044.patch

File 23044.patch, 2.4 KB (added by hardyy, 22 months ago)
  • media.php

     
    10791079 */ 
    10801080function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) { 
    10811081        $post = get_post(); 
    1082         $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' ) ) ); 
     1082        $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' ), ARRAY_N, true ) ); 
    10831083 
    1084         foreach ( $attachments as $k => $attachment ) 
    1085                 if ( $attachment->ID == $post->ID ) 
    1086                         break; 
     1084        if( in_array( $post->ID, $attachments ) ) 
     1085                $k = array_search( $post->ID, $attachments ); 
    10871086 
    10881087        $k = $prev ? $k - 1 : $k + 1; 
    10891088 
    10901089        $output = $attachment_id = null; 
    10911090        if ( isset( $attachments[ $k ] ) ) { 
    1092                 $attachment_id = $attachments[ $k ]->ID; 
     1091                $attachment_id = $attachments[ $k ]; 
    10931092                $output = wp_get_attachment_link( $attachment_id, $size, true, false, $text ); 
    10941093        } 
    10951094 
  • post.php

     
    285285 * 
    286286 * @param mixed $args Optional. User defined arguments for replacing the defaults. 
    287287 * @param string $output Optional. Constant for return type, either OBJECT (default), ARRAY_A, ARRAY_N. 
     288 * @param bool $IDs_only Optional. To get only the IDs of childern posts. Works only with ARRAY_N 
    288289 * @return array|bool False on failure and the type will be determined by $output parameter. 
    289290 */ 
    290 function get_children($args = '', $output = OBJECT) { 
     291function get_children($args = '', $output = OBJECT, $IDs_only = false) { 
    291292        $kids = array(); 
    292293        if ( empty( $args ) ) { 
    293294                if ( isset( $GLOBALS['post'] ) ) { 
     
    324325                foreach ( (array) $kids as $kid ) 
    325326                        $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]); 
    326327                return $weeuns; 
     328        } elseif ( ($output == ARRAY_N) && ($IDs_only == true) ) { 
     329                foreach ( (array) $kids as $kid ) 
     330                        $babes[$kid->ID] = $kid->ID; 
     331                return $babes; 
    327332        } elseif ( $output == ARRAY_N ) { 
    328333                foreach ( (array) $kids as $kid ) 
    329334                        $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));