Remove return ref from all calls to get_post()

Return WP_Post from get_default_post_to_edit()
Replace all calls to get_page() with get_post()
see #21309


git-svn-id: http://core.svn.wordpress.org/trunk@21597 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-08-23 20:01:10 +00:00
parent 6248d6221c
commit f56d8278bb
18 changed files with 55 additions and 57 deletions

View File

@ -103,7 +103,7 @@ if ( $doaction ) {
case 'delete': case 'delete':
$deleted = 0; $deleted = 0;
foreach( (array) $post_ids as $post_id ) { foreach( (array) $post_ids as $post_id ) {
$post_del = & get_post($post_id); $post_del = get_post($post_id);
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
wp_die( __('You are not allowed to delete this item.') ); wp_die( __('You are not allowed to delete this item.') );

View File

@ -512,7 +512,7 @@ function wp_ajax_delete_page( $action ) {
if ( !current_user_can( 'delete_page', $id ) ) if ( !current_user_can( 'delete_page', $id ) )
wp_die( -1 ); wp_die( -1 );
if ( !get_page( $id ) ) if ( ! get_post( $id ) )
wp_die( 1 ); wp_die( 1 );
if ( wp_delete_post( $id ) ) if ( wp_delete_post( $id ) )

View File

@ -509,7 +509,7 @@ class WP_Posts_List_Table extends WP_List_Table {
//sent level 0 by accident, by default, or because we don't know the actual level //sent level 0 by accident, by default, or because we don't know the actual level
$find_main_page = (int) $post->post_parent; $find_main_page = (int) $post->post_parent;
while ( $find_main_page > 0 ) { while ( $find_main_page > 0 ) {
$parent = get_page( $find_main_page ); $parent = get_post( $find_main_page );
if ( is_null( $parent ) ) if ( is_null( $parent ) )
break; break;

View File

@ -893,7 +893,7 @@ add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2
* @return unknown * @return unknown
*/ */
function image_media_send_to_editor($html, $attachment_id, $attachment) { function image_media_send_to_editor($html, $attachment_id, $attachment) {
$post =& get_post($attachment_id); $post = get_post($attachment_id);
if ( substr($post->post_mime_type, 0, 5) == 'image' ) { if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
$url = $attachment['url']; $url = $attachment['url'];
$align = !empty($attachment['align']) ? $attachment['align'] : 'none'; $align = !empty($attachment['align']) ? $attachment['align'] : 'none';
@ -920,9 +920,9 @@ add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
*/ */
function get_attachment_fields_to_edit($post, $errors = null) { function get_attachment_fields_to_edit($post, $errors = null) {
if ( is_int($post) ) if ( is_int($post) )
$post =& get_post($post); $post = get_post($post);
if ( is_array($post) ) if ( is_array($post) )
$post = (object) $post; $post = new WP_Post( (object) $post );
$image_url = wp_get_attachment_url($post->ID); $image_url = wp_get_attachment_url($post->ID);

View File

@ -160,7 +160,7 @@ function edit_post( $post_data = null ) {
// Autosave shouldn't save too soon after a real save // Autosave shouldn't save too soon after a real save
if ( 'autosave' == $post_data['action'] ) { if ( 'autosave' == $post_data['action'] ) {
$post =& get_post( $post_ID ); $post = get_post( $post_ID );
$now = time(); $now = time();
$then = strtotime($post->post_date_gmt . ' +0000'); $then = strtotime($post->post_date_gmt . ' +0000');
$delta = AUTOSAVE_INTERVAL / 2; $delta = AUTOSAVE_INTERVAL / 2;
@ -439,6 +439,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
$post->page_template = 'default'; $post->page_template = 'default';
$post->post_parent = 0; $post->post_parent = 0;
$post->menu_order = 0; $post->menu_order = 0;
$post = new WP_Post( $post );
} }
$post->post_content = apply_filters( 'default_content', $post_content, $post ); $post->post_content = apply_filters( 'default_content', $post_content, $post );
@ -745,7 +746,7 @@ function update_meta( $meta_id, $meta_key, $meta_value ) {
* @return unknown * @return unknown
*/ */
function _fix_attachment_links( $post_ID ) { function _fix_attachment_links( $post_ID ) {
$post = & get_post( $post_ID, ARRAY_A ); $post = get_post( $post_ID, ARRAY_A );
$content = $post['post_content']; $content = $post['post_content'];
// quick sanity check, don't run if no pretty permalinks or post is not published // quick sanity check, don't run if no pretty permalinks or post is not published
@ -1012,7 +1013,7 @@ function postbox_classes( $id, $page ) {
* @return array With two entries of type string * @return array With two entries of type string
*/ */
function get_sample_permalink($id, $title = null, $name = null) { function get_sample_permalink($id, $title = null, $name = null) {
$post = &get_post($id); $post = get_post($id);
if ( !$post->ID ) if ( !$post->ID )
return array('', ''); return array('', '');
@ -1078,7 +1079,7 @@ function get_sample_permalink($id, $title = null, $name = null) {
*/ */
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
global $wpdb; global $wpdb;
$post = &get_post($id); $post = get_post($id);
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);

View File

@ -705,7 +705,7 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
*/ */
function the_attachment_links( $id = false ) { function the_attachment_links( $id = false ) {
$id = (int) $id; $id = (int) $id;
$post = & get_post( $id ); $post = get_post( $id );
if ( $post->post_type != 'attachment' ) if ( $post->post_type != 'attachment' )
return false; return false;

View File

@ -202,7 +202,7 @@ case 'editpost':
case 'trash': case 'trash':
check_admin_referer('trash-post_' . $post_id); check_admin_referer('trash-post_' . $post_id);
$post = & get_post($post_id); $post = get_post($post_id);
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
wp_die( __('You are not allowed to move this item to the Trash.') ); wp_die( __('You are not allowed to move this item to the Trash.') );

View File

@ -57,7 +57,7 @@ if ( $doaction ) {
if ( !$parent_id ) if ( !$parent_id )
return; return;
$parent = &get_post( $parent_id ); $parent = get_post( $parent_id );
if ( !current_user_can( 'edit_post', $parent_id ) ) if ( !current_user_can( 'edit_post', $parent_id ) )
wp_die( __( 'You are not allowed to edit this post.' ) ); wp_die( __( 'You are not allowed to edit this post.' ) );

View File

@ -775,7 +775,7 @@ class wp_xmlrpc_server extends IXR_Server {
// Get info the page parent if there is one. // Get info the page parent if there is one.
$parent_title = ""; $parent_title = "";
if ( ! empty( $page->post_parent ) ) { if ( ! empty( $page->post_parent ) ) {
$parent = get_page( $page->post_parent ); $parent = get_post( $page->post_parent );
$parent_title = $parent->post_title; $parent_title = $parent->post_title;
} }
@ -1943,7 +1943,7 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error; return $this->error;
} }
$page = get_page($page_id); $page = get_post($page_id);
if ( ! $page ) if ( ! $page )
return new IXR_Error( 404, __( 'Invalid post ID.' ) ); return new IXR_Error( 404, __( 'Invalid post ID.' ) );

View File

@ -1371,7 +1371,7 @@ function wp_new_comment( $commentdata ) {
if ( '0' == $commentdata['comment_approved'] ) if ( '0' == $commentdata['comment_approved'] )
wp_notify_moderator($comment_ID); wp_notify_moderator($comment_ID);
$post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment $post = get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment
if ( get_option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) ) if ( get_option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) )
wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' ); wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' );

View File

@ -26,7 +26,7 @@
function get_postdata($postid) { function get_postdata($postid) {
_deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' ); _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' );
$post = &get_post($postid); $post = get_post($postid);
$postdata = array ( $postdata = array (
'ID' => $post->ID, 'ID' => $post->ID,
@ -1892,7 +1892,7 @@ function get_alloptions() {
function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' ); _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' );
$id = (int) $id; $id = (int) $id;
$_post = & get_post($id); $_post = get_post($id);
if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
return __('Missing Attachment'); return __('Missing Attachment');
@ -1921,7 +1921,7 @@ function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false,
function get_attachment_icon_src( $id = 0, $fullsize = false ) { function get_attachment_icon_src( $id = 0, $fullsize = false ) {
_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' ); _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' );
$id = (int) $id; $id = (int) $id;
if ( !$post = & get_post($id) ) if ( !$post = get_post($id) )
return false; return false;
$file = get_attached_file( $post->ID ); $file = get_attached_file( $post->ID );
@ -1966,7 +1966,7 @@ function get_attachment_icon_src( $id = 0, $fullsize = false ) {
function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
$id = (int) $id; $id = (int) $id;
if ( !$post = & get_post($id) ) if ( !$post = get_post($id) )
return false; return false;
if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
@ -2023,7 +2023,7 @@ function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
$id = (int) $id; $id = (int) $id;
if ( !$post = & get_post($id) ) if ( !$post = get_post($id) )
return false; return false;
if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
@ -2801,7 +2801,7 @@ function get_parent_post_rel_link($title = '%title') {
_deprecated_function( __FUNCTION__, '3.3' ); _deprecated_function( __FUNCTION__, '3.3' );
if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
$post = & get_post($GLOBALS['post']->post_parent); $post = get_post($GLOBALS['post']->post_parent);
if ( empty($post) ) if ( empty($post) )
return; return;

View File

@ -1627,7 +1627,7 @@ function feed_links_extra( $args = array() ) {
if ( is_single() || is_page() ) { if ( is_single() || is_page() ) {
$id = 0; $id = 0;
$post = &get_post( $id ); $post = get_post( $id );
if ( comments_open() || pings_open() || $post->comment_count > 0 ) { if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
$title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) ); $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) );

View File

@ -96,7 +96,7 @@ function get_permalink($id = 0, $leavename = false) {
$post = $id; $post = $id;
$sample = true; $sample = true;
} else { } else {
$post = &get_post($id); $post = get_post($id);
$sample = false; $sample = false;
} }
@ -178,7 +178,7 @@ function get_permalink($id = 0, $leavename = false) {
function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { function get_post_permalink( $id = 0, $leavename = false, $sample = false ) {
global $wp_rewrite; global $wp_rewrite;
$post = &get_post($id); $post = get_post($id);
if ( is_wp_error( $post ) ) if ( is_wp_error( $post ) )
return $post; return $post;
@ -895,7 +895,7 @@ function get_post_type_archive_feed_link( $post_type, $feed = '' ) {
* @return string * @return string
*/ */
function get_edit_post_link( $id = 0, $context = 'display' ) { function get_edit_post_link( $id = 0, $context = 'display' ) {
if ( !$post = &get_post( $id ) ) if ( !$post = get_post( $id ) )
return; return;
if ( 'display' == $context ) if ( 'display' == $context )
@ -924,7 +924,7 @@ function get_edit_post_link( $id = 0, $context = 'display' ) {
* @param int $id Optional. Post ID. * @param int $id Optional. Post ID.
*/ */
function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) { function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) {
if ( !$post = &get_post( $id ) ) if ( !$post = get_post( $id ) )
return; return;
if ( !$url = get_edit_post_link( $post->ID ) ) if ( !$url = get_edit_post_link( $post->ID ) )
@ -954,7 +954,7 @@ function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false
if ( ! empty( $deprecated ) ) if ( ! empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '3.0' ); _deprecated_argument( __FUNCTION__, '3.0' );
if ( !$post = &get_post( $id ) ) if ( !$post = get_post( $id ) )
return; return;
$post_type_object = get_post_type_object( $post->post_type ); $post_type_object = get_post_type_object( $post->post_type );
@ -1201,7 +1201,7 @@ function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $pr
*/ */
function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) { function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) {
if ( $previous && is_attachment() && is_object( $GLOBALS['post'] ) ) if ( $previous && is_attachment() && is_object( $GLOBALS['post'] ) )
$post = & get_post($GLOBALS['post']->post_parent); $post = get_post($GLOBALS['post']->post_parent);
else else
$post = get_adjacent_post($in_same_cat,$excluded_categories,$previous); $post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);
@ -1366,7 +1366,7 @@ function next_post_link($format='%link »', $link='%title', $in_same_cat =
*/ */
function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
if ( $previous && is_attachment() ) if ( $previous && is_attachment() )
$post = & get_post($GLOBALS['post']->post_parent); $post = get_post($GLOBALS['post']->post_parent);
else else
$post = get_adjacent_post($in_same_cat, $excluded_categories, $previous); $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous);

View File

@ -655,7 +655,7 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
$hwstring = image_hwstring($width, $height); $hwstring = image_hwstring($width, $height);
if ( is_array($size) ) if ( is_array($size) )
$size = join('x', $size); $size = join('x', $size);
$attachment =& get_post($attachment_id); $attachment = get_post($attachment_id);
$default_attr = array( $default_attr = array(
'src' => $src, 'src' => $src,
'class' => "attachment-$size", 'class' => "attachment-$size",

View File

@ -101,7 +101,7 @@ function the_title_attribute( $args = '' ) {
* @return string * @return string
*/ */
function get_the_title( $id = 0 ) { function get_the_title( $id = 0 ) {
$post = &get_post($id); $post = get_post($id);
$title = isset($post->post_title) ? $post->post_title : ''; $title = isset($post->post_title) ? $post->post_title : '';
$id = isset($post->ID) ? $post->ID : (int) $id; $id = isset($post->ID) ? $post->ID : (int) $id;
@ -148,7 +148,7 @@ function the_guid( $id = 0 ) {
* @return string * @return string
*/ */
function get_the_guid( $id = 0 ) { function get_the_guid( $id = 0 ) {
$post = &get_post($id); $post = get_post($id);
return apply_filters('get_the_guid', $post->guid); return apply_filters('get_the_guid', $post->guid);
} }
@ -276,7 +276,7 @@ function get_the_excerpt( $deprecated = '' ) {
* @return bool * @return bool
*/ */
function has_excerpt( $id = 0 ) { function has_excerpt( $id = 0 ) {
$post = &get_post( $id ); $post = get_post( $id );
return ( !empty( $post->post_excerpt ) ); return ( !empty( $post->post_excerpt ) );
} }
@ -474,7 +474,7 @@ function get_body_class( $class = '' ) {
$page_id = $wp_query->get_queried_object_id(); $page_id = $wp_query->get_queried_object_id();
$post = get_page($page_id); $post = get_post($page_id);
$classes[] = 'page-id-' . $page_id; $classes[] = 'page-id-' . $page_id;
@ -1015,7 +1015,7 @@ class Walker_Page extends Walker {
extract($args, EXTR_SKIP); extract($args, EXTR_SKIP);
$css_class = array('page_item', 'page-item-'.$page->ID); $css_class = array('page_item', 'page-item-'.$page->ID);
if ( !empty($current_page) ) { if ( !empty($current_page) ) {
$_current_page = get_page( $current_page ); $_current_page = get_post( $current_page );
if ( in_array( $page->ID, $_current_page->ancestors ) ) if ( in_array( $page->ID, $_current_page->ancestors ) )
$css_class[] = 'current_page_ancestor'; $css_class[] = 'current_page_ancestor';
if ( $page->ID == $current_page ) if ( $page->ID == $current_page )
@ -1138,7 +1138,7 @@ function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $
*/ */
function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) { function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {
$id = intval( $id ); $id = intval( $id );
$_post = & get_post( $id ); $_post = get_post( $id );
if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) ) if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
return __( 'Missing Attachment' ); return __( 'Missing Attachment' );

View File

@ -586,7 +586,7 @@ function get_post_field( $field, $post, $context = 'display' ) {
* @return bool|string False on failure or returns the mime type * @return bool|string False on failure or returns the mime type
*/ */
function get_post_mime_type($ID = '') { function get_post_mime_type($ID = '') {
$post = & get_post($ID); $post = get_post($ID);
if ( is_object($post) ) if ( is_object($post) )
return $post->post_mime_type; return $post->post_mime_type;
@ -3348,7 +3348,7 @@ function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
} }
if ( $foundid ) if ( $foundid )
return get_page( $foundid, $output ); return get_post( $foundid, $output );
return null; return null;
} }
@ -3368,7 +3368,7 @@ function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' )
global $wpdb; global $wpdb;
$page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) ); $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) );
if ( $page ) if ( $page )
return get_page($page, $output); return get_post( $page, $output );
return null; return null;
} }
@ -3455,11 +3455,11 @@ function _page_traverse_name( $page_id, &$children, &$result ){
*/ */
function get_page_uri($page) { function get_page_uri($page) {
if ( ! is_object($page) ) if ( ! is_object($page) )
$page = get_page($page); $page = get_post( $page );
$uri = $page->post_name; $uri = $page->post_name;
foreach ( $page->ancestors as $parent ) { foreach ( $page->ancestors as $parent ) {
$uri = get_page($parent)->post_name . "/" . $uri; $uri = get_post( $parent )->post_name . "/" . $uri;
} }
return $uri; return $uri;
@ -3716,7 +3716,7 @@ function is_local_attachment($url) {
if (strpos($url, home_url('/?attachment_id=')) !== false) if (strpos($url, home_url('/?attachment_id=')) !== false)
return true; return true;
if ( $id = url_to_postid($url) ) { if ( $id = url_to_postid($url) ) {
$post = & get_post($id); $post = get_post($id);
if ( 'attachment' == $post->post_type ) if ( 'attachment' == $post->post_type )
return true; return true;
} }
@ -4012,7 +4012,7 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
*/ */
function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) { function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
$post_id = (int) $post_id; $post_id = (int) $post_id;
if ( !$post =& get_post( $post_id ) ) if ( !$post = get_post( $post_id ) )
return false; return false;
$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true ); $data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
@ -4034,7 +4034,7 @@ function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
*/ */
function wp_update_attachment_metadata( $post_id, $data ) { function wp_update_attachment_metadata( $post_id, $data ) {
$post_id = (int) $post_id; $post_id = (int) $post_id;
if ( !$post =& get_post( $post_id ) ) if ( !$post = get_post( $post_id ) )
return false; return false;
$data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ); $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID );
@ -4052,7 +4052,7 @@ function wp_update_attachment_metadata( $post_id, $data ) {
*/ */
function wp_get_attachment_url( $post_id = 0 ) { function wp_get_attachment_url( $post_id = 0 ) {
$post_id = (int) $post_id; $post_id = (int) $post_id;
if ( !$post =& get_post( $post_id ) ) if ( !$post = get_post( $post_id ) )
return false; return false;
if ( 'attachment' != $post->post_type ) if ( 'attachment' != $post->post_type )
@ -4091,7 +4091,7 @@ function wp_get_attachment_url( $post_id = 0 ) {
*/ */
function wp_get_attachment_thumb_file( $post_id = 0 ) { function wp_get_attachment_thumb_file( $post_id = 0 ) {
$post_id = (int) $post_id; $post_id = (int) $post_id;
if ( !$post =& get_post( $post_id ) ) if ( !$post = get_post( $post_id ) )
return false; return false;
if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
return false; return false;
@ -4113,7 +4113,7 @@ function wp_get_attachment_thumb_file( $post_id = 0 ) {
*/ */
function wp_get_attachment_thumb_url( $post_id = 0 ) { function wp_get_attachment_thumb_url( $post_id = 0 ) {
$post_id = (int) $post_id; $post_id = (int) $post_id;
if ( !$post =& get_post( $post_id ) ) if ( !$post = get_post( $post_id ) )
return false; return false;
if ( !$url = wp_get_attachment_url( $post->ID ) ) if ( !$url = wp_get_attachment_url( $post->ID ) )
return false; return false;
@ -4140,7 +4140,7 @@ function wp_get_attachment_thumb_url( $post_id = 0 ) {
*/ */
function wp_attachment_is_image( $post_id = 0 ) { function wp_attachment_is_image( $post_id = 0 ) {
$post_id = (int) $post_id; $post_id = (int) $post_id;
if ( !$post =& get_post( $post_id ) ) if ( !$post = get_post( $post_id ) )
return false; return false;
if ( !$file = get_attached_file( $post->ID ) ) if ( !$file = get_attached_file( $post->ID ) )
@ -4171,7 +4171,7 @@ function wp_mime_type_icon( $mime = 0 ) {
$post_mimes = array(); $post_mimes = array();
if ( is_numeric($mime) ) { if ( is_numeric($mime) ) {
$mime = (int) $mime; $mime = (int) $mime;
if ( $post =& get_post( $mime ) ) { if ( $post = get_post( $mime ) ) {
$post_id = (int) $post->ID; $post_id = (int) $post->ID;
$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid); $ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid);
if ( !empty($ext) ) { if ( !empty($ext) ) {

View File

@ -2128,7 +2128,7 @@ class WP_Query {
$q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) ); $q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) );
$q['name'] = $q['pagename']; $q['name'] = $q['pagename'];
$where .= " AND ($wpdb->posts.ID = '$reqpage')"; $where .= " AND ($wpdb->posts.ID = '$reqpage')";
$reqpage_obj = get_page($reqpage); $reqpage_obj = get_post( $reqpage );
if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) { if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) {
$this->is_attachment = true; $this->is_attachment = true;
$post_type = $q['post_type'] = 'attachment'; $post_type = $q['post_type'] = 'attachment';
@ -2975,7 +2975,7 @@ class WP_Query {
$this->queried_object = get_post_type_object( $this->get('post_type') ); $this->queried_object = get_post_type_object( $this->get('post_type') );
} elseif ( $this->is_posts_page ) { } elseif ( $this->is_posts_page ) {
$page_for_posts = get_option('page_for_posts'); $page_for_posts = get_option('page_for_posts');
$this->queried_object = get_page( $page_for_posts ); $this->queried_object = get_post( $page_for_posts );
$this->queried_object_id = (int) $this->queried_object->ID; $this->queried_object_id = (int) $this->queried_object->ID;
} elseif ( $this->is_singular && !is_null($this->post) ) { } elseif ( $this->is_singular && !is_null($this->post) ) {
$this->queried_object = $this->post; $this->queried_object = $this->post;

View File

@ -3073,10 +3073,7 @@ function the_taxonomies($args = array()) {
* @return array * @return array
*/ */
function get_the_taxonomies($post = 0, $args = array() ) { function get_the_taxonomies($post = 0, $args = array() ) {
if ( is_int($post) ) $post = get_post( $post );
$post =& get_post($post);
elseif ( !is_object($post) )
$post =& $GLOBALS['post'];
$args = wp_parse_args( $args, array( $args = wp_parse_args( $args, array(
'template' => '%s: %l.', 'template' => '%s: %l.',
@ -3122,7 +3119,7 @@ function get_the_taxonomies($post = 0, $args = array() ) {
* @return array * @return array
*/ */
function get_post_taxonomies($post = 0) { function get_post_taxonomies($post = 0) {
$post =& get_post($post); $post = get_post( $post );
return get_object_taxonomies($post); return get_object_taxonomies($post);
} }