Plugin Directory

Changeset 460035


Ignore:
Timestamp:
11/06/2011 08:33:08 PM (14 years ago)
Author:
vancoder
Message:

fixed PHP version issue

Location:
rehabtabs/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rehabtabs/trunk/options.php

    r457203 r460035  
    2323
    2424function rehabtabs_theme_callback() {
     25    $options = get_option( 'rehabtabs_options' );
    2526    echo '<select name="rehabtabs_options[theme]" id="theme" class="postform">';
    2627    rehabtabs_scan_themes();
     
    3233    $options = get_option( 'rehabtabs_options' );
    3334    $themes_directory = plugin_dir_path( __FILE__ ) . 'themes';
    34     $themes = new DirectoryIterator( $themes_directory );
    35     foreach ( $themes as $theme ) {
    36         if ( $theme->isDir() && !$theme->isDot() ) {
    37             $theme_items = new FilesystemIterator( $themes_directory . '/' . $theme );
    38             foreach ( $theme_items as $theme_item ) {
    39                 if ( pathinfo( $theme_item->getFilename(), PATHINFO_EXTENSION ) == 'css' ) {
    40                     $theme_path = $theme . '/' . $theme_item->getFilename();
     35    if ( class_exists( FilesystemIterator ) ) {
     36        $themes = new DirectoryIterator( $themes_directory );
     37        foreach ( $themes as $theme ) {
     38            if ( $theme->isDir() && !$theme->isDot() ) {
     39                $theme_items = new FilesystemIterator( $themes_directory . '/' . $theme );
     40                foreach ( $theme_items as $theme_item ) {
     41                    if ( pathinfo( $theme_item->getFilename(), PATHINFO_EXTENSION ) == 'css' ) {
     42                        $theme_path = $theme . '/' . $theme_item->getFilename();
     43                        if ( $get_default )
     44                            return $theme_path;
     45                        echo '<option value="' . $theme_path . '"' . selected( $options['theme'], $theme_path, false ) . '>' . ucfirst( $theme ) . '</option>';
     46                    }
     47                }
     48            }
     49        }
     50    } else {
     51        // Alternative method for PHP version < 5.3.0
     52        $themes = scandir( $themes_directory );
     53        foreach ( $themes as $theme ) {
     54            if ( is_dir( $themes_directory . '/' . $theme ) ) {
     55                foreach ( glob( $themes_directory . '/' . $theme . '/*.css' ) as $theme_item ) {
     56                    $path_parts = pathinfo( $theme_item );
     57                    $theme_path = $theme . '/' . $path_parts['filename'] . '.css';
    4158                    if ( $get_default )
    4259                        return $theme_path;
     
    4663        }
    4764    }
    48     echo '<option value="none"' . selected( $options['theme'], 'none' ) . '>None. I\'ll handle the theme myself.</option>';
    49     echo '</select>';
     65
    5066}
    5167
  • rehabtabs/trunk/rehabtabs.php

    r457203 r460035  
    55  Plugin URI: http://vancoder.ca/plugins/rehabtabs
    66  Description: Use jQuery UI tabs in posts and pages..
    7   Version: 0.1
     7  Version: 1.0
    88  Author: vancoder
    99  Author URI: http://vancoder.ca
Note: See TracChangeset for help on using the changeset viewer.