WordPress.org

Plugin Directory

Changeset 344748 for wordpress-importer


Ignore:
Timestamp:
02/13/11 11:22:55 (3 years ago)
Author:
duck_
Message:

Warning if unsupported WXR version or if importer update available, see #WP15634

Location:
wordpress-importer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wordpress-importer/trunk/parsers.php

    r337621 r344748  
    201201            'tags' => $tags, 
    202202            'terms' => $terms, 
    203             'base_url' => $base_url 
     203            'base_url' => $base_url, 
     204            'version' => $wxr_version 
    204205        ); 
    205206    } 
     
    225226 
    226227    function parse( $file ) { 
    227         $this->is_wxr_file = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false; 
     228        $this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false; 
    228229        $this->authors = $this->posts = $this->term = $this->category = $this->tag = array(); 
    229230 
     
    244245        xml_parser_free( $xml ); 
    245246 
    246         if ( ! $this->is_wxr_file ) 
     247        if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) 
    247248            return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); 
    248249 
     
    253254            'tags' => $this->tag, 
    254255            'terms' => $this->term, 
    255             'base_url' => $this->base_url 
     256            'base_url' => $this->base_url, 
     257            'version' => $this->wxr_version 
    256258        ); 
    257259    } 
     
    334336                break; 
    335337            case 'wp:wxr_version': 
    336                 $this->is_wxr_file = preg_match( '/^\d+\.\d+$/', $this->cdata ); 
     338                $this->wxr_version = $this->cdata; 
    337339                break; 
    338340 
     
    371373 
    372374    function parse( $file ) { 
    373         $is_wxr = $in_post = false; 
     375        $wxr_version = $in_post = false; 
    374376 
    375377        $fp = $this->fopen( $file, 'r' ); 
     
    378380                $importline = rtrim( $this->fgets( $fp ) ); 
    379381 
    380                 if ( ! $is_wxr && preg_match( '|<wp:wxr_version>\d+\.\d+</wp:wxr_version>|', $importline ) ) 
    381                     $is_wxr = true; 
     382                if ( ! $wxr_version && preg_match( '|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version ) ) 
     383                    $wxr_version = $version[1]; 
    382384 
    383385                if ( false !== strpos( $importline, '<wp:base_site_url>' ) ) { 
     
    425427        } 
    426428 
    427         if ( ! $is_wxr ) 
     429        if ( ! $wxr_version ) 
    428430            return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); 
    429431 
     
    434436            'tags' => $this->tags, 
    435437            'terms' => $this->terms, 
    436             'base_url' => $this->base_url 
     438            'base_url' => $this->base_url, 
     439            'version' => $wxr_version 
    437440        ); 
    438441    } 
  • wordpress-importer/trunk/wordpress-importer.php

    r339902 r344748  
    66Author: wordpressdotorg 
    77Author URI: http://wordpress.org/ 
    8 Version: 0.3-beta7 
     8Version: 0.3-beta8 
    99License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 
    1010*/ 
     
    3636if ( class_exists( 'WP_Importer' ) ) { 
    3737class WP_Import extends WP_Importer { 
     38    var $max_wxr_version = 1.1; // max. supported WXR version 
     39 
    3840    var $id; // WXR attachment ID 
    3941 
     
    197199            echo esc_html( $import_data->get_error_message() ) . '</p>'; 
    198200            return false; 
     201        } 
     202 
     203        if ( $import_data['version'] > $this->max_wxr_version ) { 
     204            echo '<div class="error"><p><strong>'; 
     205            printf( __( 'This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'wordpress-importer' ), esc_html($import_data['version']) ); 
     206            echo '</strong></p></div>'; 
    199207        } 
    200208 
     
    927935        screen_icon(); 
    928936        echo '<h2>' . __( 'Import WordPress', 'wordpress-importer' ) . '</h2>'; 
     937 
     938        $updates = get_plugin_updates(); 
     939        $basename = plugin_basename(__FILE__); 
     940        if ( isset( $updates[$basename] ) ) { 
     941            $update = $updates[$basename]; 
     942            echo '<div class="error"><p><strong>'; 
     943            printf( __( 'A new version of this importer is available. Please update to version %s to ensure compatibility with newer export files.', 'wordpress-importer' ), $update->update->new_version ); 
     944            echo '</strong></p></div>'; 
     945        } 
    929946    } 
    930947 
Note: See TracChangeset for help on using the changeset viewer.