Make WordPress Core

Changeset 1675


Ignore:
Timestamp:
09/16/2004 06:09:32 PM (21 years ago)
Author:
rboren
Message:

Revert to default theme if active theme is broken.

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r1655 r1675  
    676676}
    677677
     678function validate_current_theme() {
     679    $theme_loc = 'wp-content/themes';
     680    $theme_root = ABSPATH . $theme_loc;
     681
     682    $template = get_settings('template');
     683    $stylesheet = get_settings('stylesheet');
     684
     685    if (($template != 'default') && (! file_exists("$theme_root/$template/index.php"))) {
     686        update_option('template', 'default');
     687        update_option('stylesheet', 'default');
     688        return false;
     689    }
     690
     691    if (($stylesheet != 'default') && (! file_exists("$theme_root/$stylesheet/style.css"))) {
     692        update_option('template', 'default');
     693        update_option('stylesheet', 'default');
     694        return false;
     695    }
     696
     697    return true;
     698}
     699
    678700?>
  • trunk/wp-admin/themes.php

    r1655 r1675  
    2929?>
    3030
    31 <?php if ( isset($activated) ) : ?>
     31<?php if ( ! validate_current_theme() ) : ?>
     32<div class="updated"><p><?php _e('The active theme is broken.  Reverting to the default theme.'); ?></p></div>
     33<?php elseif ( isset($activated) ) : ?>
    3234<div class="updated"><p><?php _e('New theme activated'); ?></p></div>
    3335<?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.