Make WordPress Core

Ticket #21309: post-to-edit.2.diff

File post-to-edit.2.diff, 12.9 KB (added by scribu, 12 years ago)
  • wp-admin/includes/deprecated.php

    diff --git wp-admin/includes/deprecated.php wp-admin/includes/deprecated.php
    index 6a66e43..bc49030 100644
    function current_theme_info() { 
    943943
    944944/**
    945945 * This was once used to display an 'Insert into Post' button. Now it is deprecated and stubbed.
    946  * 
     946 *
    947947 * @deprecated 3.5.0
    948948 */
    949949function _insert_into_post_button( $type ) {
    function _insert_into_post_button( $type ) { 
    952952
    953953/**
    954954 * This was once used to display a media button. Now it is deprecated and stubbed.
    955  * 
     955 *
    956956 * @deprecated 3.5.0
    957957 */
    958958function _media_button($title, $icon, $type, $id) {
    959959        _deprecated_function( __FUNCTION__, '3.5' );
    960960}
     961
     962/**
     963 * Get an existing post and format it for editing.
     964 *
     965 * @since 2.0.0
     966 * @deprecated 3.5.0
     967 *
     968 * @param int $id
     969 * @return object
     970 */
     971function get_post_to_edit( $id ) {
     972        _deprecated_function( __FUNCTION__, '3.5', 'get_post()' );
     973
     974        return get_post( $id, OBJECT, 'edit' );
     975}
     976
  • wp-admin/includes/post.php

    diff --git wp-admin/includes/post.php wp-admin/includes/post.php
    index c57b72c..7ee873d 100644
    function get_default_page_to_edit() { 
    463463}
    464464
    465465/**
    466  * Get an existing post and format it for editing.
    467  *
    468  * @since 2.0.0
    469  *
    470  * @param unknown_type $id
    471  * @return unknown
    472  */
    473 function get_post_to_edit( $id ) {
    474 
    475         $post = get_post( $id, OBJECT, 'edit' );
    476 
    477         if ( $post->post_type == 'page' )
    478                 $post->page_template = get_post_meta( $id, '_wp_page_template', true );
    479 
    480         return $post;
    481 }
    482 
    483 /**
    484466 * Determine if a post exists based on title, content, and date
    485467 *
    486468 * @since 2.0.0
    function get_available_post_mime_types($type = 'attachment') { 
    927909/**
    928910 * Executes a query for attachments. An array of WP_Query arguments
    929911 * can be passed in, which will override the arguments set by this function.
    930  * 
     912 *
    931913 * @since 2.5.0
    932914 * @uses apply_filters() Calls 'upload_per_page' on posts_per_page argument
    933915 *
  • wp-admin/post.php

    diff --git wp-admin/post.php wp-admin/post.php
    index 2c5ecb2..2bfc16e 100644
    case 'edit': 
    165165        }
    166166
    167167        $title = $post_type_object->labels->edit_item;
    168         $post = get_post_to_edit($post_id);
     168        $post = get_post($post_id, OBJECT, 'edit');
    169169
    170170        if ( post_type_supports($post_type, 'comments') ) {
    171171                wp_enqueue_script('admin-comments');
  • wp-includes/class-wp-atom-server.php

    diff --git wp-includes/class-wp-atom-server.php wp-includes/class-wp-atom-server.php
    index d381673..ca61ae7 100644
    EOD; 
    913913                        $this->not_found();
    914914                }
    915915
    916                 $entry = wp_get_single_post($postID,ARRAY_A);
     916                $entry = get_post($postID,ARRAY_A);
    917917
    918918                if (!isset($entry) || !isset($entry['ID']))
    919919                        $this->not_found();
    EOD; 
    14101410                switch($this->params[0]) {
    14111411                        case $this->ENTRY_PATH:
    14121412                                global $post;
    1413                                 $post = wp_get_single_post($this->params[1]);
     1413                                $post = get_post($this->params[1]);
    14141414                                $wp_last_modified = get_post_modified_time('D, d M Y H:i:s', true);
    14151415                                $post = null;
    14161416                                break;
  • wp-includes/class-wp-xmlrpc-server.php

    diff --git wp-includes/class-wp-xmlrpc-server.php wp-includes/class-wp-xmlrpc-server.php
    index 29fcc0e..674b33e 100644
    class wp_xmlrpc_server extends IXR_Server { 
    12561256
    12571257                do_action( 'xmlrpc_call', 'wp.deletePost' );
    12581258
    1259                 $post = wp_get_single_post( $post_id, ARRAY_A );
     1259                $post = get_post( $post_id, ARRAY_A );
    12601260                if ( empty( $post['ID'] ) )
    12611261                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    12621262
    class wp_xmlrpc_server extends IXR_Server { 
    12861286         * groups are 'post' (all basic fields), 'taxonomies', 'custom_fields',
    12871287         * and 'enclosure'.
    12881288         *
    1289          * @uses wp_get_single_post()
     1289         * @uses get_post()
    12901290         * @param array $args Method parameters. Contains:
    12911291         *  - int     $post_id
    12921292         *  - string  $username
    class wp_xmlrpc_server extends IXR_Server { 
    13371337
    13381338                do_action( 'xmlrpc_call', 'wp.getPost' );
    13391339
    1340                 $post = wp_get_single_post( $post_id, ARRAY_A );
     1340                $post = get_post( $post_id, ARRAY_A );
    13411341
    13421342                if ( empty( $post['ID'] ) )
    13431343                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    class wp_xmlrpc_server extends IXR_Server { 
    20602060
    20612061                // Get the current page based on the page_id and
    20622062                // make sure it is a page and not a post.
    2063                 $actual_page = wp_get_single_post($page_id, ARRAY_A);
     2063                $actual_page = get_post($page_id, ARRAY_A);
    20642064                if ( !$actual_page || ($actual_page['post_type'] != 'page') )
    20652065                        return(new IXR_Error(404, __('Sorry, no such page.')));
    20662066
    class wp_xmlrpc_server extends IXR_Server { 
    21012101                do_action('xmlrpc_call', 'wp.editPage');
    21022102
    21032103                // Get the page data and make sure it is a page.
    2104                 $actual_page = wp_get_single_post($page_id, ARRAY_A);
     2104                $actual_page = get_post($page_id, ARRAY_A);
    21052105                if ( !$actual_page || ($actual_page['post_type'] != 'page') )
    21062106                        return(new IXR_Error(404, __('Sorry, no such page.')));
    21072107
    class wp_xmlrpc_server extends IXR_Server { 
    32963296                if ( !$user = $this->login($username, $password) )
    32973297                        return $this->error;
    32983298
    3299                 $post_data = wp_get_single_post($post_ID, ARRAY_A);
     3299                $post_data = get_post($post_ID, ARRAY_A);
    33003300                if ( ! $post_data )
    33013301                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    33023302
    class wp_xmlrpc_server extends IXR_Server { 
    35383538
    35393539                do_action('xmlrpc_call', 'blogger.editPost');
    35403540
    3541                 $actual_post = wp_get_single_post($post_ID,ARRAY_A);
     3541                $actual_post = get_post($post_ID,ARRAY_A);
    35423542
    35433543                if ( !$actual_post || $actual_post['post_type'] != 'post' )
    35443544                        return new IXR_Error(404, __('Sorry, no such post.'));
    class wp_xmlrpc_server extends IXR_Server { 
    35923592
    35933593                do_action('xmlrpc_call', 'blogger.deletePost');
    35943594
    3595                 $actual_post = wp_get_single_post($post_ID,ARRAY_A);
     3595                $actual_post = get_post($post_ID,ARRAY_A);
    35963596
    35973597                if ( !$actual_post || $actual_post['post_type'] != 'post' )
    35983598                        return new IXR_Error(404, __('Sorry, no such post.'));
    class wp_xmlrpc_server extends IXR_Server { 
    39823982
    39833983                do_action('xmlrpc_call', 'metaWeblog.editPost');
    39843984
    3985                 $postdata = wp_get_single_post( $post_ID, ARRAY_A );
     3985                $postdata = get_post( $post_ID, ARRAY_A );
    39863986
    39873987                // If there is no post data for the give post id, stop
    39883988                // now and return an error. Other wise a new post will be
    class wp_xmlrpc_server extends IXR_Server { 
    42474247                if ( !$user = $this->login($username, $password) )
    42484248                        return $this->error;
    42494249
    4250                 $postdata = wp_get_single_post($post_ID, ARRAY_A);
     4250                $postdata = get_post($post_ID, ARRAY_A);
    42514251                if ( ! $postdata )
    42524252                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    42534253
    class wp_xmlrpc_server extends IXR_Server { 
    48274827
    48284828                do_action('xmlrpc_call', 'mt.getTrackbackPings');
    48294829
    4830                 $actual_post = wp_get_single_post($post_ID, ARRAY_A);
     4830                $actual_post = get_post($post_ID, ARRAY_A);
    48314831
    48324832                if ( !$actual_post )
    48334833                        return new IXR_Error(404, __('Sorry, no such post.'));
    class wp_xmlrpc_server extends IXR_Server { 
    48744874
    48754875                do_action('xmlrpc_call', 'mt.publishPost');
    48764876
    4877                 $postdata = wp_get_single_post($post_ID, ARRAY_A);
     4877                $postdata = get_post($post_ID, ARRAY_A);
    48784878                if ( ! $postdata )
    48794879                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    48804880
    class wp_xmlrpc_server extends IXR_Server { 
    50885088                        return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.'));
    50895089                }
    50905090
    5091                 $actual_post = wp_get_single_post($post_ID, ARRAY_A);
     5091                $actual_post = get_post($post_ID, ARRAY_A);
    50925092
    50935093                if ( !$actual_post ) {
    50945094                        // No such post = resource not found
  • wp-includes/deprecated.php

    diff --git wp-includes/deprecated.php wp-includes/deprecated.php
    index def4722..3deb0e3 100644
    function sticky_class( $post_id = null ) { 
    32033203 */
    32043204function _get_post_ancestors( &$post ) {
    32053205        _deprecated_function( __FUNCTION__, '3.5' );
    3206 }
    3207  No newline at end of file
     3206}
     3207
     3208/**
     3209 * Retrieve a single post, based on post ID.
     3210 *
     3211 * Has categories in 'post_category' property or key. Has tags in 'tags_input'
     3212 * property or key.
     3213 *
     3214 * @since 1.0.0
     3215 * @deprecated 3.5.0
     3216 * @see get_post()
     3217 *
     3218 * @param int $postid Post ID.
     3219 * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
     3220 * @return object|array Post object or array holding post contents and information
     3221 */
     3222function wp_get_single_post( $postid = 0, $mode = OBJECT ) {
     3223        _deprecated_function( __FUNCTION__, '3.5', 'get_post()' );
     3224        return get_post( $postid, $mode, 'edit' );
     3225}
     3226
  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index 7aed6b5..e7de852 100644
    final class WP_Post { 
    475475                if ( 'ancestors' == $key )
    476476                        return true;
    477477
     478                if ( 'page_template' == $key )
     479                        return ( 'page' == $this->post_type );
     480
     481                if ( 'post_category' == $key )
     482                   return true;
     483
     484                if ( 'tags_input' == $key )
     485                   return true;
     486
    478487                return metadata_exists( 'post', $this->ID, $key );
    479488        }
    480489
    481490        public function &__get( $key ) {
     491                if ( 'page_template' == $key && $this->__isset( $key ) ) {
     492                        $_ref = get_post_meta( $this->ID, '_wp_page_template', true );
     493                }
     494
     495                if ( 'post_category' == $key ) {
     496                        if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) {
     497                                $_ref = wp_get_post_categories( $this->ID );
     498                        } else {
     499                                $_ref = array();
     500                        }
     501                }
     502
     503                if ( 'tags_input' == $key ) {
     504                        if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) {
     505                                $_ref = wp_get_post_tags( $this->ID, array( 'fields' => 'names' ) );
     506                        } else {
     507                                $_ref = array();
     508                        }
     509                }
     510
     511                if ( isset( $_ref ) )
     512                        return $_ref;
     513
     514                // Rest of the values need filtering
     515
    482516                if ( 'ancestors' == $key ) {
    483517                        $value = get_post_ancestors( $this );
    484518                } else {
    final class WP_Post { 
    504538
    505539        public function to_array() {
    506540                $post = get_object_vars( $this );
    507                 $post['ancestors'] = array();
     541
     542                foreach ( array( 'ancestors', 'page_template', 'post_category', 'tags_input' ) as $key ) {
     543                        if ( $this->__isset( $key ) )
     544                                $post[ $key ] = $this->__get( $key );
     545                }
    508546
    509547                return $post;
    510548        }
    function wp_trash_post($post_id = 0) { 
    22262264        if ( !EMPTY_TRASH_DAYS )
    22272265                return wp_delete_post($post_id, true);
    22282266
    2229         if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
     2267        if ( !$post = get_post($post_id, ARRAY_A) )
    22302268                return $post;
    22312269
    22322270        if ( $post['post_status'] == 'trash' )
    function wp_trash_post($post_id = 0) { 
    22582296 * @return mixed False on failure
    22592297 */
    22602298function wp_untrash_post($post_id = 0) {
    2261         if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
     2299        if ( !$post = get_post($post_id, ARRAY_A) )
    22622300                return $post;
    22632301
    22642302        if ( $post['post_status'] != 'trash' )
    function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) { 
    24892527}
    24902528
    24912529/**
    2492  * Retrieve a single post, based on post ID.
    2493  *
    2494  * Has categories in 'post_category' property or key. Has tags in 'tags_input'
    2495  * property or key.
    2496  *
    2497  * @since 1.0.0
    2498  *
    2499  * @param int $postid Post ID.
    2500  * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
    2501  * @return object|array Post object or array holding post contents and information
    2502  */
    2503 function wp_get_single_post($postid = 0, $mode = OBJECT) {
    2504         $postid = (int) $postid;
    2505 
    2506         $post = get_post($postid, $mode);
    2507 
    2508         if (
    2509                 ( OBJECT == $mode && empty( $post->ID ) ) ||
    2510                 ( OBJECT != $mode && empty( $post['ID'] ) )
    2511         )
    2512                 return ( OBJECT == $mode ? null : array() );
    2513 
    2514         // Set categories and tags
    2515         if ( $mode == OBJECT ) {
    2516                 $post->post_category = array();
    2517                 if ( is_object_in_taxonomy($post->post_type, 'category') )
    2518                         $post->post_category = wp_get_post_categories($postid);
    2519                 $post->tags_input = array();
    2520                 if ( is_object_in_taxonomy($post->post_type, 'post_tag') )
    2521                         $post->tags_input = wp_get_post_tags($postid, array('fields' => 'names'));
    2522         } else {
    2523                 $post['post_category'] = array();
    2524                 if ( is_object_in_taxonomy($post['post_type'], 'category') )
    2525                         $post['post_category'] = wp_get_post_categories($postid);
    2526                 $post['tags_input'] = array();
    2527                 if ( is_object_in_taxonomy($post['post_type'], 'post_tag') )
    2528                         $post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names'));
    2529         }
    2530 
    2531         return $post;
    2532 }
    2533 
    2534 /**
    25352530 * Insert a post.
    25362531 *
    25372532 * If the $postarr parameter has 'ID' set to a value, then post will be updated.
    function wp_update_post( $postarr = array(), $wp_error = false ) { 
    28322827        }
    28332828
    28342829        // First, get all of the original fields
    2835         $post = wp_get_single_post($postarr['ID'], ARRAY_A);
     2830        $post = get_post($postarr['ID'], ARRAY_A);
    28362831
    28372832        // Escape data pulled from DB.
    28382833        $post = add_magic_quotes($post);
    function get_to_ping($post_id) { 
    32413236function trackback_url_list($tb_list, $post_id) {
    32423237        if ( ! empty( $tb_list ) ) {
    32433238                // get post data
    3244                 $postdata = wp_get_single_post($post_id, ARRAY_A);
     3239                $postdata = get_post($post_id, ARRAY_A);
    32453240
    32463241                // import postdata as variables
    32473242                extract($postdata, EXTR_SKIP);