Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#14807 closed feature request (worksforme)

Allow Theme Editor to Ignore Parent Templates

Reported by: GamajoTech Owned by:
Priority: normal Milestone:
Component: Editor Version:
Severity: normal Keywords:
Cc:

Description

When a child theme is set to be edited in the Theme Editor, a list of templates from the parent will appear, if not overwritten by identical filenames in the child theme.

However, for theme frameworks, where editing the parent theme templates is bad (as the theme framework may update at any time), there's no way for the parent theme to specify not to include its templates within the list for editing.

Could there be some option for parent themes to specify that their templates should not be available to the Editor, either completely by an option, or by some optional comment tag at the top of each out-of-bounds template file?

Change History (3)

Actually, this may not be needed, as it's technically possible already it seems (props to @CharlesClarkson):

// Add to your functions.php child theme.
add_action('admin_notices', 'theme_files_to_edit');
function theme_files_to_edit() {
    global $themes, $theme, $parent_file, $title;

    // Check to see if we are on the editor page.
    if ( __('Edit Themes') == $title && 'themes.php' == $parent_file ) {

        // Remove the genesis files from the files lists.
        $themes[$theme]['Template Files']   = preg_grep('|/parent-theme/|', $themes[$theme]['Template Files'],   PREG_GREP_INVERT);
        $themes[$theme]['Stylesheet Files'] = preg_grep('|/parent-theme/|', $themes[$theme]['Stylesheet Files'], PREG_GREP_INVERT);

    }
}  
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

See #15672 - we're no longer showing parent templates.

Note: See TracTickets for help on using tickets.