27 '<p><strong>' . __('For more information:') . '</strong></p>' . |
27 '<p><strong>' . __('For more information:') . '</strong></p>' . |
28 '<p>' . __('<a href="http://codex.wordpress.org/Tools_Import_Screen" target="_blank">Documentation on Import</a>') . '</p>' . |
28 '<p>' . __('<a href="http://codex.wordpress.org/Tools_Import_Screen" target="_blank">Documentation on Import</a>') . '</p>' . |
29 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
29 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
30 ); |
30 ); |
31 |
31 |
32 $popular_importers = array(); |
32 if ( current_user_can( 'install_plugins' ) ) |
33 if ( current_user_can('install_plugins') ) |
33 $popular_importers = wp_get_popular_importers(); |
34 $popular_importers = array( |
34 else |
35 'blogger' => array( __('Blogger'), __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), 'install' ), |
35 $popular_importers = array(); |
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 ); |
|
44 |
36 |
45 if ( ! empty( $_GET['invalid'] ) && !empty($popular_importers[$_GET['invalid']][3]) ) { |
37 // Detect and redirect invalid importers like 'movabletype', which is registered as 'mt' |
46 wp_redirect( admin_url('import.php?import=' . $popular_importers[$_GET['invalid']][3]) ); |
38 if ( ! empty( $_GET['invalid'] ) && isset( $popular_importers[ $_GET['invalid'] ] ) ) { |
47 exit; |
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 |
50 add_thickbox(); |
47 add_thickbox(); |
51 wp_enqueue_script( 'plugin-install' ); |
48 wp_enqueue_script( 'plugin-install' ); |
52 |
49 |
66 |
63 |
67 $importers = get_importers(); |
64 $importers = get_importers(); |
68 |
65 |
69 // If a popular importer is not registered, create a dummy registration that links to the plugin installer. |
66 // If a popular importer is not registered, create a dummy registration that links to the plugin installer. |
70 foreach ( $popular_importers as $pop_importer => $pop_data ) { |
67 foreach ( $popular_importers as $pop_importer => $pop_data ) { |
71 if ( isset( $importers[$pop_importer] ) ) |
68 if ( isset( $importers[ $pop_importer ] ) ) |
72 continue; |
69 continue; |
73 if ( isset( $pop_data[3] ) && isset( $importers[ $pop_data[3] ] ) ) |
70 if ( isset( $importers[ $pop_data['importer-id'] ] ) ) |
74 continue; |
71 continue; |
75 |
72 $importers[ $pop_data['importer-id'] ] = array( $pop_data['name'], $pop_data['description'], 'install' => $pop_data['plugin-slug'] ); |
76 $importers[$pop_importer] = $popular_importers[$pop_importer]; |
|
77 } |
73 } |
78 |
74 |
79 if ( empty($importers) ) { |
75 if ( empty( $importers ) ) { |
80 echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful |
76 echo '<p>' . __('No importers are available.') . '</p>'; // TODO: make more helpful |
81 } else { |
77 } else { |
82 uasort($importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);')); |
78 uasort($importers, create_function('$a, $b', 'return strnatcasecmp($a[0], $b[0]);')); |
83 ?> |
79 ?> |
84 <table class="widefat importers" cellspacing="0"> |
80 <table class="widefat importers" cellspacing="0"> |
85 |
81 |
86 <?php |
82 <?php |
87 $style = ''; |
83 $alt = ''; |
88 foreach ($importers as $id => $data) { |
84 foreach ($importers as $importer_id => $data) { |
89 $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate'; |
|
90 $action = ''; |
85 $action = ''; |
91 if ( 'install' == $data[2] ) { |
86 if ( isset( $data['install'] ) ) { |
92 $plugin_slug = $id . '-importer'; |
87 $plugin_slug = $data['install']; |
93 if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) { |
88 if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) { |
94 // Looks like Importer is installed, But not active |
89 // Looks like Importer is installed, But not active |
95 $plugins = get_plugins( '/' . $plugin_slug ); |
90 $plugins = get_plugins( '/' . $plugin_slug ); |
96 if ( !empty($plugins) ) { |
91 if ( !empty($plugins) ) { |
97 $keys = array_keys($plugins); |
92 $keys = array_keys($plugins); |
109 $action = $data[0]; |
104 $action = $data[0]; |
110 $data[1] = sprintf( __( 'This importer is not installed. Please install importers from <a href="%s">the main site</a>.' ), get_admin_url( $current_site->blog_id, 'import.php' ) ); |
105 $data[1] = sprintf( __( 'This importer is not installed. Please install importers from <a href="%s">the main site</a>.' ), get_admin_url( $current_site->blog_id, 'import.php' ) ); |
111 } |
106 } |
112 } |
107 } |
113 } else { |
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 != '') |
112 $alt = $alt ? '' : ' class="alternate"'; |
118 $style = 'class="'.$style.'"'; |
|
119 echo " |
113 echo " |
120 <tr $style> |
114 <tr$alt> |
121 <td class='import-system row-title'>$action</td> |
115 <td class='import-system row-title'>$action</td> |
122 <td class='desc'>{$data[1]}</td> |
116 <td class='desc'>{$data[1]}</td> |
123 </tr>"; |
117 </tr>"; |
124 } |
118 } |
125 ?> |
119 ?> |