Changeset 29097
- Timestamp:
- 07/11/2014 06:34:36 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r29094 r29097 392 392 } 393 393 394 // ` leading and trailing whitespace394 // leading and trailing whitespace. 395 395 $main = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $main); 396 396 $extended = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $extended); … … 872 872 return 'private'; 873 873 874 // Unattached attachments are assumed to be published 874 // Unattached attachments are assumed to be published. 875 875 if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) ) 876 876 return 'publish'; 877 877 878 // Inherit status from the parent 878 // Inherit status from the parent. 879 879 if ( $post->post_parent && ( $post->ID != $post->post_parent ) ) { 880 880 $parent_post_status = get_post_status( $post->post_parent ); … … 1363 1363 $args->exclude_from_search = !$args->public; 1364 1364 1365 // Back compat with quirky handling in version 3.0. #14122 1365 // Back compat with quirky handling in version 3.0. #14122. 1366 1366 if ( empty( $args->capabilities ) && null === $args->map_meta_cap && in_array( $args->capability_type, array( 'post', 'page' ) ) ) 1367 1367 $args->map_meta_cap = true; … … 1697 1697 foreach ( get_post_types( array( 'show_ui' => true ) ) as $ptype ) { 1698 1698 $ptype_obj = get_post_type_object( $ptype ); 1699 // Sub menus only.1699 // Sub-menus only. 1700 1700 if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true ) 1701 1701 continue; … … 1949 1949 */ 1950 1950 function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) { 1951 // make sure meta is added to the post, not a revision1951 // Make sure meta is added to the post, not a revision. 1952 1952 if ( $the_post = wp_is_post_revision($post_id) ) 1953 1953 $post_id = $the_post; … … 2592 2592 2593 2593 if ( is_post_type_hierarchical( $post->post_type ) ) { 2594 // Point children of this page to its parent, also clean the cache of affected children 2594 // Point children of this page to its parent, also clean the cache of affected children. 2595 2595 $children_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid, $post->post_type ); 2596 2596 $children = $wpdb->get_results( $children_query ); … … 2599 2599 } 2600 2600 2601 // Do raw query. wp_get_post_revisions() is filtered 2601 // Do raw query. wp_get_post_revisions() is filtered. 2602 2602 $revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) ); 2603 2603 // Use wp_delete_post (via wp_delete_post_revision) again. Ensures any meta/misplaced data gets cleaned up. … … 2605 2605 wp_delete_post_revision( $revision_id ); 2606 2606 2607 // Point all attachments to this post up one level 2607 // Point all attachments to this post up one level. 2608 2608 $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) ); 2609 2609 … … 2675 2675 $post = get_post( $post_id ); 2676 2676 if ( 'page' == $post->post_type ) { 2677 // If the page is defined in option page_on_front or post_for_posts, 2678 // adjust the corresponding options 2677 /* 2678 * If the page is defined in option page_on_front or post_for_posts, 2679 * adjust the corresponding options. 2680 */ 2679 2681 if ( get_option( 'page_on_front' ) == $post->ID ) { 2680 2682 update_option( 'show_on_front', 'posts' ); … … 2821 2823 return; 2822 2824 2823 // Cache current status for each comment 2825 // Cache current status for each comment. 2824 2826 $statuses = array(); 2825 2827 foreach ( $comments as $comment ) … … 2827 2829 add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses); 2828 2830 2829 // Set status for all comments to post-trashed 2831 // Set status for all comments to post-trashed. 2830 2832 $result = $wpdb->update($wpdb->comments, array('comment_approved' => 'post-trashed'), array('comment_post_ID' => $post_id)); 2831 2833 … … 2876 2878 do_action( 'untrash_post_comments', $post_id ); 2877 2879 2878 // Restore each comment to its original status 2880 // Restore each comment to its original status. 2879 2881 $group_by_status = array(); 2880 2882 foreach ( $statuses as $comment_id => $comment_status ) … … 2995 2997 } 2996 2998 2997 // Set default arguments 2999 // Set default arguments. 2998 3000 $defaults = array( 2999 3001 'numberposts' => 10, 'offset' => 0, … … 3009 3011 $results = get_posts( $r ); 3010 3012 3011 // Backward compatibility. Prior to 3.1 expected posts to be returned in array 3013 // Backward compatibility. Prior to 3.1 expected posts to be returned in array. 3012 3014 if ( ARRAY_A == $output ){ 3013 3015 foreach( $results as $key => $result ) { … … 3527 3529 function wp_update_post( $postarr = array(), $wp_error = false ) { 3528 3530 if ( is_object($postarr) ) { 3529 // non-escaped post was passed3531 // Non-escaped post was passed. 3530 3532 $postarr = get_object_vars($postarr); 3531 3533 $postarr = wp_slash($postarr); … … 3635 3637 $time = strtotime( $post->post_date_gmt . ' GMT' ); 3636 3638 3637 if ( $time > time() ) { // Uh oh, someone jumped the gun! 3639 // Uh oh, someone jumped the gun! 3640 if ( $time > time() ) { 3638 3641 wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) ); // clear anything else in the system 3639 3642 wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) ); … … 3989 3992 $new = apply_filters( 'add_ping', $new ); 3990 3993 3991 // expected_slashed ($new) 3994 // expected_slashed ($new). 3992 3995 $new = wp_unslash($new); 3993 3996 return $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post_id ) ); … … 4093 4096 function trackback_url_list( $tb_list, $post_id ) { 4094 4097 if ( ! empty( $tb_list ) ) { 4095 // get post data4098 // Get post data. 4096 4099 $postdata = get_post( $post_id, ARRAY_A ); 4097 4100 4098 // form an excerpt4101 // Form an excerpt. 4099 4102 $excerpt = strip_tags( $postdata['post_excerpt'] ? $postdata['post_excerpt'] : $postdata['post_content'] ); 4100 4103 … … 4432 4435 $post_status = $r['post_status']; 4433 4436 4434 // Make sure the post type is hierarchical 4437 // Make sure the post type is hierarchical. 4435 4438 $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); 4436 4439 if ( ! in_array( $r['post_type'], $hierarchical_post_types ) ) { … … 4442 4445 } 4443 4446 4444 // Make sure we have a valid post status 4447 // Make sure we have a valid post status. 4445 4448 if ( ! is_array( $post_status ) ) { 4446 4449 $post_status = explode( ',', $post_status ); … … 4450 4453 } 4451 4454 4452 // $args can be whatever, only use the args defined in defaults to compute the key 4455 // $args can be whatever, only use the args defined in defaults to compute the key. 4453 4456 $key = md5( serialize( wp_array_slice_assoc( $r, array_keys( $defaults ) ) ) ); 4454 4457 $last_changed = wp_cache_get( 'last_changed', 'posts' ); … … 4460 4463 $cache_key = "get_pages:$key:$last_changed"; 4461 4464 if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) { 4462 // Convert to WP_Post instances 4465 // Convert to WP_Post instances. 4463 4466 $pages = array_map( 'get_post', $cache ); 4464 4467 /** This filter is documented in wp-includes/post.php */ … … 4609 4612 } 4610 4613 4611 // Sanitize before caching so it'll only get done once 4614 // Sanitize before caching so it'll only get done once. 4612 4615 $num_pages = count($pages); 4613 4616 for ($i = 0; $i < $num_pages; $i++) { … … 4646 4649 wp_cache_set( $cache_key, $page_structure, 'posts' ); 4647 4650 4648 // Convert to WP_Post instances 4651 // Convert to WP_Post instances. 4649 4652 $pages = array_map( 'get_post', $pages ); 4650 4653 … … 4781 4784 wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type)); 4782 4785 4783 delete_metadata( 'post', null, '_thumbnail_id', $post_id, true ); // delete all for any posts. 4786 // Delete all for any posts. 4787 delete_metadata( 'post', null, '_thumbnail_id', $post_id, true ); 4784 4788 4785 4789 $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id )); … … 5273 5277 $sql .= "(post_status = 'publish'"; 5274 5278 5275 // Only need to check the cap if $public_only is false 5279 // Only need to check the cap if $public_only is false. 5276 5280 if ( false === $public_only ) { 5277 5281 if ( current_user_can( $cap ) ) { … … 5593 5597 5594 5598 if ( $old_status != 'publish' && $new_status == 'publish' ) { 5595 // Reset GUID if transitioning to publish and it is empty 5599 // Reset GUID if transitioning to publish and it is empty. 5596 5600 if ( '' == get_the_guid($post->ID) ) 5597 5601 $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) ); … … 5608 5612 } 5609 5613 5610 // If published posts changed clear the lastpostmodified cache 5614 // If published posts changed clear the lastpostmodified cache. 5611 5615 if ( 'publish' == $new_status || 'publish' == $old_status) { 5612 5616 foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) { … … 5707 5711 */ 5708 5712 function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) { 5709 // Nothing fancy here - bail 5713 // Nothing fancy here - bail. 5710 5714 if ( !$post_parent ) 5711 5715 return 0; 5712 5716 5713 // New post can't cause a loop 5717 // New post can't cause a loop. 5714 5718 if ( empty( $post_ID ) ) 5715 5719 return $post_parent; 5716 5720 5717 // Can't be its own parent 5721 // Can't be its own parent. 5718 5722 if ( $post_parent == $post_ID ) 5719 5723 return 0; 5720 5724 5721 // Now look for larger loops 5722 5725 // Now look for larger loops. 5723 5726 if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) ) 5724 5727 return $post_parent; // No loop 5725 5728 5726 // Setting $post_parent to the given value causes a loop 5729 // Setting $post_parent to the given value causes a loop. 5727 5730 if ( isset( $loop[$post_ID] ) ) 5728 5731 return 0; … … 5790 5793 5791 5794 /** 5792 * Update the custom taxonomies' term counts when a post's status is changed. For example, default posts term counts (for custom taxonomies) don't include private / draft posts. 5795 * Update the custom taxonomies' term counts when a post's status is changed. 5796 * 5797 * For example, default posts term counts (for custom taxonomies) don't include 5798 * private / draft posts. 5793 5799 * 5794 5800 * @since 3.3.0 … … 5811 5817 * 5812 5818 * @since 3.4.0 5813 *5814 5819 * @access private 5820 * 5821 * @see update_post_caches() 5815 5822 * 5816 5823 * @param array $post_ids ID list
Note: See TracChangeset
for help on using the changeset viewer.