[wp-hackers] Safe location for "fallback" theme
Peter Westwood
peter.westwood at ftwr.co.uk
Wed Apr 21 07:03:09 UTC 2010
On 20 Apr 2010, at 20:03, Stephen Rider wrote:
> I came across an issue today, and after finally figuring out the problem I thought I'd run this past y'all. Needs a code fix, IMO.
>
> I installed a new WordPress site, went into admin and started configuring settings. After a bit I popped over to the main site URL to see how it was all looking.
>
> Blank page.
>
> Huh. That's weird. I thought it might be something to do with my putting the WordPress files in their own directory, so I monkeyed with that for a while. No dice. Checking database settings, the SiteURL setting, etc. No luck.
>
> Finally I discovered that the problem was that the "default" theme was not in the theme directory (long story short: there was a filter set in the FTP program). The site was set to "Default" theme, but the theme was missing. Because "Default" is the fallback theme if a theme is missing, it was falling back on its own nonexistent self and thus showing a blank page.
>
> I have a plugin that makes pull-quotes, and in coding the "style" functionality therein, I came across the same issues regarding fallback, and here is the solution that I finally implemented there:
>
> 1) Theme directory has default theme and whatever else comes with the system.
>
> 2) A complete second copy of the default theme exists in a completely different location not likely to be modified by user (/wp-includes perhaps?)
>
> 3) The "hidden" copy is the ultimate fallback. If a selected theme is missing, fall back to the "default" in the theme directory. If THAT is missing, fall back to the hidden "safe copy" of the default theme.
>
> I can readily see a site owner removing the default theme, and then being lost if there is a problem with the theme he's using. I think this would be a worthwhile addition to the core.
>
> What say you all?
>
This is the /standard/ behaviour if you delete your theme - whatever your theme is and has been for a while
From memory we ended up with this because in the past we used to auto-switch to the /default/ theme when we couldn't find the theme folder on the disk unfortunately this had the behaviour on a number of hosts (I think where NFS is involved) of randomly switching peoples themes back to /default/ which is definitely not desirable.
We shouldn't be moving / duplicating the current fallback theme and don't forget it doesn't have to be twentyten - see WP_FALLBACK_THEME and validate_current_theme()
What we could and maybe should do is display a (possibly customisable) error page if we can't find the current theme on the front-end - this could then provide you with a link to the Themes section in the Administration to allow you to go and fix the issue
Cheers
Peter
--
Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5
More information about the wp-hackers
mailing list