]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/import.php
Wordpress 3.3-scripts
[autoinstalls/wordpress.git] / wp-admin / import.php
1 <?php
2 /**
3  * Import WordPress Administration Screen
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 get_current_screen()->add_help_tab( array(
20         'id'      => 'overview',
21         'title'   => __('Overview'),
22         'content' => '<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>' .
23                 '<p>' . __('In previous versions of WordPress, all importers were built-in.  They have been turned into plugins since most people only use them once or infrequently.') . '</p>',
24 ) );
25
26
27 get_current_screen()->set_help_sidebar(
28         '<p><strong>' . __('For more information:') . '</strong></p>' .
29         '<p>' . __('<a href="http://codex.wordpress.org/Tools_Import_Screen" target="_blank">Documentation on Import</a>') . '</p>' .
30         '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
31 );
32
33 $popular_importers = array();
34 if ( current_user_can('install_plugins') )
35         $popular_importers = array(
36                 'blogger' => array( __('Blogger'), __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), 'install' ),
37                 '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' ),
38                 'livejournal' => array( __( 'LiveJournal' ), __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), 'install' ),
39                 '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' ),
40                 'opml' => array( __('Blogroll'), __('Install the blogroll importer to import links in OPML format.'), 'install' ),
41                 'rss' => array( __('RSS'), __('Install the RSS importer to import posts from an RSS feed.'), 'install' ),
42                 'tumblr' => array( __('Tumblr'), __('Install the Tumblr importer to import posts &amp; media from Tumblr using their API.'), 'install' ),
43                 'wordpress' => array( 'WordPress', __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), 'install' )
44         );
45
46 if ( ! empty( $_GET['invalid'] ) && !empty($popular_importers[$_GET['invalid']][3]) ) {
47         wp_redirect( admin_url('import.php?import=' . $popular_importers[$_GET['invalid']][3]) );
48         exit;
49 }
50
51 add_thickbox();
52 wp_enqueue_script( 'plugin-install' );
53
54 require_once ('admin-header.php');
55 $parent_file = 'tools.php';
56 ?>
57
58 <div class="wrap">
59 <?php screen_icon(); ?>
60 <h2><?php echo esc_html( $title ); ?></h2>
61 <?php if ( ! empty( $_GET['invalid'] ) ) : ?>
62         <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>
63 <?php endif; ?>
64 <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>
65
66 <?php
67
68 $importers = get_importers();
69
70 // If a popular importer is not registered, create a dummy registration that links to the plugin installer.
71 foreach ( $popular_importers as $pop_importer => $pop_data ) {
72         if ( isset( $importers[$pop_importer] ) )
73                 continue;
74         if ( isset( $pop_data[3] ) && isset( $importers[ $pop_data[3] ] ) )
75                 continue;
76
77         $importers[$pop_importer] = $popular_importers[$pop_importer];
78 }
79
80 if ( empty($importers) ) {
81         echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful
82 } else {
83         uasort($importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
84 ?>
85 <table class="widefat importers" cellspacing="0">
86
87 <?php
88         $style = '';
89         foreach ($importers as $id => $data) {
90                 $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
91                 $action = '';
92                 if ( 'install' == $data[2] ) {
93                         $plugin_slug = $id . '-importer';
94                         if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) {
95                                 // Looks like Importer is installed, But not active
96                                 $plugins = get_plugins( '/' . $plugin_slug );
97                                 if ( !empty($plugins) ) {
98                                         $keys = array_keys($plugins);
99                                         $plugin_file = $plugin_slug . '/' . $keys[0];
100                                         $action = '<a href="' . esc_url(wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $plugin_file . '&from=import'), 'activate-plugin_' . $plugin_file)) .
101                                                                                         '"title="' . esc_attr__('Activate importer') . '"">' . $data[0] . '</a>';
102                                 }
103                         }
104                         if ( empty($action) ) {
105                                 if ( is_main_site() ) {
106                                         $action = '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug .
107                                                                                 '&from=import&TB_iframe=true&width=600&height=550' ) ) . '" class="thickbox" title="' .
108                                                                                 esc_attr__('Install importer') . '">' . $data[0] . '</a>';
109                                 } else {
110                                         $action = $data[0];
111                                         $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' ) );
112                                 }
113                         }
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 plugin directory</a> to see if an importer is available.'), esc_url( network_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 ?>