Make WordPress Core

Changeset 1829


Ignore:
Timestamp:
10/24/2004 11:48:51 PM (20 years ago)
Author:
rboren
Message:

List broken themes and suggest corrective action.

Location:
trunk
Files:
3 edited

Legend:

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

    r1818 r1829  
    573573}
    574574
     575function get_broken_themes() {
     576    global $wp_broken_themes;
     577
     578    get_themes();
     579    return $wp_broken_themes;
     580}
     581
    575582function get_page_templates() {
    576583    $themes = get_themes();
  • trunk/wp-admin/themes.php

    r1818 r1829  
    100100}
    101101?>
     102
     103<?php
     104// List broken themes, if any.
     105$broken_themes = get_broken_themes();
     106if (count($broken_themes)) {
     107?>
     108
     109<h2><?php _e('Broken Themes'); ?></h2>
     110<p><?php _e('The following themes are installed but incomplete.  Themes must have a stylesheet and a template.'); ?></p>
     111
     112<table width="100%" cellpadding="3" cellspacing="3">
     113    <tr>
     114        <th><?php _e('Name'); ?></th>
     115        <th><?php _e('Description'); ?></th>
     116    </tr>
     117<?php
     118    $theme = '';
     119   
     120    $theme_names = array_keys($broken_themes);
     121    natcasesort($theme_names);
     122
     123    foreach ($theme_names as $theme_name) {
     124        $title = $broken_themes[$theme_name]['Title'];
     125        $description = $broken_themes[$theme_name]['Description'];
     126
     127        $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
     128        echo "
     129      <tr $theme>
     130         <td>$title</td>
     131         <td>$description</td>
     132      </tr>";
     133    }
     134?>
     135</table>
     136<?php
     137}
     138?>
     139
    102140</div>
    103141
  • trunk/wp-includes/functions.php

    r1823 r1829  
    19941994function get_themes() {
    19951995    global $wp_themes;
     1996    global $wp_broken_themes;
    19961997
    19971998    if (isset($wp_themes)) {
     
    20002001
    20012002    $themes = array();
     2003    $wp_broken_themes = array();
    20022004    $theme_loc = 'wp-content/themes';
    20032005    $theme_root = ABSPATH . $theme_loc;
     
    20082010        while(($theme_dir = $themes_dir->read()) !== false) {
    20092011            if (is_dir($theme_root . '/' . $theme_dir)) {
     2012                if ($theme_dir == '.' || $theme_dir == '..') {
     2013                    continue;
     2014                }
    20102015                $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
     2016                $found_stylesheet = false;
    20112017                while(($theme_file = $stylish_dir->read()) !== false) {
    20122018                    if ( $theme_file == 'style.css' ) {
    20132019                        $theme_files[] = $theme_dir . '/' . $theme_file;
     2020                        $found_stylesheet = true;
     2021                        break;
    20142022                    }
     2023                }
     2024                if (!$found_stylesheet) {
     2025                    $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
    20152026                }
    20162027            }
     
    20632074        $stylesheet = dirname($theme_file);
    20642075
     2076        if (empty($name)) {
     2077            $name = dirname($theme_file);
     2078            $title = $name;
     2079        }
     2080
    20652081        if (empty($template)) {
    20662082            if (file_exists(dirname("$theme_root/$theme_file/index.php"))) {
     
    20742090
    20752091        if (($template != 'default') && (! file_exists("$theme_root/$template/index.php"))) {
     2092            $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
    20762093            continue;
    2077         }
    2078 
    2079         if (empty($name)) {
    2080             $name = dirname($theme_file);
    2081             $title = $name;
    20822094        }
    20832095       
Note: See TracChangeset for help on using the changeset viewer.