]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/import.php
Wordpress 3.0.2
[autoinstalls/wordpress.git] / wp-admin / import.php
1 <?php
2 /**
3  * Import WordPress Administration Panel
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 define('WP_LOAD_IMPORTERS', true);
10
11 /** Load WordPress Bootstrap */
12 require_once ('admin.php');
13
14 if ( !current_user_can('import') )
15         wp_die(__('You do not have sufficient permissions to import content in this site.'));
16
17 $title = __('Import');
18
19 add_contextual_help($current_screen,
20         '<p>' . __('This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.') . '</p>' .
21         '<p>' . __('In previous versions of WordPress, all the importers were built-in, but they have been turned into plugins as of version 3.0 since most people only use them once or infrequently.') . '</p>' .
22         '<p><strong>' . __('For more information:') . '</strong></p>' .
23         '<p>' . __('<a href="http://codex.wordpress.org/Tools_Import_SubPanel" target="_blank">Import Documentation</a>') . '</p>' .
24         '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
25 );
26
27 $popular_importers = array();
28 if ( current_user_can('install_plugins') )
29         $popular_importers = array(
30                 'blogger' => array( __('Blogger'), __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), 'install' ),
31                 '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' ),
32                 'livejournal' => array( __( 'LiveJournal' ), __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), 'install' ),
33                 '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' ),
34                 'opml' => array( __('Blogroll'), __('Install the blogroll importer to import links in OPML format.'), 'install' ),
35                 'rss' => array( __('RSS'), __('Install the RSS importer to import posts from an RSS feed.'), 'install' ),
36                 'wordpress' => array( 'WordPress', __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), 'install' )
37         );
38
39 if ( ! empty( $_GET['invalid'] ) && !empty($popular_importers[$_GET['invalid']][3]) ) {
40         wp_redirect("import.php?import=" . $popular_importers[$_GET['invalid']][3]);
41         exit;
42 }
43
44 add_thickbox();
45 require_once ('admin-header.php');
46 $parent_file = 'tools.php';
47 ?>
48
49 <div class="wrap">
50 <?php screen_icon(); ?>
51 <h2><?php echo esc_html( $title ); ?></h2>
52 <?php if ( ! empty( $_GET['invalid'] ) ) : ?>
53         <div class="error"><p><strong><?php _e('ERROR:')?></strong> <?php printf( __('The <strong>%s</strong> importer is invalid or is not installed.'), esc_html( $_GET['invalid'] ) ); ?></p></div>
54 <?php endif; ?>
55 <p><?php _e('If you have posts or comments in another system, WordPress can import those into this site. To get started, choose a system to import from below:'); ?></p>
56
57 <?php
58
59 // Load all importers so that they can register.
60 $import_loc = 'wp-admin/import';
61 $import_root = ABSPATH.$import_loc;
62 $imports_dir = @ opendir($import_root);
63 if ($imports_dir) {
64         while (($file = readdir($imports_dir)) !== false) {
65                 if ($file{0} == '.') {
66                         continue;
67                 } elseif (substr($file, -4) == '.php') {
68                         require_once($import_root . '/' . $file);
69                 }
70         }
71 }
72 @closedir($imports_dir);
73
74 $importers = get_importers();
75
76 // If a popular importer is not registered, create a dummy registration that links to the plugin installer.
77 foreach ( $popular_importers as $pop_importer => $pop_data ) {
78         if ( isset($importers[$pop_importer] ) )
79                 continue;
80         if ( isset( $pop_data[3] ) && isset( $importers[ $pop_data[3] ] ) )
81                 continue;
82
83         $importers[$pop_importer] = $popular_importers[$pop_importer];
84 }
85
86 if (empty ($importers)) {
87         echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful
88 } else {
89         uasort($importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
90 ?>
91 <table class="widefat" cellspacing="0">
92
93 <?php
94         $style = '';
95         foreach ($importers as $id => $data) {
96                 $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
97                 $action = '';
98                 if ( 'install' == $data[2] ) {
99                         $plugin_slug = $id . '-importer';
100                         if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) {
101                                 // Looks like Importer is installed, But not active
102                                 $plugins = get_plugins( '/' . $plugin_slug );
103                                 if ( !empty($plugins) ) {
104                                         $keys = array_keys($plugins);
105                                         $plugin_file = $plugin_slug . '/' . $keys[0];
106                                         $action = '<a href="' . esc_url(wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $plugin_file . '&from=import'), 'activate-plugin_' . $plugin_file)) .
107                                                                                         '"title="' . esc_attr__('Activate importer') . '"">' . $data[0] . '</a>';
108                                 }
109                         }
110                         if ( empty($action) )
111                                 $action = '<a href="' . esc_url(admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug .
112                                                                                 '&from=import&TB_iframe=true&width=600&height=550')) . '" class="thickbox" title="' .
113                                                                                 esc_attr__('Install importer') . '">' . $data[0] . '</a>';
114                 } else {
115                         $action = "<a href='" . esc_url("admin.php?import=$id") . "' title='" . esc_attr( wptexturize(strip_tags($data[1])) ) ."'>{$data[0]}</a>";
116                 }
117
118                 if ($style != '')
119                         $style = 'class="'.$style.'"';
120                 echo "
121                         <tr $style>
122                                 <td class='import-system row-title'>$action</td>
123                                 <td class='desc'>{$data[1]}</td>
124                         </tr>";
125         }
126 ?>
127
128 </table>
129 <?php
130 }
131
132 if ( current_user_can('install_plugins') )
133         echo '<p>' . sprintf( __('If the importer you need is not listed, <a href="%s">search the plugins directory</a> to see if an importer is available.'), esc_url(admin_url('plugin-install.php?tab=search&type=tag&s=importer')) ) . '</p>';
134 ?>
135
136 </div>
137
138 <?php
139
140 include ('admin-footer.php');
141 ?>