Ticket #11049: preview_template.diff
File preview_template.diff, 2.1 KB (added by , 14 years ago) |
---|
-
wp-includes/post.php
2592 2592 2593 2593 $post = get_post($post_ID); 2594 2594 2595 if ( !empty($page_template) && 'page' == $data['post_type']) {2595 if ( !empty($page_template) && (('page' == $data['post_type']) || ('revision' == $data['post_type'])) ) { 2596 2596 $post->page_template = $page_template; 2597 2597 $page_templates = get_page_templates(); 2598 2598 if ( 'default' != $page_template && !in_array($page_template, $page_templates) ) { … … 2601 2601 else 2602 2602 return 0; 2603 2603 } 2604 update_post_meta($post_ID, '_wp_page_template', $page_template); 2604 if ( 'page' == $data['post_type'] ) { 2605 update_post_meta($post_ID, '_wp_page_template', $page_template); 2606 } elseif ('revision' == $data['post_type'] ) { 2607 //update the meta for autosave, page preview 2608 update_post_meta($post_ID, '_wp_preview_page_template', $page_template); 2609 } 2605 2610 } 2606 2611 2607 2612 wp_transition_post_status($data['post_status'], $previous_status, $post); … … 4629 4634 $return['post_name'] = $autosave ? "$post[ID]-autosave" : "$post[ID]-revision"; 4630 4635 $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : ''; 4631 4636 $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : ''; 4637 4638 if ( $autosave ) { 4639 $return['page_template'] = isset($post['page_template']) ? $post['page_template'] : 'default'; 4640 } 4632 4641 4633 4642 return $return; 4634 4643 } -
wp-includes/theme.php
946 946 */ 947 947 function get_page_template() { 948 948 $id = get_queried_object_id(); 949 $template = get_post_meta($id, '_wp_page_template', true); 949 if ( is_preview() ) { //a page preview may have a different template than the published page 950 $template = get_post_meta($id, '_wp_preview_page_template', true); 951 } else { 952 $template = get_post_meta($id, '_wp_page_template', true); 953 } 950 954 $pagename = get_query_var('pagename'); 951 955 952 956 if ( !$pagename && $id > 0 ) {