Ticket #13265: 13265.diff
File 13265.diff, 4.2 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/meta-boxes.php
705 705 <?php 706 706 } // end empty pages check 707 707 } // end hierarchical check. 708 if ( 'page' == $post->post_type && 0 != count( get_page_templates( ) ) ) {708 if ( 'page' == $post->post_type && 0 != count( get_page_templates( $post ) ) ) { 709 709 $template = !empty($post->page_template) ? $post->page_template : false; 710 710 ?> 711 711 <p><strong><?php _e('Template') ?></strong></p> -
wp-admin/includes/template.php
741 741 * @param string $default Optional. The template file name. Default empty. 742 742 */ 743 743 function page_template_dropdown( $default = '' ) { 744 $templates = get_page_templates( );744 $templates = get_page_templates( get_post() ); 745 745 ksort( $templates ); 746 746 foreach ( array_keys( $templates ) as $template ) { 747 747 $selected = selected( $default, $templates[ $template ], false ); -
wp-admin/includes/theme.php
78 78 * 79 79 * @since 1.5.0 80 80 * 81 * @param WP_Post|null $post Optional. The post being edited, provided for context. 81 82 * @return array Key is the template name, value is the filename of the template 82 83 */ 83 function get_page_templates( ) {84 return array_flip( wp_get_theme()->get_page_templates( ) );84 function get_page_templates( $post = null ) { 85 return array_flip( wp_get_theme()->get_page_templates( $post ) ); 85 86 } 86 87 87 88 /** -
wp-includes/class-wp-theme.php
931 931 * @since 3.4.0 932 932 * @access public 933 933 * 934 * @param WP_Post|null $post Optional. The post being edited, provided for context. 934 935 * @return array Array of page templates, keyed by filename, with the value of the translated header name. 935 936 */ 936 public function get_page_templates( ) {937 public function get_page_templates( $post = null ) { 937 938 // If you screw up your current theme and we invalidate your parent, most things still work. Let it slide. 938 939 if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) ) 939 940 return array(); … … 961 962 } 962 963 963 964 if ( $this->parent() ) 964 $page_templates += $this->parent()->get_page_templates( );965 $page_templates += $this->parent()->get_page_templates( $post ); 965 966 966 967 /** 967 968 * Remove or rename page templates for a theme. … … 970 971 * 971 972 * @since 3.9.0 972 973 * 973 * @param array $page_templates Array of page templates. Keys are filenames, 974 * values are translated names. 975 * @param WP_Theme $this The theme object. 974 * @param array $page_templates Array of page templates. Keys are filenames, 975 * values are translated names. 976 * @param WP_Theme $this The theme object. 977 * @param WP_Post|null $post The post being edited, provided for context, or null. 976 978 */ 977 $return = apply_filters( 'page_templates', $page_templates, $this );979 $return = apply_filters( 'page_templates', $page_templates, $this, $post ); 978 980 return array_intersect_assoc( $return, $page_templates ); 979 981 } 980 982 -
wp-includes/post.php
2948 2948 2949 2949 if ( !empty($page_template) && 'page' == $data['post_type'] ) { 2950 2950 $post->page_template = $page_template; 2951 $page_templates = wp_get_theme()->get_page_templates( );2951 $page_templates = wp_get_theme()->get_page_templates( $post ); 2952 2952 if ( 'default' != $page_template && ! isset( $page_templates[ $page_template ] ) ) { 2953 2953 if ( $wp_error ) 2954 2954 return new WP_Error('invalid_page_template', __('The page template is invalid.'));