Ticket #36905: 36905.2.patch
File 36905.2.patch, 1.4 KB (added by , 8 years ago) |
---|
-
src/wp-includes/post.php
4326 4326 * @return WP_Post|array|void WP_Post on success or null on failure 4327 4327 */ 4328 4328 function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) { 4329 global $wpdb;4330 4329 4331 if ( is_array( $post_type ) ) { 4332 $post_type = esc_sql( $post_type ); 4333 $post_type_in_string = "'" . implode( "','", $post_type ) . "'"; 4334 $sql = $wpdb->prepare( " 4335 SELECT ID 4336 FROM $wpdb->posts 4337 WHERE post_title = %s 4338 AND post_type IN ($post_type_in_string) 4339 ", $page_title ); 4340 } else { 4341 $sql = $wpdb->prepare( " 4342 SELECT ID 4343 FROM $wpdb->posts 4344 WHERE post_title = %s 4345 AND post_type = %s 4346 ", $page_title, $post_type ); 4347 } 4330 // Make sure that we actually get all the post statuses 4331 $post_status = get_post_stati(); 4348 4332 4349 $page = $wpdb->get_var( $sql ); 4333 $query = new WP_Query( 4334 array( 4335 'title' => $page_title, 4336 'post_type' => $post_type, 4337 'posts_per_page' => 1, 4338 'post_status' => $post_status, 4339 'orderby' => 'ID', 4340 'order' => 'ASC', 4341 'fields' => 'ids' 4342 ) 4343 ); 4344 $posts = $query->get_posts(); 4350 4345 4351 if ( $p age) {4352 return get_post( $p age, $output );4346 if ( $posts ) { 4347 return get_post( $posts[0], $output ); 4353 4348 } 4354 4349 } 4355 4350