Ticket #11049: 11049.diff
File 11049.diff, 2.7 KB (added by , 14 years ago) |
---|
-
wp-includes/post.php
2604 2604 $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where ); 2605 2605 2606 2606 $post = get_post($post_ID); 2607 2608 if ( ! empty($page_template) && 'page' == $data['post_type']) {2607 2608 if ( ! empty( $page_template ) && in_array( $data['post_type'], array( 'page', 'revision' ) ) ) { 2609 2609 $post->page_template = $page_template; 2610 2610 $page_templates = get_page_templates(); 2611 if ( 'default' != $page_template && ! in_array($page_template, $page_templates) ) {2611 if ( 'default' != $page_template && ! in_array( $page_template, $page_templates ) ) { 2612 2612 if ( $wp_error ) 2613 return new WP_Error( 'invalid_page_template', __('The page template is invalid.'));2613 return new WP_Error( 'invalid_page_template', __( 'The page template is invalid.' ) ); 2614 2614 else 2615 2615 return 0; 2616 2616 } 2617 update_post_meta($post_ID, '_wp_page_template', $page_template); 2617 if ( 'page' == $data['post_type'] ) { 2618 update_post_meta( $post_ID, '_wp_page_template', $page_template ); 2619 } elseif ( 'revision' == $data['post_type'] ) { 2620 // update the meta for autosave, page preview 2621 // sanity check, only allow this for pages 2622 $revision_parent = get_post( $post->post_parent ); 2623 if ( 'page' == $revision_parent->post_type ) 2624 update_metadata( 'post', $post_ID, '_wp_page_template', $page_template ); 2625 } 2618 2626 } 2619 2627 2620 2628 wp_transition_post_status($data['post_status'], $previous_status, $post); … … 4631 4639 $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : ''; 4632 4640 $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : ''; 4633 4641 4642 if ( $autosave && 'page' == $post['post_type'] ) 4643 $return['page_template'] = isset( $post['page_template'] ) ? $post['page_template'] : 'default'; 4644 4634 4645 return $return; 4635 4646 } 4636 4647 … … 4946 4957 return $revisions; 4947 4958 } 4948 4959 4960 /** 4961 * @access private 4962 */ 4949 4963 function _set_preview($post) { 4950 4964 4951 4965 if ( ! is_object($post) ) … … 4965 4979 return $post; 4966 4980 } 4967 4981 4982 /** 4983 * @access private 4984 */ 4968 4985 function _show_post_preview() { 4969 4986 4970 4987 if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) { … … 4978 4995 } 4979 4996 4980 4997 /** 4998 * @access private 4999 */ 5000 function _show_page_template_preview( $null, $post_id, $meta_key, $single ) { 5001 if ( $meta_key != '_wp_page_template' || ! is_preview() || get_the_ID() != $post_id ) 5002 return; 5003 5004 $preview = wp_get_post_autosave( $post_id ); 5005 return get_post_meta( $preview->ID, '_wp_page_template', true ); 5006 } 5007 5008 /** 4981 5009 * Returns the post's parent's post_ID 4982 5010 * 4983 5011 * @since 3.1.0