WordPress.org

Make WordPress Core

Changeset 4392


Ignore:
Timestamp:
10/13/06 10:33:44 (9 years ago)
Author:
markjaquith
Message:

Code cleanup: wp-includes/theme.php

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/theme.php

    r4194 r4392  
    11<?php 
    22/* 
    3  * Theme/template/stylesheet functions.   
     3 * Theme/template/stylesheet functions. 
    44 */ 
    55 
     
    3333    if ( file_exists("$dir/$locale.css") ) 
    3434        $stylesheet_uri = "$stylesheet_dir_uri/$locale.css"; 
    35     else if ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") ) 
     35    elseif ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") ) 
    3636        $stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css"; 
    3737    else 
     
    8989 
    9090function get_themes() { 
    91     global $wp_themes; 
    92     global $wp_broken_themes; 
     91    global $wp_themes, $wp_broken_themes; 
    9392 
    9493    if ( isset($wp_themes) ) 
     
    103102    $themes_dir = @ dir($theme_root); 
    104103    if ( $themes_dir ) { 
    105         while(($theme_dir = $themes_dir->read()) !== false) { 
     104        while ( ($theme_dir = $themes_dir->read()) !== false ) { 
    106105            if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { 
    107                 if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) { 
     106                if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) 
    108107                    continue; 
    109                 } 
    110108                $stylish_dir = @ dir($theme_root . '/' . $theme_dir); 
    111109                $found_stylesheet = false; 
    112                 while (($theme_file = $stylish_dir->read()) !== false) { 
     110                while ( ($theme_file = $stylish_dir->read()) !== false ) { 
    113111                    if ( $theme_file == 'style.css' ) { 
    114112                        $theme_files[] = $theme_dir . '/' . $theme_file; 
     
    117115                    } 
    118116                } 
    119                 if ( !$found_stylesheet ) { 
     117                if ( !$found_stylesheet ) 
    120118                    $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); 
    121                 } 
    122             } 
    123         } 
    124     } 
    125  
    126     if ( !$themes_dir || !$theme_files ) { 
     119            } 
     120        } 
     121    } 
     122 
     123    if ( !$themes_dir || !$theme_files ) 
    127124        return $themes; 
    128     } 
    129125 
    130126    sort($theme_files); 
    131127 
    132     foreach($theme_files as $theme_file) { 
    133         if ( ! is_readable("$theme_root/$theme_file") ) { 
     128    foreach ( (array) $theme_files as $theme_file ) { 
     129        if ( !is_readable("$theme_root/$theme_file") ) { 
    134130            $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.')); 
    135131            continue; 
     
    138134        $theme_data = get_theme_data("$theme_root/$theme_file"); 
    139135 
    140         $name = $theme_data['Name']; 
    141         $title = $theme_data['Title']; 
     136        $name        = $theme_data['Name']; 
     137        $title       = $theme_data['Title']; 
    142138        $description = wptexturize($theme_data['Description']); 
    143         $version = $theme_data['Version']; 
    144         $author = $theme_data['Author']; 
    145         $template = $theme_data['Template']; 
    146         $stylesheet = dirname($theme_file); 
    147  
    148         foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) { 
     139        $version     = $theme_data['Version']; 
     140        $author      = $theme_data['Author']; 
     141        $template    = $theme_data['Template']; 
     142        $stylesheet  = dirname($theme_file); 
     143 
     144        foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) { 
    149145            if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) { 
    150146                $screenshot = "screenshot.$ext"; 
     
    159155 
    160156        if ( empty($template) ) { 
    161             if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) { 
     157            if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) 
    162158                $template = dirname($theme_file); 
    163             } else { 
     159            else 
    164160                continue; 
    165             } 
    166161        } 
    167162 
     
    176171        $stylesheet_dir = @ dir("$theme_root/$stylesheet"); 
    177172        if ( $stylesheet_dir ) { 
    178             while(($file = $stylesheet_dir->read()) !== false) { 
     173            while ( ($file = $stylesheet_dir->read()) !== false ) { 
    179174                if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) ) 
    180175                    $stylesheet_files[] = "$theme_loc/$stylesheet/$file"; 
     
    223218    $theme_names = array_keys($themes); 
    224219 
    225     foreach ($theme_names as $theme_name) { 
     220    foreach ( (array) $theme_names as $theme_name ) { 
    226221        $themes[$theme_name]['Parent Theme'] = ''; 
    227222        if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) { 
    228             foreach ($theme_names as $parent_theme_name) { 
     223            foreach ( (array) $theme_names as $parent_theme_name ) { 
    229224                if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) { 
    230225                    $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name']; 
     
    257252 
    258253    if ( $themes ) { 
    259         foreach ($theme_names as $theme_name) { 
     254        foreach ( (array) $theme_names as $theme_name ) { 
    260255            if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet && 
    261256                    $themes[$theme_name]['Template'] == $current_template ) { 
     
    301296    if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') ) 
    302297        $template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php'; 
    303     else if ( file_exists(TEMPLATEPATH . "/category.php") ) 
     298    elseif ( file_exists(TEMPLATEPATH . "/category.php") ) 
    304299        $template = TEMPLATEPATH . "/category.php"; 
    305300 
     
    316311    if ( file_exists(TEMPLATEPATH . "/home.php") ) 
    317312        $template = TEMPLATEPATH . "/home.php"; 
    318     else if ( file_exists(TEMPLATEPATH . "/index.php") ) 
     313    elseif ( file_exists(TEMPLATEPATH . "/index.php") ) 
    319314        $template = TEMPLATEPATH . "/index.php"; 
    320315 
     
    331326        $template = ''; 
    332327 
    333     if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") ) 
     328    if ( !empty($template) && file_exists(TEMPLATEPATH . "/$template") ) 
    334329        $template = TEMPLATEPATH . "/$template"; 
    335     else if ( file_exists(TEMPLATEPATH . "/page.php") ) 
     330    elseif ( file_exists(TEMPLATEPATH . "/page.php") ) 
    336331        $template = TEMPLATEPATH . "/page.php"; 
    337332    else 
     
    396391        return true; 
    397392 
    398     if ((get_template() != 'default') && (!file_exists(get_template_directory() . '/index.php'))) { 
     393    if ( get_template() != 'default' && !file_exists(get_template_directory() . '/index.php') ) { 
    399394        update_option('template', 'default'); 
    400395        update_option('stylesheet', 'default'); 
     
    403398    } 
    404399 
    405     if ((get_stylesheet() != 'default') && (!file_exists(get_template_directory() . '/style.css'))) { 
     400    if ( get_stylesheet() != 'default' && !file_exists(get_template_directory() . '/style.css') ) { 
    406401        update_option('template', 'default'); 
    407402        update_option('stylesheet', 'default'); 
Note: See TracChangeset for help on using the changeset viewer.