Changeset 41887 for trunk/src/wp-includes/theme.php
- Timestamp:
- 10/17/2017 08:14:56 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/theme.php
r41824 r41887 3052 3052 3053 3053 /** 3054 * Make sure that auto-draft posts get their post_date bumped to prevent premature garbage-collection.3054 * Make sure that auto-draft posts get their post_date bumped or status changed to draft to prevent premature garbage-collection. 3055 3055 * 3056 3056 * When a changeset is updated but remains an auto-draft, ensure the post_date … … 3061 3061 * unless the changeset post itself is deleted. 3062 3062 * 3063 * When a changeset is updated to be a persistent draft or to be scheduled for 3064 * publishing, then transition any dependent auto-drafts to a draft status so 3065 * that they likewise will not be garbage-collected but also so that they can 3066 * be edited in the admin before publishing since there is not yet a post/page 3067 * editing flow in the Customizer. See #39752. 3068 * 3069 * @link https://core.trac.wordpress.org/ticket/39752 3070 * 3063 3071 * @since 4.8.0 3064 3072 * @access private … … 3079 3087 } 3080 3088 3089 $data = json_decode( $post->post_content, true ); 3090 if ( empty( $data['nav_menus_created_posts']['value'] ) ) { 3091 return; 3092 } 3093 3094 /* 3095 * Actually, in lieu of keeping alive, trash any customization drafts here if the changeset itself is 3096 * getting trashed. This is needed because when a changeset transitions to a draft, then any of the 3097 * dependent auto-draft post/page stubs will also get transitioned to customization drafts which 3098 * are then visible in the WP Admin. We cannot wait for the deletion of the changeset in which 3099 * _wp_delete_customize_changeset_dependent_auto_drafts() will be called, since they need to be 3100 * trashed to remove from visibility immediately. 3101 */ 3102 if ( 'trash' === $new_status ) { 3103 foreach ( $data['nav_menus_created_posts']['value'] as $post_id ) { 3104 if ( ! empty( $post_id ) && 'draft' === get_post_status( $post_id ) ) { 3105 wp_trash_post( $post_id ); 3106 } 3107 } 3108 return; 3109 } 3110 3111 $post_args = array(); 3081 3112 if ( 'auto-draft' === $new_status ) { 3082 3113 /* … … 3084 3115 * so that it will not be garbage-collected before the changeset. 3085 3116 */ 3086 $ new_post_date = $post->post_date;3117 $post_args['post_date'] = $post->post_date; // Note wp_delete_auto_drafts() only looks at this date. 3087 3118 } else { 3088 3119 /* 3089 3120 * Since the changeset no longer has an auto-draft (and it is not published) 3090 3121 * it is now a persistent changeset, a long-lived draft, and so any 3091 * associated auto-draft posts should have their dates 3092 * pushed out very far into the future to prevent them from ever 3093 * being garbage-collected. 3122 * associated auto-draft posts should likewise transition into having a draft 3123 * status. These drafts will be treated differently than regular drafts in 3124 * that they will be tied to the given changeset. The publish metabox is 3125 * replaced with a notice about how the post is part of a set of customized changes 3126 * which will be published when the changeset is published. 3094 3127 */ 3095 $new_post_date = gmdate( 'Y-m-d H:i:d', strtotime( '+100 years' ) ); 3096 } 3097 3098 $data = json_decode( $post->post_content, true ); 3099 if ( empty( $data['nav_menus_created_posts']['value'] ) ) { 3100 return; 3101 } 3128 $post_args['post_status'] = 'draft'; 3129 } 3130 3102 3131 foreach ( $data['nav_menus_created_posts']['value'] as $post_id ) { 3103 3132 if ( empty( $post_id ) || 'auto-draft' !== get_post_status( $post_id ) ) { … … 3106 3135 $wpdb->update( 3107 3136 $wpdb->posts, 3108 array( 'post_date' => $new_post_date ), // Note wp_delete_auto_drafts() only looks at this date.3137 $post_args, 3109 3138 array( 'ID' => $post_id ) 3110 3139 );
Note: See TracChangeset
for help on using the changeset viewer.