Ticket #15634: 15634.combined.diff
| File 15634.combined.diff, 3.9 KB (added by duck_, 2 years ago) |
|---|
-
trunk/parsers.php
200 200 'categories' => $categories, 201 201 'tags' => $tags, 202 202 'terms' => $terms, 203 'base_url' => $base_url 203 'base_url' => $base_url, 204 'version' => $wxr_version 204 205 ); 205 206 } 206 207 } … … 224 225 ); 225 226 226 227 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; 228 229 $this->authors = $this->posts = $this->term = $this->category = $this->tag = array(); 229 230 230 231 $xml = xml_parser_create( 'UTF-8' ); … … 243 244 } 244 245 xml_parser_free( $xml ); 245 246 246 if ( ! $this->is_wxr_file)247 if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) 247 248 return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); 248 249 249 250 return array( … … 252 253 'categories' => $this->category, 253 254 'tags' => $this->tag, 254 255 'terms' => $this->term, 255 'base_url' => $this->base_url 256 'base_url' => $this->base_url, 257 'version' => $this->wxr_version 256 258 ); 257 259 } 258 260 … … 333 335 $this->base_url = $this->cdata; 334 336 break; 335 337 case 'wp:wxr_version': 336 $this-> is_wxr_file = preg_match( '/^\d+\.\d+$/', $this->cdata );338 $this->wxr_version = $this->cdata; 337 339 break; 338 340 339 341 default: … … 370 372 } 371 373 372 374 function parse( $file ) { 373 $ is_wxr= $in_post = false;375 $wxr_version = $in_post = false; 374 376 375 377 $fp = $this->fopen( $file, 'r' ); 376 378 if ( $fp ) { 377 379 while ( ! $this->feof( $fp ) ) { 378 380 $importline = rtrim( $this->fgets( $fp ) ); 379 381 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]; 382 384 383 385 if ( false !== strpos( $importline, '<wp:base_site_url>' ) ) { 384 386 preg_match( '|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url ); … … 433 435 'categories' => $this->categories, 434 436 'tags' => $this->tags, 435 437 'terms' => $this->terms, 436 'base_url' => $this->base_url 438 'base_url' => $this->base_url, 439 'version' => $wxr_version 437 440 ); 438 441 } 439 442 -
trunk/wordpress-importer.php
35 35 */ 36 36 if ( class_exists( 'WP_Importer' ) ) { 37 37 class WP_Import extends WP_Importer { 38 var $wxr_version = 1.1; // max. supported WXR version 39 38 40 var $id; // WXR attachment ID 39 41 40 42 // information to import from WXR file … … 197 199 return false; 198 200 } 199 201 202 if ( $import_data['version'] > $this->wxr_version ) { 203 echo '<div class="error"><p><strong>'; 204 printf( __( 'This WXR file (version %s) may not be supported by this version of the importer, please try upgrading.', 'wordpress-importer' ), esc_html($import_data['version']) ); 205 echo '</strong></p></div>'; 206 } 207 200 208 $this->get_authors_from_import( $import_data ); 201 209 202 210 return true; … … 903 911 echo '<div class="wrap">'; 904 912 screen_icon(); 905 913 echo '<h2>' . __( 'Import WordPress', 'wordpress-importer' ) . '</h2>'; 914 915 $updates = get_plugin_updates(); 916 $basename = plugin_basename(__FILE__); 917 if ( isset( $updates[$basename] ) ) { 918 $update = $updates[$basename]; 919 echo '<div class="error"><p><strong>'; 920 printf( __( 'A new version (%s) of this importer is available. Please upgrade to ensure compatibility with newer export files.', 'wordpress-importer' ), $update->update->new_version ); 921 echo '</strong></p></div>'; 922 } 906 923 } 907 924 908 925 // Close div.wrap
