Ticket #21309: post-to-edit.diff
File post-to-edit.diff, 6.4 KB (added by , 13 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() { 943 943 944 944 /** 945 945 * This was once used to display an 'Insert into Post' button. Now it is deprecated and stubbed. 946 * 946 * 947 947 * @deprecated 3.5.0 948 948 */ 949 949 function _insert_into_post_button( $type ) { … … function _insert_into_post_button( $type ) { 952 952 953 953 /** 954 954 * This was once used to display a media button. Now it is deprecated and stubbed. 955 * 955 * 956 956 * @deprecated 3.5.0 957 957 */ 958 958 function _media_button($title, $icon, $type, $id) { 959 959 _deprecated_function( __FUNCTION__, '3.5' ); 960 960 } 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 */ 971 function 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() { 463 463 } 464 464 465 465 /** 466 * Get an existing post and format it for editing.467 *468 * @since 2.0.0469 *470 * @param unknown_type $id471 * @return unknown472 */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 /**484 466 * Determine if a post exists based on title, content, and date 485 467 * 486 468 * @since 2.0.0 … … function get_available_post_mime_types($type = 'attachment') { 927 909 /** 928 910 * Executes a query for attachments. An array of WP_Query arguments 929 911 * can be passed in, which will override the arguments set by this function. 930 * 912 * 931 913 * @since 2.5.0 932 914 * @uses apply_filters() Calls 'upload_per_page' on posts_per_page argument 933 915 * -
wp-includes/deprecated.php
diff --git wp-includes/deprecated.php wp-includes/deprecated.php index def4722..3deb0e3 100644
function sticky_class( $post_id = null ) { 3203 3203 */ 3204 3204 function _get_post_ancestors( &$post ) { 3205 3205 _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 */ 3222 function 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..39b632e 100644
function get_post( $post, $output = OBJECT, $filter = 'raw' ) { 402 402 403 403 $_post = $_post->filter( $filter ); 404 404 405 if ( 'edit' == $filter ) 406 $_post = new WP_Post_To_Edit( $_post ); 407 405 408 if ( $output == ARRAY_A ) 406 409 return $_post->to_array(); 407 410 elseif ( $output == ARRAY_N ) … … function get_post( $post, $output = OBJECT, $filter = 'raw' ) { 440 443 * @property $comment_count; 441 444 * @property $ancestors; 442 445 */ 443 finalclass WP_Post {446 class WP_Post { 444 447 445 448 public $filter; 446 449 … … final class WP_Post { 511 514 } 512 515 513 516 /** 517 * A WP_Post class, with added magic 518 */ 519 class WP_Post_To_Edit extends WP_Post { 520 521 public function __isset( $key ) { 522 if ( 'page_template' == $key ) 523 return ( 'page' == $this->post_type ); 524 525 if ( 'post_category' == $key ) 526 return true; 527 528 if ( 'tags_input' == $key ) 529 return true; 530 531 return parent::__isset( $key ); 532 } 533 534 public function __get( $key ) { 535 if ( 'page_template' == $key && $this->__isset( $key ) ) 536 return get_post_meta( $this->ID, '_wp_page_template', true ); 537 538 if ( 'post_category' == $key ) { 539 if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) 540 return wp_get_post_categories( $this->ID ); 541 542 return array(); 543 } 544 545 if ( 'tags_input' == $key && $this->__isset( $key ) ) { 546 if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) 547 return wp_get_post_tags( $this->ID, array( 'fields' => 'names' ) ); 548 549 return array(); 550 } 551 552 return parent::__get( $key ); 553 } 554 555 public function to_array() { 556 $post = parent::to_array(); 557 558 foreach ( array( 'page_template', 'post_category', 'tags_input' ) as $key ) { 559 if ( $this->__isset( $key ) ) 560 $post['page_template'] = $this->__get( $key ); 561 } 562 563 return $post; 564 } 565 } 566 567 /** 514 568 * Retrieve ancestors of a post. 515 569 * 516 570 * @since 2.5.0 … … function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) { 2489 2543 } 2490 2544 2491 2545 /** 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.02498 *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 information2502 */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 tags2515 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 /**2535 2546 * Insert a post. 2536 2547 * 2537 2548 * If the $postarr parameter has 'ID' set to a value, then post will be updated.