2005-08-21 09:03:23 +02:00
< ? php
2008-08-11 22:26:31 +02:00
/**
* Import WordPress Administration Panel
*
* @ package WordPress
* @ subpackage Administration
*/
2010-05-20 21:20:25 +02:00
define ( 'WP_LOAD_IMPORTERS' , true );
2008-08-11 22:26:31 +02:00
/** Load WordPress Bootstrap */
2005-08-21 09:03:23 +02:00
require_once ( 'admin.php' );
2009-08-02 04:23:54 +02:00
if ( ! current_user_can ( 'edit_files' ) )
2010-04-30 03:54:32 +02:00
wp_die ( __ ( 'You do not have sufficient permissions to import content in this site.' ));
2009-08-02 04:23:54 +02:00
2006-11-18 08:31:29 +01:00
$title = __ ( 'Import' );
2010-05-20 21:20:25 +02:00
add_thickbox ();
2005-08-21 09:03:23 +02:00
require_once ( 'admin-header.php' );
2008-11-27 22:11:25 +01:00
$parent_file = 'tools.php' ;
2005-08-21 09:03:23 +02:00
?>
< div class = " wrap " >
2008-11-26 14:51:25 +01:00
< ? php screen_icon (); ?>
2009-05-18 17:11:07 +02:00
< h2 >< ? php echo esc_html ( $title ); ?> </h2>
2010-04-30 03:54:32 +02:00
< 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>
2005-08-21 09:03:23 +02:00
< ? php
// Load all importers so that they can register.
$import_loc = 'wp-admin/import' ;
$import_root = ABSPATH . $import_loc ;
2007-08-14 04:58:33 +02:00
$imports_dir = @ opendir ( $import_root );
2005-08-21 09:03:23 +02:00
if ( $imports_dir ) {
2007-08-17 03:59:37 +02:00
while (( $file = readdir ( $imports_dir )) !== false ) {
2007-04-07 17:46:09 +02:00
if ( $file { 0 } == '.' ) {
2005-08-21 09:03:23 +02:00
continue ;
2007-04-07 17:46:09 +02:00
} elseif ( substr ( $file , - 4 ) == '.php' ) {
require_once ( $import_root . '/' . $file );
}
2005-08-21 09:03:23 +02:00
}
}
2007-08-14 04:58:33 +02:00
@ closedir ( $imports_dir );
2005-08-21 09:03:23 +02:00
2010-05-20 21:20:25 +02:00
$popular_importers = array ();
if ( current_user_can ( 'install_plugins' ) )
$popular_importers = array (
'blogger' => array ( __ ( 'Blogger' ), __ ( 'Install the Blogger importer to import posts, comments, and users from a Blogger blog.' ), 'install' ),
2010-05-23 00:54:52 +02:00
'wpcat2tag' => array ( __ ( 'Categories and Tags Converter' ), __ ( 'Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.' ), 'install' ),
2010-05-20 21:20:25 +02:00
'livejournal' => array ( __ ( 'LiveJournal' ), __ ( 'Install the LiveJounral importer to import posts from LiveJournal using their API.' ), 'install' ),
'mt' => array ( __ ( 'Movable Type and TypePad' ), __ ( 'Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.' ), 'install' ),
'opml' => array ( __ ( 'Blogroll' ), __ ( 'Install the blogroll importer to import links in OPML format.' ), 'install' ),
'rss' => array ( __ ( 'RSS' ), __ ( 'Install the RSS importer to import posts from an RSS feed.' ), 'install' ),
'wordpress' => array ( 'WordPress' , __ ( 'Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ), 'install' )
);
2005-08-21 09:03:23 +02:00
$importers = get_importers ();
2010-05-20 21:20:25 +02:00
// If a popular importer is not registered, create a dummy registration that links to the plugin installer.
foreach ( array_keys ( $popular_importers ) as $pop_importer ) {
if ( isset ( $importers [ $pop_importer ] ) )
continue ;
$importers [ $pop_importer ] = $popular_importers [ $pop_importer ];
}
uasort ( $importers , create_function ( '$a, $b' , 'return strcmp($a[0], $b[0]);' ));
2005-08-21 09:03:23 +02:00
if ( empty ( $importers )) {
2005-12-02 23:37:02 +01:00
echo '<p>' . __ ( 'No importers are available.' ) . '</p>' ; // TODO: make more helpful
2005-08-21 09:03:23 +02:00
} else {
?>
2008-11-17 19:01:00 +01:00
< table class = " widefat " cellspacing = " 0 " >
2005-08-21 09:03:23 +02:00
< ? php
$style = '' ;
foreach ( $importers as $id => $data ) {
$style = ( 'class="alternate"' == $style || 'class="alternate active"' == $style ) ? '' : 'alternate' ;
2010-05-20 21:20:25 +02:00
if ( 'install' == $data [ 2 ] ) {
$plugin_slug = $id . '-importer' ;
$action = '<a href="' . admin_url ( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug .
'&TB_iframe=true&width=600&height=550' ) . '" class="thickbox" title="' .
esc_attr__ ( 'Install importer' ) . '">' . $data [ 0 ] . '</a>' ;
} else {
2010-05-20 21:43:52 +02:00
$action = " <a href=' " . esc_url ( " admin.php?import= $id " ) . " ' title=' " . esc_attr ( wptexturize ( strip_tags ( $data [ 1 ])) ) . " '> { $data [ 0 ] } </a> " ;
2010-05-20 21:20:25 +02:00
}
2005-08-21 09:03:23 +02:00
if ( $style != '' )
$style = 'class="' . $style . '"' ;
echo "
< tr $style >
2008-02-24 03:07:51 +01:00
< td class = 'import-system row-title' > $action </ td >
2006-05-10 22:34:17 +02:00
< td class = 'desc' > { $data [ 1 ]} </ td >
2005-08-21 09:03:23 +02:00
</ tr > " ;
}
?>
</ table >
< ? php
}
2010-05-20 21:20:25 +02:00
if ( current_user_can ( 'install_plugins' ) )
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.' , admin_url ( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) . '</p>' ;
2005-08-21 09:03:23 +02:00
?>
</ div >
< ? php
include ( 'admin-footer.php' );
?>