remove parent theme templates post 3.4
-
function remove_template( $files_to_delete = array() ){ global $wp_themes; if ( is_scalar( $files_to_delete ) ) $files_to_delete = array( $files_to_delete ); $files_to_delete = preg_replace( "/\.[^.]+$/", '', $files_to_delete ); get_themes(); $current_theme_name = get_current_theme(); $template_files = &$wp_themes[$current_theme_name]['Template Files']; foreach ( $template_files as $file_path ){ foreach( $files_to_delete as $file_name ){ if ( preg_match( '/\/'.$file_name.'\.[^.]+$/', $file_path ) ){ $key = array_search( $file_path, $template_files ); if ( $key ) unset ( $template_files[$key] ); } } } } add_action( 'admin_head', 'remove_parent_templates' ); function remove_parent_templates() { remove_template( array( "showcase.php", "sidebar-page.php" ) ); }This code used to nicely remove parent theme templates from the array of templates available to a child theme. Since the 3.4 update, this no longer works. If you look at the array of templates, this code does remove them, none of these functions have been deprecated, however the way WP uses $wp_themes must be different.
If you create/edit a page, in the drop down list of template options you will see your child theme templates and parent theme templates, even though this code should have removed those parent templates.
Does anyone know of a solution to this, other than physically removing the parent theme templates?
The topic ‘remove parent theme templates post 3.4’ is closed to new replies.