Opened 13 years ago
Closed 11 years ago
#18490 closed enhancement (duplicate)
When installing a new theme, check if parent theme is required.
Reported by: | sterlo | Owned by: | nacin |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2.1 |
Component: | Upgrade/Install | Keywords: | needs-patch |
Focuses: | Cc: |
Description
Currently I am able to do the following:
- Upload a child theme.
- Do not have the parent theme installed (for instance, Genesis Framework).
- After the child theme is uploaded...I am presented with the option to activate the child theme. Even though the parent theme does not exist.
The child theme can check this by doing something like this...
function genesis_failed_to_load() { echo '<div id="message" class="error"><p>Unable to locate the Genesis Framework!</p></div>'; } /** Start the engine */ if( file_exists( TEMPLATEPATH . '/lib/init.php' ) ) { require_once( TEMPLATEPATH . '/lib/init.php' ); } else { add_action( 'admin_notices' , 'genesis_failed_to_load' ); return false; }
But knowing most people are not using such code, allowing the activation of a child theme without it's parent theme can lead to site breakage.
Fatal errors, etc.
I propose that upon uploading, prior to providing the activation option, we check to see if the parent theme is installed, if it's not...then mark the theme as broken and don't allow them to activate.
Attachments (5)
Change History (16)
@
13 years ago
Example of the code in the description stopping a fatal error from happening. require_once would have failed.
#1
@
13 years ago
Example of what it can produce:
Failed opening required '/wp-content/themes/genesis/lib/init.php' (include_path='.:/usr/share/php:/usr/share/pear') in /wp-content/themes/child/functions.php on line 3, referer: /wp-admin/update.php?action=upload-theme
#2
@
13 years ago
- Milestone changed from Awaiting Review to 3.3
- Owner set to nacin
- Status changed from new to accepted
We should be able to hide the action link and comment that the parent theme isn't there, if detected.
#6
@
13 years ago
The string needs a bit of tweaking IMO, and it should probably be inserted after the Network Enable section too (I'm thinking Network Enabling shouldn't be possible unless the template exists)
#8
@
13 years ago
- Component changed from Themes to Upgrade/Install
- Keywords needs-patch added; has-patch needs-testing removed
Quick patch review:
- Can't use $wp_filesystem->wp_themes_dir() with get_theme_data - better to just use get_themes() and iterate through.
- Block should be moved further down to unset network enable too
This ticket will be superseded by #13774 (Automatically install the parent theme if possible) and a similar message would probably be included there in the event of the parent not being installable.
It's either this, or #13774 for 3.3
Here I have the option to activate a theme without the parent theme installed.