diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 671311c4b1..5ba8972f46 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -103,7 +103,7 @@ if ( $doaction ) { case 'delete': $deleted = 0; 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) ) wp_die( __('You are not allowed to delete this item.') ); diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 18849b8e65..014dd56fce 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -512,7 +512,7 @@ function wp_ajax_delete_page( $action ) { if ( !current_user_can( 'delete_page', $id ) ) wp_die( -1 ); - if ( !get_page( $id ) ) + if ( ! get_post( $id ) ) wp_die( 1 ); if ( wp_delete_post( $id ) ) diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index e3d2ac76e4..f3f10b0a41 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -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 $find_main_page = (int) $post->post_parent; while ( $find_main_page > 0 ) { - $parent = get_page( $find_main_page ); + $parent = get_post( $find_main_page ); if ( is_null( $parent ) ) break; diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index a5f5f2ac5b..4c281fa909 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -893,7 +893,7 @@ add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 * @return unknown */ 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' ) { $url = $attachment['url']; $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) { if ( is_int($post) ) - $post =& get_post($post); + $post = get_post($post); if ( is_array($post) ) - $post = (object) $post; + $post = new WP_Post( (object) $post ); $image_url = wp_get_attachment_url($post->ID); diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index c57b72c139..f21d162c37 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -160,7 +160,7 @@ function edit_post( $post_data = null ) { // Autosave shouldn't save too soon after a real save if ( 'autosave' == $post_data['action'] ) { - $post =& get_post( $post_ID ); + $post = get_post( $post_ID ); $now = time(); $then = strtotime($post->post_date_gmt . ' +0000'); $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->post_parent = 0; $post->menu_order = 0; + $post = new WP_Post( $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 */ function _fix_attachment_links( $post_ID ) { - $post = & get_post( $post_ID, ARRAY_A ); + $post = get_post( $post_ID, ARRAY_A ); $content = $post['post_content']; // 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 */ function get_sample_permalink($id, $title = null, $name = null) { - $post = &get_post($id); + $post = get_post($id); if ( !$post->ID ) 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 ) { global $wpdb; - $post = &get_post($id); + $post = get_post($id); list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 8983bb99e5..1c99c90efb 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -705,7 +705,7 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { */ function the_attachment_links( $id = false ) { $id = (int) $id; - $post = & get_post( $id ); + $post = get_post( $id ); if ( $post->post_type != 'attachment' ) return false; diff --git a/wp-admin/post.php b/wp-admin/post.php index 2c5ecb20be..216d157bbf 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -202,7 +202,7 @@ case 'editpost': case 'trash': 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) ) wp_die( __('You are not allowed to move this item to the Trash.') ); diff --git a/wp-admin/upload.php b/wp-admin/upload.php index d172327474..997d4b94f8 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -57,7 +57,7 @@ if ( $doaction ) { if ( !$parent_id ) return; - $parent = &get_post( $parent_id ); + $parent = get_post( $parent_id ); if ( !current_user_can( 'edit_post', $parent_id ) ) wp_die( __( 'You are not allowed to edit this post.' ) ); diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index 29fcc0ef9f..a51cf08fb5 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -775,7 +775,7 @@ class wp_xmlrpc_server extends IXR_Server { // Get info the page parent if there is one. $parent_title = ""; if ( ! empty( $page->post_parent ) ) { - $parent = get_page( $page->post_parent ); + $parent = get_post( $page->post_parent ); $parent_title = $parent->post_title; } @@ -1943,7 +1943,7 @@ class wp_xmlrpc_server extends IXR_Server { return $this->error; } - $page = get_page($page_id); + $page = get_post($page_id); if ( ! $page ) return new IXR_Error( 404, __( 'Invalid post ID.' ) ); diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 9215e1eb3e..19aff1223c 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -1371,7 +1371,7 @@ function wp_new_comment( $commentdata ) { if ( '0' == $commentdata['comment_approved'] ) 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'] ) ) wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' ); diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index def4722ec4..178afb9fc6 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -26,7 +26,7 @@ function get_postdata($postid) { _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' ); - $post = &get_post($postid); + $post = get_post($postid); $postdata = array ( 'ID' => $post->ID, @@ -1892,7 +1892,7 @@ function get_alloptions() { function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' ); $id = (int) $id; - $_post = & get_post($id); + $_post = get_post($id); if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) 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 ) { _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' ); $id = (int) $id; - if ( !$post = & get_post($id) ) + if ( !$post = get_post($id) ) return false; $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 ) { _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); $id = (int) $id; - if ( !$post = & get_post($id) ) + if ( !$post = get_post($id) ) return false; 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) { _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); $id = (int) $id; - if ( !$post = & get_post($id) ) + if ( !$post = get_post($id) ) return false; 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' ); 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) ) return; diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 4a096019ae..dbdea16af9 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1627,7 +1627,7 @@ function feed_links_extra( $args = array() ) { if ( is_single() || is_page() ) { $id = 0; - $post = &get_post( $id ); + $post = get_post( $id ); if ( comments_open() || pings_open() || $post->comment_count > 0 ) { $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) ); diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 2a9e2a45d4..8d742e80dd 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -96,7 +96,7 @@ function get_permalink($id = 0, $leavename = false) { $post = $id; $sample = true; } else { - $post = &get_post($id); + $post = get_post($id); $sample = false; } @@ -178,7 +178,7 @@ function get_permalink($id = 0, $leavename = false) { function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { global $wp_rewrite; - $post = &get_post($id); + $post = get_post($id); if ( is_wp_error( $post ) ) return $post; @@ -895,7 +895,7 @@ function get_post_type_archive_feed_link( $post_type, $feed = '' ) { * @return string */ function get_edit_post_link( $id = 0, $context = 'display' ) { - if ( !$post = &get_post( $id ) ) + if ( !$post = get_post( $id ) ) return; if ( 'display' == $context ) @@ -924,7 +924,7 @@ function get_edit_post_link( $id = 0, $context = 'display' ) { * @param int $id Optional. Post ID. */ function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) { - if ( !$post = &get_post( $id ) ) + if ( !$post = get_post( $id ) ) return; 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 ) ) _deprecated_argument( __FUNCTION__, '3.0' ); - if ( !$post = &get_post( $id ) ) + if ( !$post = get_post( $id ) ) return; $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) { if ( $previous && is_attachment() && is_object( $GLOBALS['post'] ) ) - $post = & get_post($GLOBALS['post']->post_parent); + $post = get_post($GLOBALS['post']->post_parent); else $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) { if ( $previous && is_attachment() ) - $post = & get_post($GLOBALS['post']->post_parent); + $post = get_post($GLOBALS['post']->post_parent); else $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous); diff --git a/wp-includes/media.php b/wp-includes/media.php index b19a90ea1c..477d000586 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -655,7 +655,7 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa $hwstring = image_hwstring($width, $height); if ( is_array($size) ) $size = join('x', $size); - $attachment =& get_post($attachment_id); + $attachment = get_post($attachment_id); $default_attr = array( 'src' => $src, 'class' => "attachment-$size", diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index e278e25040..28eb164b81 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -101,7 +101,7 @@ function the_title_attribute( $args = '' ) { * @return string */ function get_the_title( $id = 0 ) { - $post = &get_post($id); + $post = get_post($id); $title = isset($post->post_title) ? $post->post_title : ''; $id = isset($post->ID) ? $post->ID : (int) $id; @@ -148,7 +148,7 @@ function the_guid( $id = 0 ) { * @return string */ function get_the_guid( $id = 0 ) { - $post = &get_post($id); + $post = get_post($id); return apply_filters('get_the_guid', $post->guid); } @@ -276,7 +276,7 @@ function get_the_excerpt( $deprecated = '' ) { * @return bool */ function has_excerpt( $id = 0 ) { - $post = &get_post( $id ); + $post = get_post( $id ); return ( !empty( $post->post_excerpt ) ); } @@ -474,7 +474,7 @@ function get_body_class( $class = '' ) { $page_id = $wp_query->get_queried_object_id(); - $post = get_page($page_id); + $post = get_post($page_id); $classes[] = 'page-id-' . $page_id; @@ -1015,7 +1015,7 @@ class Walker_Page extends Walker { extract($args, EXTR_SKIP); $css_class = array('page_item', 'page-item-'.$page->ID); if ( !empty($current_page) ) { - $_current_page = get_page( $current_page ); + $_current_page = get_post( $current_page ); if ( in_array( $page->ID, $_current_page->ancestors ) ) $css_class[] = 'current_page_ancestor'; 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 ) { $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 ) ) return __( 'Missing Attachment' ); diff --git a/wp-includes/post.php b/wp-includes/post.php index 7aed6b5b72..bf0a0b02af 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -586,7 +586,7 @@ function get_post_field( $field, $post, $context = 'display' ) { * @return bool|string False on failure or returns the mime type */ function get_post_mime_type($ID = '') { - $post = & get_post($ID); + $post = get_post($ID); if ( is_object($post) ) return $post->post_mime_type; @@ -3348,7 +3348,7 @@ function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') { } if ( $foundid ) - return get_page( $foundid, $output ); + return get_post( $foundid, $output ); return null; } @@ -3368,7 +3368,7 @@ function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) 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 ) ); if ( $page ) - return get_page($page, $output); + return get_post( $page, $output ); return null; } @@ -3455,11 +3455,11 @@ function _page_traverse_name( $page_id, &$children, &$result ){ */ function get_page_uri($page) { if ( ! is_object($page) ) - $page = get_page($page); + $page = get_post( $page ); $uri = $page->post_name; foreach ( $page->ancestors as $parent ) { - $uri = get_page($parent)->post_name . "/" . $uri; + $uri = get_post( $parent )->post_name . "/" . $uri; } return $uri; @@ -3716,7 +3716,7 @@ function is_local_attachment($url) { if (strpos($url, home_url('/?attachment_id=')) !== false) return true; if ( $id = url_to_postid($url) ) { - $post = & get_post($id); + $post = get_post($id); if ( 'attachment' == $post->post_type ) 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 ) { $post_id = (int) $post_id; - if ( !$post =& get_post( $post_id ) ) + if ( !$post = get_post( $post_id ) ) return false; $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 ) { $post_id = (int) $post_id; - if ( !$post =& get_post( $post_id ) ) + if ( !$post = get_post( $post_id ) ) return false; $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 ) { $post_id = (int) $post_id; - if ( !$post =& get_post( $post_id ) ) + if ( !$post = get_post( $post_id ) ) return false; 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 ) { $post_id = (int) $post_id; - if ( !$post =& get_post( $post_id ) ) + if ( !$post = get_post( $post_id ) ) return false; if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) return false; @@ -4113,7 +4113,7 @@ function wp_get_attachment_thumb_file( $post_id = 0 ) { */ function wp_get_attachment_thumb_url( $post_id = 0 ) { $post_id = (int) $post_id; - if ( !$post =& get_post( $post_id ) ) + if ( !$post = get_post( $post_id ) ) return false; if ( !$url = wp_get_attachment_url( $post->ID ) ) return false; @@ -4140,7 +4140,7 @@ function wp_get_attachment_thumb_url( $post_id = 0 ) { */ function wp_attachment_is_image( $post_id = 0 ) { $post_id = (int) $post_id; - if ( !$post =& get_post( $post_id ) ) + if ( !$post = get_post( $post_id ) ) return false; if ( !$file = get_attached_file( $post->ID ) ) @@ -4171,7 +4171,7 @@ function wp_mime_type_icon( $mime = 0 ) { $post_mimes = array(); if ( is_numeric($mime) ) { $mime = (int) $mime; - if ( $post =& get_post( $mime ) ) { + if ( $post = get_post( $mime ) ) { $post_id = (int) $post->ID; $ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid); if ( !empty($ext) ) { diff --git a/wp-includes/query.php b/wp-includes/query.php index 8d85e3e100..c60c257961 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2128,7 +2128,7 @@ class WP_Query { $q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) ); $q['name'] = $q['pagename']; $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 ) { $this->is_attachment = true; $post_type = $q['post_type'] = 'attachment'; @@ -2975,7 +2975,7 @@ class WP_Query { $this->queried_object = get_post_type_object( $this->get('post_type') ); } elseif ( $this->is_posts_page ) { $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; } elseif ( $this->is_singular && !is_null($this->post) ) { $this->queried_object = $this->post; diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 4b19b3e713..f59aee7189 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -3073,10 +3073,7 @@ function the_taxonomies($args = array()) { * @return array */ function get_the_taxonomies($post = 0, $args = array() ) { - if ( is_int($post) ) - $post =& get_post($post); - elseif ( !is_object($post) ) - $post =& $GLOBALS['post']; + $post = get_post( $post ); $args = wp_parse_args( $args, array( 'template' => '%s: %l.', @@ -3122,7 +3119,7 @@ function get_the_taxonomies($post = 0, $args = array() ) { * @return array */ function get_post_taxonomies($post = 0) { - $post =& get_post($post); + $post = get_post( $post ); return get_object_taxonomies($post); }