WordPress.org

Make WordPress Core

Ticket #1845: 1845.diff

File 1845.diff, 1.1 KB (added by morydd, 15 years ago)

update to check if theme is valid, and if not revert to default.

  • template-loader.php

     
    11<?php
    22if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
     3        if ( !file_exists(TEMPLATEPATH . '/index.php') || !file_exists(TEMPLATEPATH . '/style.css')){
     4                if (!file_exists(get_theme_root() . '/default/index.php') || !file_exists(get_theme_root() . '/default/index.php')) {
     5                        echo "There don't seem to be any functional themes installed. The default theme needs to be re-installed at the very least. Need help reinstalling themes? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>.";
     6                } else {
     7                        update_option('template', 'default');
     8                        update_option('stylesheet', 'default');
     9                        do_action('switch_theme', 'Default');
     10                        echo "<a href='";
     11                        echo  $_SERVER['SCRIPT_NAME'];
     12                        echo  $_SERVER['QUERY_STRING'];
     13                        echo '<html><head><meta http-equiv="refresh" content="0" /></head><body>Please Reload This Page</body></html>';
     14                }
     15        }
    316        do_action('template_redirect');
    417        if ( is_feed() ) {
    518                include(ABSPATH . '/wp-feed.php');