Changeset 22632 for trunk/wp-admin/import.php
- Timestamp:
- 11/17/2012 07:20:04 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/import.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import.php
r19712 r22632 30 30 ); 31 31 32 $popular_importers = array(); 33 if ( current_user_can('install_plugins') ) 34 $popular_importers = array( 35 'blogger' => array( __('Blogger'), __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), 'install' ), 36 'wpcat2tag' => array(__('Categories and Tags Converter'), __('Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.'), 'install', 'wp-cat2tag' ), 37 'livejournal' => array( __( 'LiveJournal' ), __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), 'install' ), 38 'movabletype' => array( __('Movable Type and TypePad'), __('Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.'), 'install', 'mt' ), 39 'opml' => array( __('Blogroll'), __('Install the blogroll importer to import links in OPML format.'), 'install' ), 40 'rss' => array( __('RSS'), __('Install the RSS importer to import posts from an RSS feed.'), 'install' ), 41 'tumblr' => array( __('Tumblr'), __('Install the Tumblr importer to import posts & media from Tumblr using their API.'), 'install' ), 42 'wordpress' => array( 'WordPress', __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), 'install' ) 43 ); 32 if ( current_user_can( 'install_plugins' ) ) 33 $popular_importers = wp_get_popular_importers(); 34 else 35 $popular_importers = array(); 44 36 45 if ( ! empty( $_GET['invalid'] ) && !empty($popular_importers[$_GET['invalid']][3]) ) { 46 wp_redirect( admin_url('import.php?import=' . $popular_importers[$_GET['invalid']][3]) ); 47 exit; 37 // Detect and redirect invalid importers like 'movabletype', which is registered as 'mt' 38 if ( ! empty( $_GET['invalid'] ) && isset( $popular_importers[ $_GET['invalid'] ] ) ) { 39 $importer_id = $popular_importers[ $_GET['invalid'] ]['importer-id']; 40 if ( $importer_id != $_GET['invalid'] ) { // Prevent redirect loops. 41 wp_redirect( admin_url( 'admin.php?import=' . $importer_id ) ); 42 exit; 43 } 44 unset( $importer_id ); 48 45 } 49 46 … … 69 66 // If a popular importer is not registered, create a dummy registration that links to the plugin installer. 70 67 foreach ( $popular_importers as $pop_importer => $pop_data ) { 71 if ( isset( $importers[ $pop_importer] ) )68 if ( isset( $importers[ $pop_importer ] ) ) 72 69 continue; 73 if ( isset( $ pop_data[3] ) && isset( $importers[ $pop_data[3] ] ) )70 if ( isset( $importers[ $pop_data['importer-id'] ] ) ) 74 71 continue; 75 76 $importers[$pop_importer] = $popular_importers[$pop_importer]; 72 $importers[ $pop_data['importer-id'] ] = array( $pop_data['name'], $pop_data['description'], 'install' => $pop_data['plugin-slug'] ); 77 73 } 78 74 79 if ( empty( $importers) ) {80 echo '<p>' .__('No importers are available.').'</p>'; // TODO: make more helpful75 if ( empty( $importers ) ) { 76 echo '<p>' . __('No importers are available.') . '</p>'; // TODO: make more helpful 81 77 } else { 82 uasort($importers, create_function('$a, $b', 'return str cmp($a[0], $b[0]);'));78 uasort($importers, create_function('$a, $b', 'return strnatcasecmp($a[0], $b[0]);')); 83 79 ?> 84 80 <table class="widefat importers" cellspacing="0"> 85 81 86 82 <?php 87 $style = ''; 88 foreach ($importers as $id => $data) { 89 $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate'; 83 $alt = ''; 84 foreach ($importers as $importer_id => $data) { 90 85 $action = ''; 91 if ( 'install' == $data[2]) {92 $plugin_slug = $ id . '-importer';86 if ( isset( $data['install'] ) ) { 87 $plugin_slug = $data['install']; 93 88 if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) { 94 89 // Looks like Importer is installed, But not active … … 112 107 } 113 108 } else { 114 $action = "<a href='" . esc_url( "admin.php?import=$id") . "' title='" . esc_attr( wptexturize(strip_tags($data[1])) ) ."'>{$data[0]}</a>";109 $action = "<a href='" . esc_url( "admin.php?import=$importer_id" ) . "' title='" . esc_attr( wptexturize( strip_tags( $data[1] ) ) ) ."'>{$data[0]}</a>"; 115 110 } 116 111 117 if ($style != '') 118 $style = 'class="'.$style.'"'; 112 $alt = $alt ? '' : ' class="alternate"'; 119 113 echo " 120 <tr $style>114 <tr$alt> 121 115 <td class='import-system row-title'>$action</td> 122 116 <td class='desc'>{$data[1]}</td>
Note: See TracChangeset
for help on using the changeset viewer.