2005-08-21 03:03:23 -04:00
< ? php
2008-08-11 16:26:31 -04:00
/**
* Import WordPress Administration Panel
*
* @ package WordPress
* @ subpackage Administration
*/
2010-05-20 15:20:25 -04:00
define ( 'WP_LOAD_IMPORTERS' , true );
2008-08-11 16:26:31 -04:00
/** Load WordPress Bootstrap */
2005-08-21 03:03:23 -04:00
require_once ( 'admin.php' );
2009-08-01 22:23:54 -04:00
if ( ! current_user_can ( 'edit_files' ) )
2010-04-29 21:54:32 -04:00
wp_die ( __ ( 'You do not have sufficient permissions to import content in this site.' ));
2009-08-01 22:23:54 -04:00
2006-11-18 02:31:29 -05:00
$title = __ ( 'Import' );
2010-05-20 15:20:25 -04:00
add_thickbox ();
2005-08-21 03:03:23 -04:00
require_once ( 'admin-header.php' );
2008-11-27 16:11:25 -05:00
$parent_file = 'tools.php' ;
2005-08-21 03:03:23 -04:00
?>
< div class = " wrap " >
2008-11-26 08:51:25 -05:00
< ? php screen_icon (); ?>
2009-05-18 11:11:07 -04:00
< h2 >< ? php echo esc_html ( $title ); ?> </h2>
2010-04-29 21:54:32 -04: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 03:03:23 -04:00
< ? php
// Load all importers so that they can register.
$import_loc = 'wp-admin/import' ;
$import_root = ABSPATH . $import_loc ;
2007-08-13 22:58:33 -04:00
$imports_dir = @ opendir ( $import_root );
2005-08-21 03:03:23 -04:00
if ( $imports_dir ) {
2007-08-16 21:59:37 -04:00
while (( $file = readdir ( $imports_dir )) !== false ) {
2007-04-07 11:46:09 -04:00
if ( $file { 0 } == '.' ) {
2005-08-21 03:03:23 -04:00
continue ;
2007-04-07 11:46:09 -04:00
} elseif ( substr ( $file , - 4 ) == '.php' ) {
require_once ( $import_root . '/' . $file );
}
2005-08-21 03:03:23 -04:00
}
}
2007-08-13 22:58:33 -04:00
@ closedir ( $imports_dir );
2005-08-21 03:03:23 -04:00
2010-05-20 15:20:25 -04: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-22 18:54:52 -04: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 15:20:25 -04:00
'livejournal' => array ( __ ( 'LiveJournal' ), __ ( 'Install the LiveJounral importer to import posts from LiveJournal using their API.' ), 'install' ),
2010-05-25 07:37:25 -04:00
'movabletype' => array ( __ ( 'Movable Type and TypePad' ), __ ( 'Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.' ), 'install' ),
2010-05-20 15:20:25 -04:00
'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 03:03:23 -04:00
$importers = get_importers ();
2010-05-20 15:20:25 -04: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 03:03:23 -04:00
if ( empty ( $importers )) {
2005-12-02 17:37:02 -05:00
echo '<p>' . __ ( 'No importers are available.' ) . '</p>' ; // TODO: make more helpful
2005-08-21 03:03:23 -04:00
} else {
?>
2008-11-17 13:01:00 -05:00
< table class = " widefat " cellspacing = " 0 " >
2005-08-21 03:03:23 -04:00
< ? php
$style = '' ;
foreach ( $importers as $id => $data ) {
$style = ( 'class="alternate"' == $style || 'class="alternate active"' == $style ) ? '' : 'alternate' ;
2010-05-20 15:20:25 -04: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 15:43:52 -04:00
$action = " <a href=' " . esc_url ( " admin.php?import= $id " ) . " ' title=' " . esc_attr ( wptexturize ( strip_tags ( $data [ 1 ])) ) . " '> { $data [ 0 ] } </a> " ;
2010-05-20 15:20:25 -04:00
}
2005-08-21 03:03:23 -04:00
if ( $style != '' )
$style = 'class="' . $style . '"' ;
echo "
< tr $style >
2008-02-23 21:07:51 -05:00
< td class = 'import-system row-title' > $action </ td >
2006-05-10 16:34:17 -04:00
< td class = 'desc' > { $data [ 1 ]} </ td >
2005-08-21 03:03:23 -04:00
</ tr > " ;
}
?>
</ table >
< ? php
}
2010-05-20 15:20:25 -04: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 03:03:23 -04:00
?>
</ div >
< ? php
include ( 'admin-footer.php' );
?>