WordPress.org

Plugin Directory

Changeset 533639


Ignore:
Timestamp:
04/19/12 17:14:05 (2 years ago)
Author:
pross
Message:

Added 3.3 => 3.4 compat layer.

Location:
theme-check/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • theme-check/trunk/checkbase.php

    r503927 r533639  
    256256    return array( 'Name' => $theme, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Author_URI' => $author_uri, 'Version' => $version, 'Template' => $template, 'Status' => $status, 'Tags' => $tags ); 
    257257} 
     258 
     259/* 
     260 * 3.3/3.4 compat 
     261 * 
     262 */ 
     263function tc_get_themes() { 
     264     
     265    if ( ! class_exists( 'WP_Theme' ) ) 
     266        return get_themes(); 
     267 
     268    global $wp_themes; 
     269    if ( isset( $wp_themes ) ) 
     270        return $wp_themes; 
     271 
     272    $themes = wp_get_themes(); 
     273    $wp_themes = array(); 
     274 
     275    foreach ( $themes as $theme ) { 
     276        $name = $theme->get('Name'); 
     277        if ( isset( $wp_themes[ $name ] ) ) 
     278            $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; 
     279        else 
     280            $wp_themes[ $name ] = $theme; 
     281    } 
     282 
     283    return $wp_themes;   
     284} 
     285 
     286function tc_get_theme_data( $theme_file ) { 
     287     
     288    if ( ! class_exists( 'WP_Theme' ) ) 
     289        return get_theme_data( $theme_file ); 
     290 
     291    $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) ); 
     292 
     293    $theme_data = array( 
     294        'Name' => $theme->get('Name'), 
     295        'URI' => $theme->display('ThemeURI', true, false), 
     296        'Description' => $theme->display('Description', true, false), 
     297        'Author' => $theme->display('Author', true, false), 
     298        'AuthorURI' => $theme->display('AuthorURI', true, false), 
     299        'Version' => $theme->get('Version'), 
     300        'Template' => $theme->get('Template'), 
     301        'Status' => $theme->get('Status'), 
     302        'Tags' => $theme->get('Tags'), 
     303        'Title' => $theme->get('Name'), 
     304        'AuthorName' => $theme->display('Author', false, false), 
     305    ); 
     306 
     307    return $theme_data; 
     308} 
  • theme-check/trunk/main.php

    r503927 r533639  
    55    $theme = get_theme_root( $theme ) . "/$theme"; 
    66    $files = listdir( $theme ); 
    7     $data = get_theme_data( $theme . '/style.css' ); 
     7    $data = tc_get_theme_data( $theme . '/style.css' ); 
    88    if ( $data[ 'Template' ] ) { 
    99        // This is a child theme, so we need to pull files from the parent, which HAS to be installed. 
    1010        $parent = get_theme_root( $data[ 'Template' ] ) . '/' . $data['Template']; 
    11         if ( !get_theme_data( $parent . '/style.css' ) ) { // This should never happen but we will check while were here! 
     11        if ( ! tc_get_theme_data( $parent . '/style.css' ) ) { // This should never happen but we will check while were here! 
    1212            echo '<h2>' . sprintf(__('Parent theme <strong>%1$s</strong> not found! You have to have parent AND child-theme installed!', 'themecheck'), $data[ 'Template' ] ) . '</h2>'; 
    1313            return; 
    1414        } 
    15         $parent_data = get_theme_data( $parent . '/style.css' ); 
     15        $parent_data = tc_get_theme_data( $parent . '/style.css' ); 
    1616        $themename = basename( $parent ); 
    1717        $files = array_merge( listdir( $parent ), $files ); 
     
    125125 
    126126function tc_form() { 
    127     $themes = get_themes(); 
     127    $themes = tc_get_themes(); 
    128128    echo '<form action="themes.php?page=themecheck" method="post">'; 
    129129    echo '<select name="themename">'; 
Note: See TracChangeset for help on using the changeset viewer.