summaryrefslogtreecommitdiffstats
path: root/wp-admin/import
diff options
context:
space:
mode:
Diffstat (limited to 'wp-admin/import')
-rw-r--r--wp-admin/import/blogger.php21
-rw-r--r--wp-admin/import/blogware.php10
-rw-r--r--wp-admin/import/btt.php14
-rw-r--r--wp-admin/import/dotclear.php11
-rw-r--r--wp-admin/import/greymatter.php18
-rw-r--r--wp-admin/import/jkw.php22
-rw-r--r--wp-admin/import/livejournal.php9
-rw-r--r--wp-admin/import/mt.php42
-rw-r--r--wp-admin/import/rss.php5
-rw-r--r--wp-admin/import/stp.php22
-rw-r--r--wp-admin/import/textpattern.php23
-rw-r--r--wp-admin/import/utw.php18
-rw-r--r--wp-admin/import/wordpress.php504
-rw-r--r--wp-admin/import/wp-cat2tag.php97
14 files changed, 569 insertions, 247 deletions
diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php
index 23e0807..fb15c66 100644
--- a/wp-admin/import/blogger.php
+++ b/wp-admin/import/blogger.php
@@ -12,7 +12,7 @@ class Blogger_Import {
$auth_url = "https://www.google.com/accounts/AuthSubRequest";
$title = __('Import Blogger');
$welcome = __('Howdy! This importer allows you to import posts and comments from your Blogger account into your WordPress blog.');
- $prereqs = __('To use this importer, you must have a Google account, an upgraded (New, was Beta) blog, and it must be on blogspot or a custom domain (not FTP).');
+ $prereqs = __('To use this importer, you must have a Google account and an upgraded (New, was Beta) blog hosted on blogspot.com or a custom domain (not FTP).');
$stepone = __('The first thing you need to do is tell Blogger to let WordPress access your account. You will be sent back here after providing authorization.');
$auth = __('Authorize');
@@ -20,7 +20,7 @@ class Blogger_Import {
<div class='wrap'><h2>$title</h2><p>$welcome</p><p>$prereqs</p><p>$stepone</p>
<form action='$auth_url' method='get'>
<p class='submit' style='text-align:left;'>
- <input type='submit' value='$auth' />
+ <input type='submit' class='button' value='$auth' />
<input type='hidden' name='scope' value='http://www.blogger.com/feeds/' />
<input type='hidden' name='session' value='1' />
<input type='hidden' name='secure' value='0' />
@@ -178,7 +178,7 @@ class Blogger_Import {
$init .= "blogs[$i]=new blog($i,'$blogtitle','{$blog['mode']}'," . $this->get_js_status($i) . ');';
$pstat = "<div class='ind' id='pind$i'>&nbsp;</div><div id='pstat$i' class='stat'>$pdone/{$blog['total_posts']}</div>";
$cstat = "<div class='ind' id='cind$i'>&nbsp;</div><div id='cstat$i' class='stat'>$cdone/{$blog['total_comments']}</div>";
- $rows .= "<tr id='blog$i'><td class='blogtitle'>$blogtitle</td><td class='bloghost'>{$blog['host']}</td><td class='bar'>$pstat</td><td class='bar'>$cstat</td><td class='submit'><input type='submit' id='submit$i' value='$value' /><input type='hidden' name='blog' value='$i' /></td></tr>\n";
+ $rows .= "<tr id='blog$i'><td class='blogtitle'>$blogtitle</td><td class='bloghost'>{$blog['host']}</td><td class='bar'>$pstat</td><td class='bar'>$cstat</td><td class='submit'><input type='submit' class='button' id='submit$i' value='$value' /><input type='hidden' name='blog' value='$i' /></td></tr>\n";
}
echo "<div class='wrap'><h2>$title</h2><noscript>$noscript</noscript><table cellpadding='5px'><thead><td>$name</td><td>$url</td><td>$posts</td><td>$comments</td><td>$action</td></thead>\n$rows</table></form></div>";
@@ -381,7 +381,7 @@ class Blogger_Import {
$AtomParser = new AtomParser();
$AtomParser->parse( $entry );
$result = $this->import_post($AtomParser->entry);
- if ( is_wp_error( $result ) )
+ if ( is_wp_error( $result ) )
return $result;
unset($AtomParser);
}
@@ -520,7 +520,7 @@ class Blogger_Import {
$post = compact('post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($post);
- if ( is_wp_error( $post_id ) )
+ if ( is_wp_error( $post_id ) )
return $post_id;
wp_create_categories( array_map( 'addslashes', $entry->categories ), $post_id );
@@ -613,12 +613,12 @@ class Blogger_Import {
$blogtitle = "{$blog['title']} ({$blog['host']})";
$mapthis = __('Blogger username');
$tothis = __('WordPress login');
- $submit = js_escape( __('Save Changes &raquo;') );
+ $submit = js_escape( __('Save Changes') );
foreach ( $blog['authors'] as $i => $author )
$rows .= "<tr><td><label for='authors[$i]'>{$author[0]}</label></td><td><select name='authors[$i]' id='authors[$i]'>" . $this->get_user_options($author[1]) . "</select></td></tr>";
- return "<div class='wrap'><h2>$heading</h2><h3>$blogtitle</h3><p>$directions</p><form action='index.php?import=blogger&noheader=true&saveauthors=1' method='post'><input type='hidden' name='blog' value='$importing_blog' /><table cellpadding='5'><thead><td>$mapthis</td><td>$tothis</td></thead>$rows<tr><td></td><td class='submit'><input type='submit' class='authorsubmit' value='$submit' /></td></tr></table></form></div>";
+ return "<div class='wrap'><h2>$heading</h2><h3>$blogtitle</h3><p>$directions</p><form action='index.php?import=blogger&noheader=true&saveauthors=1' method='post'><input type='hidden' name='blog' value='$importing_blog' /><table cellpadding='5'><thead><td>$mapthis</td><td>$tothis</td></thead>$rows<tr><td></td><td class='submit'><input type='submit' class='button authorsubmit' value='$submit' /></td></tr></table></form></div>";
}
function get_user_options($current) {
@@ -788,7 +788,7 @@ class Blogger_Import {
$restart = __('Restart');
$message = __('We have saved some information about your Blogger account in your WordPress database. Clearing this information will allow you to start over. Restarting will not affect any posts you have already imported. If you attempt to re-import a blog, duplicate posts and comments will be skipped.');
$submit = __('Clear account information');
- echo "<div class='wrap'><h2>$restart</h2><p>$message</p><form method='post' action='?import=blogger&noheader=true'><p class='submit' style='text-align:left;'><input type='submit' value='$submit' name='restart' /></p></form></div>";
+ echo "<div class='wrap'><h2>$restart</h2><p>$message</p><form method='post' action='?import=blogger&noheader=true'><p class='submit' style='text-align:left;'><input type='submit' class='button' value='$submit' name='restart' /></p></form></div>";
}
}
@@ -821,9 +821,6 @@ thead td { font-weight: bold; }
position: relative;
text-align: center;
}
-.submit {
- text-align: center !important;
-}
</style>
<?php
}
@@ -840,7 +837,7 @@ thead td { font-weight: bold; }
$blogger_import = new Blogger_Import();
-register_importer('blogger', __('Blogger'), __('Import posts, comments, and users from a Blogger blog'), array ($blogger_import, 'start'));
+register_importer('blogger', __('Blogger'), __('Import posts, comments, and users from a Blogger blog.'), array ($blogger_import, 'start'));
class AtomEntry {
var $links = array();
diff --git a/wp-admin/import/blogware.php b/wp-admin/import/blogware.php
index 0083230..0054db2 100644
--- a/wp-admin/import/blogware.php
+++ b/wp-admin/import/blogware.php
@@ -86,9 +86,9 @@ class BW_Import {
echo '<li>';
if ($post_id = post_exists($post_title, $post_content, $post_date)) {
- printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
+ printf(__('Post <em>%s</em> already exists.'), stripslashes($post_title));
} else {
- printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
+ printf(__('Importing post <em>%s</em>...'), stripslashes($post_title));
$postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($postdata);
if ( is_wp_error( $post_id ) ) {
@@ -141,7 +141,7 @@ class BW_Import {
}
if ( $num_comments ) {
echo ' ';
- printf(__('(%s comments)'), $num_comments);
+ printf( __ngettext('%s comment', '%s comments', $num_comments), $num_comments );
}
echo '</li>';
flush();
@@ -162,7 +162,7 @@ class BW_Import {
if ( is_wp_error( $result ) )
return $result;
wp_import_cleanup($file['id']);
-
+ do_action('import_done', 'blogware');
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
echo '</h3>';
@@ -197,5 +197,5 @@ class BW_Import {
$blogware_import = new BW_Import();
-register_importer('blogware', __('Blogware'), __('Import posts from Blogware'), array ($blogware_import, 'dispatch'));
+register_importer('blogware', __('Blogware'), __('Import posts from Blogware.'), array ($blogware_import, 'dispatch'));
?>
diff --git a/wp-admin/import/btt.php b/wp-admin/import/btt.php
index 76a02c3..4bd884c 100644
--- a/wp-admin/import/btt.php
+++ b/wp-admin/import/btt.php
@@ -14,13 +14,13 @@ class BunnyTags_Import {
function greet() {
echo '<div class="narrow">';
- echo '<p>'.__('Howdy! This imports tags from an existing Bunny&#8217;s Technorati Tags installation into this blog using the new WordPress native tagging structure.').'</p>';
+ echo '<p>'.__('Howdy! This imports tags from Bunny&#8217;s Technorati Tags into WordPress tags.').'</p>';
echo '<p>'.__('This is suitable for Bunny&#8217;s Technorati Tags version 0.6.').'</p>';
echo '<p><strong>'.__('All existing Bunny&#8217;s Technorati Tags will be removed after import.').'</strong></p>';
echo '<p><strong>'.__('Don&#8217;t be stupid - backup your database before proceeding!').'</strong></p>';
echo '<form action="admin.php?import=btt&amp;step=1" method="post">';
wp_nonce_field('import-btt');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Tags &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Tags').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -29,7 +29,7 @@ class BunnyTags_Import {
if ( empty($_GET['step']) )
$step = 0;
else
- $step = abs(intval($_GET['step']));
+ $step = absint($_GET['step']);
// load the header
$this->header();
@@ -61,14 +61,14 @@ class BunnyTags_Import {
echo '<div class="narrow">';
echo '<p><h3>'.__('Reading Bunny&#8217;s Technorati Tags&#8230;').'</h3></p>';
- // import Bunny's Keywords tags
+ // import Bunny's Keywords tags
$metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'tags'");
if ( !is_array($metakeys)) {
echo '<p>' . __('No Tags Found!') . '</p>';
return false;
} else {
$count = count($metakeys);
- echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>';
+ echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> post with tags were read.', 'Done! <strong>%s</strong> posts with tags were read.', $count), $count ) . '<br /></p>';
echo '<ul>';
foreach ( $metakeys as $post_meta ) {
if ( $post_meta->meta_value != '' ) {
@@ -90,7 +90,7 @@ class BunnyTags_Import {
echo '<form action="admin.php?import=btt&amp;step='.($precheck? 2:3).'" method="post">';
wp_nonce_field('import-btt');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -110,6 +110,6 @@ class BunnyTags_Import {
$btt_import = new BunnyTags_Import();
// add it to the import page!
-register_importer('btt', 'Bunny&#8217;s Technorati Tags', __('Import Bunny&#8217;s Technorati Tags into the new native tagging structure.'), array($btt_import, 'dispatch'));
+register_importer('btt', 'Bunny&#8217;s Technorati Tags', __('Import Bunny&#8217;s Technorati Tags into WordPress tags.'), array($btt_import, 'dispatch'));
?>
diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php
index 1bf0486..16df934 100644
--- a/wp-admin/import/dotclear.php
+++ b/wp-admin/import/dotclear.php
@@ -128,7 +128,7 @@ class Dotclear_Import {
echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
wp_nonce_field('import-dotclear');
$this->db_form();
- echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories &raquo;')).'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories')).'" /></p>';
echo '</form></div>';
}
@@ -225,7 +225,7 @@ class Dotclear_Import {
// Store category translation for future use
add_option('dccat2wpcat',$dccat2wpcat);
- echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
+ echo '<p>'.sprintf(__ngettext('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>';
return true;
}
echo __('No Categories to Import!');
@@ -526,7 +526,7 @@ class Dotclear_Import {
}
add_option('dclinks2wplinks',$dclinks2wplinks);
echo '<p>';
- printf(__('Done! <strong>%s</strong> links or link categories imported'), $count);
+ printf(__ngettext('Done! <strong>%s</strong> link or link category imported.', 'Done! <strong>%s</strong> links or link categories imported.', $count), $count);
echo '<br /><br /></p>';
return true;
}
@@ -615,6 +615,7 @@ class Dotclear_Import {
delete_option('dcname');
delete_option('dchost');
delete_option('dccharset');
+ do_action('import_done', 'dotclear');
$this->tips();
}
@@ -639,7 +640,7 @@ class Dotclear_Import {
function db_form()
{
- echo '<table class="editform">';
+ echo '<table class="form-table">';
printf('<tr><th><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('DotClear Database User:'));
printf('<tr><th><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('DotClear Database Password:'));
printf('<tr><th><label for="dbname">%s</label></th><td><input type="text" name="dbname" id="dbname" /></td></tr>', __('DotClear Database Name:'));
@@ -741,5 +742,5 @@ class Dotclear_Import {
}
$dc_import = new Dotclear_Import();
-register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog'), array ($dc_import, 'dispatch'));
+register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog.'), array ($dc_import, 'dispatch'));
?>
diff --git a/wp-admin/import/greymatter.php b/wp-admin/import/greymatter.php
index 6e92235..92abc48 100644
--- a/wp-admin/import/greymatter.php
+++ b/wp-admin/import/greymatter.php
@@ -36,7 +36,7 @@ class GM_Import {
<input type="hidden" name="step" value="1" />
<?php wp_nonce_field('import-greymatter'); ?>
<h3><?php _e('Second step: GreyMatter details:') ?></h3>
-<p><table cellpadding="0">
+<table class="form-table">
<tr>
<td><?php _e('Path to GM files:') ?></td>
<td><input type="text" style="width:300px" name="gmpath" value="/home/my/site/cgi-bin/greymatter/" /></td>
@@ -46,17 +46,14 @@ class GM_Import {
<td><input type="text" style="width:300px" name="archivespath" value="/home/my/site/cgi-bin/greymatter/archives/" /></td>
</tr>
<tr>
-<td colspan="2"><br /><?php _e("This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don't know that number, just log into your FTP and look it out<br />in the entries' folder)") ?></td>
-</tr>
-<tr>
<td><?php _e("Last entry's number:") ?></td>
-<td><input type="text" name="lastentry" value="00000001" /></td>
+<td><input type="text" name="lastentry" value="00000001" /><br />
+ <?php _e("This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don't know that number, just log into your FTP and look it out<br />in the entries' folder)") ?></td>
</tr>
</table>
</p>
-<p><?php _e("When you're ready, click OK to start importing: ") ?><input type="submit" name="submit" value="<?php _e('OK') ?>" class="search" /></p>
+<p><input type="submit" name="submit" value="<?php _e('Start Importing') ?>" class="button" /></p>
</form>
-<p>&nbsp</p>
<?php
$this->footer();
}
@@ -272,17 +269,18 @@ class GM_Import {
}
if ($numAddedComments > 0) {
echo ': ';
- printf(__('imported %d comment(s)'), $numAddedComments);
+ printf( __ngettext('imported %s comment', 'imported %s comments', $numAddedComments) , $numAddedComments);
}
$preExisting = $numComments - numAddedComments;
if ($preExisting > 0) {
echo ' ';
- printf(__('ignored %d pre-existing comments'), $preExisting);
+ printf( __ngettext( 'ignored %s pre-existing comment', 'ignored %s pre-existing comments', $preExisting ) , $preExisting);
}
}
echo '... <strong>'.__('Done').'</strong></li>';
}
}
+ do_action('import_done', 'greymatter');
?>
</ul><strong><?php _e('Done') ?></strong></li></ul>
<p>&nbsp;</p>
@@ -318,5 +316,5 @@ class GM_Import {
$gm_import = new GM_Import();
-register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog'), array ($gm_import, 'dispatch'));
+register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog.'), array ($gm_import, 'dispatch'));
?>
diff --git a/wp-admin/import/jkw.php b/wp-admin/import/jkw.php
index 9f7b48e..1bb0ad6 100644
--- a/wp-admin/import/jkw.php
+++ b/wp-admin/import/jkw.php
@@ -14,17 +14,17 @@ class JeromesKeyword_Import {
function greet() {
echo '<div class="narrow">';
- echo '<p>'.__('Howdy! This imports tags from an existing Jerome&#8217;s Keywords installation into this blog using the new WordPress native tagging structure.').'</p>';
+ echo '<p>'.__('Howdy! This imports tags from Jerome&#8217;s Keywords into WordPress tags.').'</p>';
echo '<p>'.__('This is suitable for Jerome&#8217;s Keywords version 1.x and 2.0a.').'</p>';
echo '<p><strong>'.__('All existing Jerome&#8217;s Keywords will be removed after import.').'</strong></p>';
echo '<p><strong>'.__('Don&#8217;t be stupid - backup your database before proceeding!').'</strong></p>';
echo '<form action="admin.php?import=jkw&amp;step=1" method="post">';
wp_nonce_field('import-jkw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Version 1.x &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Import Version 1.x').'" /></p>';
echo '</form>';
echo '<form action="admin.php?import=jkw&amp;step=3" method="post">';
wp_nonce_field('import-jkw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Version 2.0a &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Import Version 2.0a').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -33,7 +33,7 @@ class JeromesKeyword_Import {
if ( empty($_GET['step']) )
$step = 0;
else
- $step = abs(intval($_GET['step']));
+ $step = absint($_GET['step']);
// load the header
$this->header();
@@ -77,14 +77,14 @@ class JeromesKeyword_Import {
echo '<div class="narrow">';
echo '<p><h3>'.__('Reading Jerome&#8217;s Keywords Tags&#8230;').'</h3></p>';
- // import Jerome's Keywords tags
+ // import Jerome's Keywords tags
$metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'keywords'");
if ( !is_array($metakeys)) {
echo '<p>' . __('No Tags Found!') . '</p>';
return false;
} else {
$count = count($metakeys);
- echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>';
+ echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> post with tags were read.', 'Done! <strong>%s</strong> posts with tags were read.', $count), $count ) . '<br /></p>';
echo '<ul>';
foreach ( $metakeys as $post_meta ) {
if ( $post_meta->meta_value != '' ) {
@@ -106,7 +106,7 @@ class JeromesKeyword_Import {
echo '<form action="admin.php?import=jkw&amp;step='.($precheck? 2:6).'" method="post">';
wp_nonce_field('import-jkw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -117,7 +117,7 @@ class JeromesKeyword_Import {
echo '<div class="narrow">';
echo '<p><h3>'.__('Reading Jerome&#8217;s Keywords Tags&#8230;').'</h3></p>';
- // import Jerome's Keywords tags
+ // import Jerome's Keywords tags
$tablename = $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1);
$metakeys = $wpdb->get_results("SELECT post_id, tag_name FROM $tablename");
if ( !is_array($metakeys) ) {
@@ -125,7 +125,7 @@ class JeromesKeyword_Import {
return false;
} else {
$count = count($metakeys);
- echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>';
+ echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag were read.', 'Done! <strong>%s</strong> tags were read.', $count), $count ) . '<br /></p>';
echo '<ul>';
foreach ( $metakeys as $post_meta ) {
$keyword = addslashes(trim($post_meta->tag_name));
@@ -139,7 +139,7 @@ class JeromesKeyword_Import {
}
echo '<form action="admin.php?import=jkw&amp;step='.($precheck? 4:5).'" method="post">';
wp_nonce_field('import-jkw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -173,6 +173,6 @@ class JeromesKeyword_Import {
$jkw_import = new JeromesKeyword_Import();
// add it to the import page!
-register_importer('jkw', 'Jerome&#8217;s Keywords', __('Import Jerome&#8217;s Keywords into the new native tagging structure.'), array($jkw_import, 'dispatch'));
+register_importer('jkw', 'Jerome&#8217;s Keywords', __('Import Jerome&#8217;s Keywords into WordPress tags.'), array($jkw_import, 'dispatch'));
?>
diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php
index 81f0365..bd8394e 100644
--- a/wp-admin/import/livejournal.php
+++ b/wp-admin/import/livejournal.php
@@ -66,9 +66,9 @@ class LJ_Import {
echo '<li>';
if ($post_id = post_exists($post_title, $post_content, $post_date)) {
- printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
+ printf(__('Post <em>%s</em> already exists.'), stripslashes($post_title));
} else {
- printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
+ printf(__('Importing post <em>%s</em>...'), stripslashes($post_title));
$postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($postdata);
if ( is_wp_error( $post_id ) )
@@ -119,7 +119,7 @@ class LJ_Import {
}
if ( $num_comments ) {
echo ' ';
- printf(__('(%s comments)'), $num_comments);
+ printf(__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments);
}
echo '</li>';
}
@@ -138,6 +138,7 @@ class LJ_Import {
if ( is_wp_error( $result ) )
return $result;
wp_import_cleanup($file['id']);
+ do_action('import_done', 'livejournal');
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
@@ -174,5 +175,5 @@ class LJ_Import {
$livejournal_import = new LJ_Import();
-register_importer('livejournal', __('LiveJournal'), __('Import posts from a LiveJournal XML export file'), array ($livejournal_import, 'dispatch'));
+register_importer('livejournal', __('LiveJournal'), __('Import posts from a LiveJournal XML export file.'), array ($livejournal_import, 'dispatch'));
?>
diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php
index fc59794..6b945b2 100644
--- a/wp-admin/import/mt.php
+++ b/wp-admin/import/mt.php
@@ -23,8 +23,19 @@ class MT_Import {
?>
<div class="narrow">
<p><?php _e('Howdy! We&#8217;re about to begin importing all of your Movable Type or Typepad entries into WordPress. To begin, either choose a file to upload and click "Upload file and import," or use FTP to upload your MT export file as <code>mt-export.txt</code> in your <code>/wp-content/</code> directory and then click "Import mt-export.txt"'); ?></p>
+
<?php wp_import_upload_form( add_query_arg('step', 1) ); ?>
- <p><?php _e('The importer is smart enough not to import duplicates, so you can run this multiple times without worry if&#8212;for whatever reason&#8212;it doesn\'t finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces.'); ?> </p>
+<form method="post" action="<?php echo add_query_arg('step', 1); ?>" class="import-upload-form">
+
+<?php wp_nonce_field('import-upload'); ?>
+<p>
+ <input type="hidden" name="upload_type" value="ftp" />
+<?php _e('Or use <code>mt-export.txt</code> in your <code>/wp-content/</code> directory'); ?></p>
+<p class="submit">
+<input type="submit" value="<?php echo attribute_escape(__('Import mt-export.txt')); ?>" />
+</p>
+</form>
+<p><?php _e('The importer is smart enough not to import duplicates, so you can run this multiple times without worry if&#8212;for whatever reason&#8212;it doesn\'t finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces.'); ?> </p>
</div>
<?php
$this->footer();
@@ -126,8 +137,8 @@ class MT_Import {
<div class="wrap">
<h2><?php _e('Assign Authors'); ?></h2>
<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as admin\'s entries.'); ?></p>
-<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <i>italics</i>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p>
-<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
+<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <em>italics</em>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p>
+<p><?php _e('If a new user is created by WordPress, a password will be randomly generated. Manually change the user\'s details if necessary.'); ?></p>
<?php
@@ -173,23 +184,30 @@ class MT_Import {
if ( $post_id = post_exists($post->post_title, '', $post->post_date) ) {
echo '<li>';
- printf(__('Post <i>%s</i> already exists.'), stripslashes($post->post_title));
+ printf(__('Post <em>%s</em> already exists.'), stripslashes($post->post_title));
} else {
echo '<li>';
- printf(__('Importing post <i>%s</i>...'), stripslashes($post->post_title));
+ printf(__('Importing post <em>%s</em>...'), stripslashes($post->post_title));
if ( '' != trim( $post->extended ) )
$post->post_content .= "\n<!--more-->\n$post->extended";
$post->post_author = $this->checkauthor($post->post_author); //just so that if a post already exists, new users are not created by checkauthor
$post_id = wp_insert_post($post);
- if ( is_wp_error( $post_id ) )
+ if ( is_wp_error( $post_id ) )
return $post_id;
// Add categories.
if ( 0 != count($post->categories) ) {
wp_create_categories($post->categories, $post_id);
}
+
+ // Add tags or keywords
+ if ( 1 < strlen($post->post_keywords) ) {
+ // Keywords exist.
+ printf(__('<br />Adding tags <i>%s</i>...'), stripslashes($post->post_keywords));
+ wp_add_post_tags($post_id, $post->post_keywords);
+ }
}
$num_comments = 0;
@@ -206,7 +224,7 @@ class MT_Import {
}
if ( $num_comments )
- printf(' '.__('(%s comments)'), $num_comments);
+ printf(' '.__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments);
$num_pings = 0;
foreach ( $pings as $ping ) {
@@ -223,7 +241,7 @@ class MT_Import {
}
if ( $num_pings )
- printf(' '.__('(%s pings)'), $num_pings);
+ printf(' '.__ngettext('(%s ping)', '(%s pings)', $num_pings), $num_pings);
echo "</li>";
//ob_flush();flush();
@@ -262,7 +280,7 @@ class MT_Import {
// Finishing a post.
$context = '';
$result = $this->save_post($post, $comments, $pings);
- if ( is_wp_error( $result ) )
+ if ( is_wp_error( $result ) )
return $result;
$post = new StdClass;
$comment = new StdClass();
@@ -364,6 +382,8 @@ class MT_Import {
$post->extended .= $line;
} else if ( 'excerpt' == $context ) {
$post->post_excerpt .= $line;
+ } else if ( 'keywords' == $context ) {
+ $post->post_keywords .= $line;
} else if ( 'comment' == $context ) {
$comment->comment_content .= $line;
} else if ( 'ping' == $context ) {
@@ -386,7 +406,7 @@ class MT_Import {
$this->file = get_attached_file($this->id);
$this->get_authors_from_post();
$result = $this->process_posts();
- if ( is_wp_error( $result ) )
+ if ( is_wp_error( $result ) )
return $result;
}
@@ -420,5 +440,5 @@ class MT_Import {
$mt_import = new MT_Import();
-register_importer('mt', __('Movable Type and TypePad'), __('Import posts and comments from a Movable Type or Typepad blog'), array ($mt_import, 'dispatch'));
+register_importer('mt', __('Movable Type and TypePad'), __('Import posts and comments from a Movable Type or Typepad blog.'), array ($mt_import, 'dispatch'));
?>
diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php
index 11fc770..60a4490 100644
--- a/wp-admin/import/rss.php
+++ b/wp-admin/import/rss.php
@@ -71,7 +71,7 @@ class RSS_Import {
$cat_index++;
}
- preg_match('|<guid.+?>(.*?)</guid>|is', $post, $guid);
+ preg_match('|<guid.*?>(.*?)</guid>|is', $post, $guid);
if ($guid)
$guid = $wpdb->escape(trim($guid[1]));
else
@@ -141,6 +141,7 @@ class RSS_Import {
if ( is_wp_error( $result ) )
return $result;
wp_import_cleanup($file['id']);
+ do_action('import_done', 'rss');
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
@@ -177,5 +178,5 @@ class RSS_Import {
$rss_import = new RSS_Import();
-register_importer('rss', __('RSS'), __('Import posts from an RSS feed'), array ($rss_import, 'dispatch'));
+register_importer('rss', __('RSS'), __('Import posts from an RSS feed.'), array ($rss_import, 'dispatch'));
?>
diff --git a/wp-admin/import/stp.php b/wp-admin/import/stp.php
index 9d5371c..53b339a 100644
--- a/wp-admin/import/stp.php
+++ b/wp-admin/import/stp.php
@@ -12,13 +12,13 @@ class STP_Import {
function greet() {
echo '<div class="narrow">';
- echo '<p>'.__('Howdy! This imports tags from an existing Simple Tagging 1.6.2 installation into this blog using the new WordPress native tagging structure.').'</p>';
+ echo '<p>'.__('Howdy! This imports tags from Simple Tagging 1.6.2 into WordPress tags.').'</p>';
echo '<p>'.__('This has not been tested on any other versions of Simple Tagging. Mileage may vary.').'</p>';
echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 4-step program to help you kick that nasty Simple Tagging habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>';
echo '<p><strong>'.__('Don&#8217;t be stupid - backup your database before proceeding!').'</strong></p>';
echo '<form action="admin.php?import=stp&amp;step=1" method="post">';
wp_nonce_field('import-stp');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -70,15 +70,15 @@ class STP_Import {
if ( get_option('stpimp_posts') ) {
delete_option('stpimp_posts');
}
-
+
add_option('stpimp_posts', $posts);
$count = count($posts);
- echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>';
+ echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag to post relationships were read.', 'Done! <strong>%s</strong> tags to post relationships were read.', $count), $count ) . '<br /></p>';
}
echo '<form action="admin.php?import=stp&amp;step=2" method="post">';
wp_nonce_field('import-stp');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -87,14 +87,14 @@ class STP_Import {
function import_t2p ( ) {
echo '<div class="narrow">';
echo '<p><h3>'.__('Adding Tags to Posts&#8230;').'</h3></p>';
-
+
// run that funky magic!
$tags_added = $this->tag2post();
-
- echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags where added!'), $tags_added ) . '<br /></p>';
+
+ echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag was added!', 'Done! <strong>%s</strong> tags were added!', $tags_added), $tags_added ) . '<br /></p>';
echo '<form action="admin.php?import=stp&amp;step=3" method="post">';
wp_nonce_field('import-stp');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -151,5 +151,5 @@ class STP_Import {
$stp_import = new STP_Import();
// add it to the import page!
-register_importer('stp', 'Simple Tagging', __('Import Simple Tagging tags into the new native tagging structure.'), array($stp_import, 'dispatch'));
-?> \ No newline at end of file
+register_importer('stp', 'Simple Tagging', __('Import Simple Tagging tags into WordPress tags.'), array($stp_import, 'dispatch'));
+?>
diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php
index 1fe54c8..1c10015 100644
--- a/wp-admin/import/textpattern.php
+++ b/wp-admin/import/textpattern.php
@@ -46,7 +46,7 @@ class Textpattern_Import {
echo '<form action="admin.php?import=textpattern&amp;step=1" method="post">';
wp_nonce_field('import-textpattern');
$this->db_form();
- echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories &raquo;')).'" /></p>';
+ echo '<p class="submit"><input type="submit" class="button" name="submit" value="'.attribute_escape(__('Import')).'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -177,7 +177,7 @@ class Textpattern_Import {
// Store category translation for future use
add_option('txpcat2wpcat',$txpcat2wpcat);
- echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
+ echo '<p>'.sprintf(__ngettext('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>';
return true;
}
echo __('No Categories to Import!');
@@ -462,7 +462,7 @@ class Textpattern_Import {
}
add_option('txplinks2wplinks',$txplinks2wplinks);
echo '<p>';
- printf(__('Done! <strong>%s</strong> Links imported'), $count);
+ printf(__ngettext('Done! <strong>%s</strong> link imported', 'Done! <strong>%s</strong> links imported', $count), $count);
echo '<br /><br /></p>';
return true;
}
@@ -481,7 +481,7 @@ class Textpattern_Import {
echo '<form action="admin.php?import=textpattern&amp;step=2" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users')));
+ printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Users')));
echo '</form>';
}
@@ -494,7 +494,7 @@ class Textpattern_Import {
echo '<form action="admin.php?import=textpattern&amp;step=3" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
+ printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
echo '</form>';
}
@@ -508,7 +508,7 @@ class Textpattern_Import {
echo '<form action="admin.php?import=textpattern&amp;step=4" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
+ printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
echo '</form>';
}
@@ -520,7 +520,7 @@ class Textpattern_Import {
echo '<form action="admin.php?import=textpattern&amp;step=5" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links')));
+ printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Links')));
echo '</form>';
}
@@ -533,7 +533,7 @@ class Textpattern_Import {
echo '<form action="admin.php?import=textpattern&amp;step=6" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish')));
+ printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Finish')));
echo '</form>';
}
@@ -550,6 +550,7 @@ class Textpattern_Import {
delete_option('txppass');
delete_option('txpname');
delete_option('txphost');
+ do_action('import_done', 'textpattern');
$this->tips();
}
@@ -574,7 +575,7 @@ class Textpattern_Import {
function db_form()
{
- echo '<table class="editform">';
+ echo '<table class="form-table">';
printf('<tr><th scope="row"><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('Textpattern Database User:'));
printf('<tr><th scope="row"><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('Textpattern Database Password:'));
printf('<tr><th scope="row"><label for="dbname">%s</label></th><td><input type="text" id="dbname" name="dbname" /></td></tr>', __('Textpattern Database Name:'));
@@ -645,7 +646,7 @@ class Textpattern_Import {
break;
case 3 :
$result = $this->import_posts();
- if ( is_wp_error( $result ) )
+ if ( is_wp_error( $result ) )
echo $result->get_error_message();
break;
case 4 :
@@ -669,5 +670,5 @@ class Textpattern_Import {
}
$txp_import = new Textpattern_Import();
-register_importer('textpattern', __('Textpattern'), __('Import categories, users, posts, comments, and links from a Textpattern blog'), array ($txp_import, 'dispatch'));
+register_importer('textpattern', __('Textpattern'), __('Import categories, users, posts, comments, and links from a Textpattern blog.'), array ($txp_import, 'dispatch'));
?>
diff --git a/wp-admin/import/utw.php b/wp-admin/import/utw.php
index 120f50c..759809e 100644
--- a/wp-admin/import/utw.php
+++ b/wp-admin/import/utw.php
@@ -14,12 +14,12 @@ class UTW_Import {
function greet() {
echo '<div class="narrow">';
- echo '<p>'.__('Howdy! This imports tags from an existing Ultimate Tag Warrior 3 installation into this blog using the new WordPress native tagging structure.').'</p>';
+ echo '<p>'.__('Howdy! This imports tags from Ultimate Tag Warrior 3 into WordPress tags.').'</p>';
echo '<p>'.__('This has not been tested on any other versions of Ultimate Tag Warrior. Mileage may vary.').'</p>';
echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>';
echo '<p><strong>'.__('Don&#8217;t be stupid - backup your database before proceeding!').'</strong></p>';
echo '<form action="admin.php?import=utw&amp;step=1" method="post">';
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -84,7 +84,7 @@ class UTW_Import {
$count = count($tags);
- echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>';
+ echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag were read.', 'Done! <strong>%s</strong> tags were read.', $count), $count ) . '<br /></p>';
echo '<p>' . __('The following tags were found:') . '</p>';
echo '<ul>';
@@ -106,7 +106,7 @@ class UTW_Import {
echo '<form action="admin.php?import=utw&amp;step=2" method="post">';
wp_nonce_field('import-utw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2').'" /></p>';
echo '</form>';
echo '</div>';
}
@@ -136,13 +136,13 @@ class UTW_Import {
$count = count($posts);
- echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>';
+ echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag to post relationships were read.', 'Done! <strong>%s</strong> tags to post relationships were read.', $count), $count ) . '<br /></p>';
}
echo '<form action="admin.php?import=utw&amp;step=3" method="post">';
wp_nonce_field('import-utw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3').'" /></p>';
echo '</form>';
echo '</div>';
@@ -157,11 +157,11 @@ class UTW_Import {
// run that funky magic!
$tags_added = $this->tag2post();
- echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were added!'), $tags_added ) . '<br /></p>';
+ echo '<p>' . sprintf( __ngettext( 'Done! <strong>%s</strong> tag were added!', 'Done! <strong>%s</strong> tags were added!', $tags_added ), $tags_added ) . '<br /></p>';
echo '<form action="admin.php?import=utw&amp;step=4" method="post">';
wp_nonce_field('import-utw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 4 &raquo;').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 4').'" /></p>';
echo '</form>';
echo '</div>';
@@ -271,6 +271,6 @@ class UTW_Import {
$utw_import = new UTW_Import();
// add it to the import page!
-register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into the new native tagging structure.'), array($utw_import, 'dispatch'));
+register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into WordPress tags.'), array($utw_import, 'dispatch'));
?>
diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php
index dca1c73..03395bd 100644
--- a/wp-admin/import/wordpress.php
+++ b/wp-admin/import/wordpress.php
@@ -2,14 +2,21 @@
class WP_Import {
- var $posts = array ();
- var $posts_processed = array ();
- // Array of arrays. [[0] => XML fragment, [1] => New post ID]
+ var $post_ids_processed = array ();
+ var $orphans = array ();
var $file;
var $id;
var $mtnames = array ();
var $newauthornames = array ();
+ var $allauthornames = array ();
+
+ var $author_ids = array ();
+ var $tags = array ();
+ var $categories = array ();
+
var $j = -1;
+ var $fetch_attachments = false;
+ var $url_remap = array ();
function header() {
echo '<div class="wrap">';
@@ -42,44 +49,48 @@ class WP_Import {
return $return;
}
- function users_form($n) {
- global $wpdb, $testing;
- $users = get_users_of_blog($wpdb->blogid);
-?><select name="userselect[<?php echo attribute_escape($n); ?>]">
- <option value="#NONE#">- Select -</option>
- <?php
- foreach ($users as $user) {
- echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
- }
-?>
- </select>
- <?php
+ function has_gzip() {
+ return is_callable('gzopen');
}
- //function to check the authorname and do the mapping
- function checkauthor($author) {
- global $wpdb;
+ function fopen($filename, $mode='r') {
+ if ( $this->has_gzip() )
+ return gzopen($filename, $mode);
+ return fopen($filename, $mode);
+ }
- $map = $_POST['userselect'];
+ function feof($fp) {
+ if ( $this->has_gzip() )
+ return gzeof($fp);
+ return feof($fp);
+ }
- $user_id = username_exists($map[$author]); //use that key to get the value of the author's name from $newauthornames
+ function fgets($fp, $len=8192) {
+ if ( $this->has_gzip() )
+ return gzgets($fp, $len);
+ return fgets($fp, $len);
+ }
- return $user_id;
+ function fclose($fp) {
+ if ( $this->has_gzip() )
+ return gzclose($fp);
+ return fclose($fp);
}
- function get_entries() {
+ function get_entries($process_post_func=NULL) {
set_magic_quotes_runtime(0);
- $this->posts = array();
- $this->categories = array();
- $this->tags = array();
- $num = 0;
$doing_entry = false;
+ $is_wxr_file = false;
- $fp = fopen($this->file, 'r');
+ $fp = $this->fopen($this->file, 'r');
if ($fp) {
- while ( !feof($fp) ) {
- $importline = rtrim(fgets($fp));
+ while ( !$this->feof($fp) ) {
+ $importline = rtrim($this->fgets($fp));
+
+ // this doesn't check that the file is perfectly valid but will at least confirm that it's not the wrong format altogether
+ if ( !$is_wxr_file && preg_match('|xmlns:wp="http://wordpress[.]org/export/\d+[.]\d+/"|', $importline) )
+ $is_wxr_file = true;
if ( false !== strpos($importline, '<wp:category>') ) {
preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
@@ -92,44 +103,31 @@ class WP_Import {
continue;
}
if ( false !== strpos($importline, '<item>') ) {
- $this->posts[$num] = '';
+ $this->post = '';
$doing_entry = true;
continue;
}
if ( false !== strpos($importline, '</item>') ) {
- $num++;
$doing_entry = false;
+ if ($process_post_func)
+ call_user_func($process_post_func, $this->post);
continue;
}
if ( $doing_entry ) {
- $this->posts[$num] .= $importline . "\n";
- }
- }
-
- foreach ($this->posts as $post) {
- $post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
- if ($post_ID) {
- $this->posts_processed[$post_ID][0] = &$post;
- $this->posts_processed[$post_ID][1] = 0;
+ $this->post .= $importline . "\n";
}
}
- fclose($fp);
+ $this->fclose($fp);
}
+
+ return $is_wxr_file;
+
}
function get_wp_authors() {
- $temp = array ();
- $i = -1;
- foreach ($this->posts as $post) {
- if ('' != trim($post)) {
- ++ $i;
- $author = $this->get_tag( $post, 'dc:creator' );
- array_push($temp, "$author"); //store the extracted author names in a temporary array
- }
- }
-
// We need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting.
+ $temp = $this->allauthornames;
$authors[0] = array_shift($temp);
$y = count($temp) + 1;
for ($x = 1; $x < $y; $x ++) {
@@ -142,36 +140,50 @@ class WP_Import {
}
function get_authors_from_post() {
- $formnames = array ();
- $selectnames = array ();
-
- foreach ((array)$_POST['user'] as $key => $line) {
- $newname = trim(stripslashes($line));
- if ($newname == '')
- $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
- array_push($formnames, "$newname");
- } // $formnames is the array with the form entered names
-
- foreach ($_POST['userselect'] as $user => $key) {
- $selected = trim(stripslashes($key));
- array_push($selectnames, "$selected");
- }
+ global $current_user;
+
+ // this will populate $this->author_ids with a list of author_names => user_ids
- $count = count($formnames);
- for ($i = 0; $i < $count; $i ++) {
- if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form
- array_push($this->newauthornames, "$selectnames[$i]");
- } else {
- array_push($this->newauthornames, "$formnames[$i]");
+ foreach ( $_POST['author_in'] as $i => $in_author_name ) {
+
+ if ( !empty($_POST['user_select'][$i]) ) {
+ // an existing user was selected in the dropdown list
+ $user = get_userdata( intval($_POST['user_select'][$i]) );
+ if ( isset($user->ID) )
+ $this->author_ids[$in_author_name] = $user->ID;
+ }
+ elseif ( $this->allow_create_users() ) {
+ // nothing was selected in the dropdown list, so we'll use the name in the text field
+
+ $new_author_name = trim($_POST['user_create'][$i]);
+ // if the user didn't enter a name, assume they want to use the same name as in the import file
+ if ( empty($new_author_name) )
+ $new_author_name = $in_author_name;
+
+ $user_id = username_exists($new_author_name);
+ if ( !$user_id ) {
+ $user_id = wp_create_user($new_author_name, wp_generate_password());
+ }
+
+ $this->author_ids[$in_author_name] = $user_id;
+ }
+
+ // failsafe: if the user_id was invalid, default to the current user
+ if ( empty($this->author_ids[$in_author_name]) ) {
+ $this->author_ids[$in_author_name] = intval($current_user->ID);
}
}
+
}
function wp_authors_form() {
?>
<h2><?php _e('Assign Authors'); ?></h2>
<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
- <?php
+<?php
+ if ( $this->allow_create_users() ) {
+ echo '<p>'.__('If a new user is created by WordPress, a password will be randomly generated. Manually change the user\'s details if necessary.')."</p>\n";
+ }
$authors = $this->get_wp_authors();
@@ -181,31 +193,76 @@ class WP_Import {
$j = -1;
foreach ($authors as $author) {
++ $j;
- echo '<li>'.__('Current author:').' <strong>'.$author.'</strong><br />'.'Map to existing: ';
- $this->users_form($author);
+ echo '<li>'.__('Import author:').' <strong>'.$author.'</strong><br />';
+ $this->users_form($j, $author);
echo '</li>';
}
- echo '<input type="submit" value="Submit">'.'<br />';
+ if ( $this->allow_fetch_attachments() ) {
+?>
+</ol>
+<h2><?php _e('Import Attachments'); ?></h2>
+<p>
+ <input type="checkbox" value="1" name="attachments" id="import-attachments" />
+ <label for="import-attachments"><?php _e('Download and import file attachments') ?></label>
+</p>
+
+<?php
+ }
+
+ echo '<input type="submit" value="'.attribute_escape( __('Submit') ).'">'.'<br />';
echo '</form>';
- echo '</ol>';
}
+ function users_form($n, $author) {
+
+ if ( $this->allow_create_users() ) {
+ printf(__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user_create['.intval($n).']'.'" maxlength="30"> <br />');
+ }
+ else {
+ echo __('Map to existing').'<br />';
+ }
+
+ // keep track of $n => $author name
+ echo '<input type="hidden" name="author_in['.intval($n).']" value="'.htmlspecialchars($author).'" />';
+
+ $users = get_users_of_blog();
+?><select name="user_select[<?php echo $n; ?>]">
+ <option value="0"><?php _e('- Select -'); ?></option>
+ <?php
+ foreach ($users as $user) {
+ echo '<option value="'.$user->user_id.'">'.$user->user_login.'</option>';
+ }
+?>
+ </select>
+ <?php
+ }
+
function select_authors() {
- $file = wp_import_handle_upload();
- if ( isset($file['error']) ) {
- echo '<p>'.__('Sorry, there has been an error.').'</p>';
- echo '<p><strong>' . $file['error'] . '</strong></p>';
- return;
+ $is_wxr_file = $this->get_entries(array(&$this, 'process_author'));
+ if ( $is_wxr_file ) {
+ $this->wp_authors_form();
}
- $this->file = $file['file'];
- $this->id = (int) $file['id'];
+ else {
+ echo '<h2>'.__('Invalid file').'</h2>';
+ echo '<p>'.__('Please upload a valid WXR (WordPress eXtended RSS) export file.').'</p>';
+ }
+ }
- $this->get_entries();
- $this->wp_authors_form();
+ // fetch the user ID for a given author name, respecting the mapping preferences
+ function checkauthor($author) {
+ global $current_user;
+
+ if ( !empty($this->author_ids[$author]) )
+ return $this->author_ids[$author];
+
+ // failsafe: map to the current user
+ return $current_user->ID;
}
+
+
function process_categories() {
global $wpdb;
@@ -256,19 +313,22 @@ class WP_Import {
}
}
+ function process_author($post) {
+ $author = $this->get_tag( $post, 'dc:creator' );
+ if ($author)
+ $this->allauthornames[] = $author;
+ }
+
function process_posts() {
$i = -1;
echo '<ol>';
- foreach ($this->posts as $post) {
- $result = $this->process_post($post);
- if ( is_wp_error( $result ) )
- return $result;
- }
+ $this->get_entries(array(&$this, 'process_post'));
echo '</ol>';
wp_import_cleanup($this->id);
+ do_action('import_done', 'wordpress');
echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>';
}
@@ -277,8 +337,10 @@ class WP_Import {
global $wpdb;
$post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
- if ( $post_ID && !empty($this->posts_processed[$post_ID][1]) ) // Processed already
+ if ( $post_ID && !empty($this->post_ids_processed[$post_ID]) ) // Processed already
return 0;
+
+ set_time_limit( 60 );
// There are only ever one of these
$post_title = $this->get_tag( $post, 'title' );
@@ -291,6 +353,7 @@ class WP_Import {
$post_parent = $this->get_tag( $post, 'wp:post_parent' );
$menu_order = $this->get_tag( $post, 'wp:menu_order' );
$post_type = $this->get_tag( $post, 'wp:post_type' );
+ $post_password = $this->get_tag( $post, 'wp:post_password' );
$guid = $this->get_tag( $post, 'guid' );
$post_author = $this->get_tag( $post, 'dc:creator' );
@@ -317,35 +380,52 @@ class WP_Import {
$cat_index++;
}
- if ($post_id = post_exists($post_title, '', $post_date)) {
+ $post_exists = post_exists($post_title, '', $post_date);
+
+ if ( $post_exists ) {
echo '<li>';
- printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
+ printf(__('Post <em>%s</em> already exists.'), stripslashes($post_title));
} else {
// If it has parent, process parent first.
$post_parent = (int) $post_parent;
- if ($parent = $this->posts_processed[$post_parent]) {
- if (!$parent[1]) {
- $result = $this->process_post($parent[0]); // If not yet, process the parent first.
- if ( is_wp_error( $result ) )
- return $result;
+ if ($post_parent) {
+ // if we already know the parent, map it to the local ID
+ if ( $parent = $this->post_ids_processed[$post_parent] ) {
+ $post_parent = $parent; // new ID of the parent
+ }
+ else {
+ // record the parent for later
+ $this->orphans[intval($post_ID)] = $post_parent;
}
- $post_parent = $parent[1]; // New ID of the parent;
}
echo '<li>';
- printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor
- $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type');
- $comment_post_ID = $post_id = wp_insert_post($postdata);
+ $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent', 'menu_order', 'post_type', 'post_password');
+ if ($post_type == 'attachment') {
+ $remote_url = $this->get_tag( $post, 'wp:attachment_url' );
+ if ( !$remote_url )
+ $remote_url = $guid;
+
+ $comment_post_ID = $post_id = $this->process_attachment($postdata, $remote_url);
+ if ( !$post_id or is_wp_error($post_id) )
+ return $post_id;
+ }
+ else {
+ printf(__('Importing post <em>%s</em>...'), stripslashes($post_title));
+ $comment_post_ID = $post_id = wp_insert_post($postdata);
+ }
+
if ( is_wp_error( $post_id ) )
return $post_id;
// Memorize old and new ID.
- if ( $post_id && $post_ID && $this->posts_processed[$post_ID] )
- $this->posts_processed[$post_ID][1] = $post_id; // New ID.
+ if ( $post_id && $post_ID ) {
+ $this->post_ids_processed[intval($post_ID)] = intval($post_id);
+ }
// Add categories.
if (count($categories) > 0) {
@@ -379,7 +459,7 @@ class WP_Import {
$tag_id = wp_insert_term($tag, 'post_tag');
$tag_id = $tag_id['term_id'];
}
- $post_tags[] = intval( $tag_id );
+ $post_tags[] = intval($tag_id);
}
wp_set_post_tags($post_id, $post_tags);
}
@@ -401,7 +481,8 @@ class WP_Import {
$comment_type = $this->get_tag( $comment, 'wp:comment_type');
$comment_parent = $this->get_tag( $comment, 'wp:comment_parent');
- if ( !comment_exists($comment_author, $comment_date) ) {
+ // if this is a new post we can skip the comment_exists() check
+ if ( !$post_exists || !comment_exists($comment_author, $comment_date) ) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent');
wp_insert_comment($commentdata);
$num_comments++;
@@ -409,7 +490,7 @@ class WP_Import {
} }
if ( $num_comments )
- printf(' '.__('(%s comments)'), $num_comments);
+ printf(' '.__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments);
// Now for post meta
preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
@@ -418,23 +499,217 @@ class WP_Import {
$key = $this->get_tag( $p, 'wp:meta_key' );
$value = $this->get_tag( $p, 'wp:meta_value' );
$value = stripslashes($value); // add_post_meta() will escape.
- add_post_meta( $post_id, $key, $value );
+
+ $this->process_post_meta($post_id, $key, $value);
+
} }
+
+ do_action('import_post_added', $post_id);
+ print "</li>\n";
}
- function import() {
- $this->id = (int) $_GET['id'];
+ function process_post_meta($post_id, $key, $value) {
+ // the filter can return false to skip a particular metadata key
+ $_key = apply_filters('import_post_meta_key', $key);
+ if ( $_key ) {
+ add_post_meta( $post_id, $_key, $value );
+ do_action('import_post_meta', $post_id, $_key, $value);
+ }
+ }
+
+ function process_attachment($postdata, $remote_url) {
+ if ($this->fetch_attachments and $remote_url) {
+ printf( __('Importing attachment <em>%s</em>... '), htmlspecialchars($remote_url) );
+ $upload = $this->fetch_remote_file($postdata, $remote_url);
+ if ( is_wp_error($upload) ) {
+ printf( __('Remote file error: %s'), htmlspecialchars($upload->get_error_message()) );
+ return $upload;
+ }
+ else {
+ print '('.size_format(filesize($upload['file'])).')';
+ }
+
+ if ( $info = wp_check_filetype($upload['file']) ) {
+ $postdata['post_mime_type'] = $info['type'];
+ }
+ else {
+ print __('Invalid file type');
+ return;
+ }
+
+ $postdata['guid'] = $upload['url'];
+
+ // as per wp-admin/includes/upload.php
+ $post_id = wp_insert_attachment($postdata, $upload['file']);
+ wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) );
+
+ // remap the thumbnail url. this isn't perfect because we're just guessing the original url.
+ if ( preg_match('@^image/@', $info['type']) && $thumb_url = wp_get_attachment_thumb_url($post_id) ) {
+ $parts = pathinfo($remote_url);
+ $ext = $parts['extension'];
+ $name = basename($parts['basename'], ".{$ext}");
+ $this->url_remap[$parts['dirname'] . '/' . $name . '.thumbnail.' . $ext] = $thumb_url;
+ }
+
+ return $post_id;
+ }
+ else {
+ printf( __('Skipping attachment <em>%s</em>'), htmlspecialchars($remote_url) );
+ }
+ }
+
+ function fetch_remote_file($post, $url) {
+ $upload = wp_upload_dir($post['post_date']);
+
+ // extract the file name and extension from the url
+ $file_name = basename($url);
+
+ // get placeholder file in the upload dir with a unique sanitized filename
+ $upload = wp_upload_bits( $file_name, 0, '', $post['post_date']);
+ if ( $upload['error'] ) {
+ echo $upload['error'];
+ return new WP_Error( 'upload_dir_error', $upload['error'] );
+ }
+
+ // fetch the remote url and write it to the placeholder file
+ $headers = wp_get_http($url, $upload['file']);
+
+ // make sure the fetch was successful
+ if ( $headers['response'] != '200' ) {
+ @unlink($upload['file']);
+ return new WP_Error( 'import_file_error', sprintf(__('Remote file returned error response %d'), intval($headers['response'])) );
+ }
+ elseif ( isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length'] ) {
+ @unlink($upload['file']);
+ return new WP_Error( 'import_file_error', __('Remote file is incorrect size') );
+ }
+
+ $max_size = $this->max_attachment_size();
+ if ( !empty($max_size) and filesize($upload['file']) > $max_size ) {
+ @unlink($upload['file']);
+ return new WP_Error( 'import_file_error', sprintf(__('Remote file is too large, limit is %s', size_format($max_size))) );
+ }
+
+ // keep track of the old and new urls so we can substitute them later
+ $this->url_remap[$url] = $upload['url'];
+ // if the remote url is redirected somewhere else, keep track of the destination too
+ if ( $headers['x-final-location'] != $url )
+ $this->url_remap[$headers['x-final-location']] = $upload['url'];
+
+ return $upload;
+
+ }
+
+ // sort by strlen, longest string first
+ function cmpr_strlen($a, $b) {
+ return strlen($b) - strlen($a);
+ }
+
+ // update url references in post bodies to point to the new local files
+ function backfill_attachment_urls() {
+
+ // make sure we do the longest urls first, in case one is a substring of another
+ uksort($this->url_remap, array(&$this, 'cmpr_strlen'));
- $this->file = get_attached_file($this->id);
+ global $wpdb;
+ foreach ($this->url_remap as $from_url => $to_url) {
+ // remap urls in post_content
+ $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, '%s', '%s')", $from_url, $to_url) );
+ // remap enclosure urls
+ $result = $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, '%s', '%s') WHERE meta_key='enclosure'", $from_url, $to_url) );
+ }
+ }
+
+ // update the post_parent of orphans now that we know the local id's of all parents
+ function backfill_parents() {
+ global $wpdb;
+
+ foreach ($this->orphans as $child_id => $parent_id) {
+ $local_child_id = $this->post_ids_processed[$child_id];
+ $local_parent_id = $this->post_ids_processed[$parent_id];
+ if ($local_child_id and $local_parent_id) {
+ $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = %d WHERE ID = %d", $local_parent_id, $local_child_id));
+ }
+ }
+ }
+
+ function is_valid_meta_key($key) {
+ // skip _wp_attached_file metadata since we'll regenerate it from scratch
+ if ( $key == '_wp_attached_file' )
+ return false;
+ return $key;
+ }
+
+ // give the user the option of creating new users to represent authors in the import file?
+ function allow_create_users() {
+ return apply_filters('import_allow_create_users', true);
+ }
+
+ // give the user the option of downloading and importing attached files
+ function allow_fetch_attachments() {
+ return apply_filters('import_allow_fetch_attachments', true);
+ }
+
+ function max_attachment_size() {
+ // can be overridden with a filter - 0 means no limit
+ return apply_filters('import_attachment_size_limit', 0);
+ }
+
+ function import_start() {
+ wp_defer_term_counting(true);
+ wp_defer_comment_counting(true);
+ do_action('import_start');
+ }
+
+ function import_end() {
+ do_action('import_end');
+
+ // clear the caches after backfilling
+ foreach ($this->post_ids_processed as $post_id)
+ clean_post_cache($post_id);
+
+ wp_defer_term_counting(false);
+ wp_defer_comment_counting(false);
+ }
+
+ function import($id, $fetch_attachments = false) {
+ $this->id = (int) $id;
+ $this->fetch_attachments = ($this->allow_fetch_attachments() && (bool) $fetch_attachments);
+
+ add_filter('import_post_meta_key', array($this, 'is_valid_meta_key'));
+ $file = get_attached_file($this->id);
+ $this->import_file($file);
+ }
+
+ function import_file($file) {
+ $this->file = $file;
+
+ $this->import_start();
$this->get_authors_from_post();
$this->get_entries();
$this->process_categories();
$this->process_tags();
$result = $this->process_posts();
+ $this->backfill_parents();
+ $this->backfill_attachment_urls();
+ $this->import_end();
+
if ( is_wp_error( $result ) )
return $result;
}
+ function handle_upload() {
+ $file = wp_import_handle_upload();
+ if ( isset($file['error']) ) {
+ echo '<p>'.__('Sorry, there has been an error.').'</p>';
+ echo '<p><strong>' . $file['error'] . '</strong></p>';
+ return false;
+ }
+ $this->file = $file['file'];
+ $this->id = (int) $file['id'];
+ return true;
+ }
+
function dispatch() {
if (empty ($_GET['step']))
$step = 0;
@@ -448,11 +723,12 @@ class WP_Import {
break;
case 1 :
check_admin_referer('import-upload');
- $this->select_authors();
+ if ( $this->handle_upload() )
+ $this->select_authors();
break;
case 2:
check_admin_referer('import-wordpress');
- $result = $this->import();
+ $result = $this->import( $_GET['id'], $_POST['attachments'] );
if ( is_wp_error( $result ) )
echo $result->get_error_message();
break;
@@ -467,6 +743,6 @@ class WP_Import {
$wp_import = new WP_Import();
-register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, pages, and categories</strong> from a WordPress export file'), array ($wp_import, 'dispatch'));
+register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, pages, and categories</strong> from a WordPress export file.'), array ($wp_import, 'dispatch'));
?>
diff --git a/wp-admin/import/wp-cat2tag.php b/wp-admin/import/wp-cat2tag.php
index d38e17a..246125e 100644
--- a/wp-admin/import/wp-cat2tag.php
+++ b/wp-admin/import/wp-cat2tag.php
@@ -5,12 +5,12 @@ class WP_Categories_to_Tags {
var $all_categories = array();
function header() {
- print '<div class="wrap">';
- print '<h2>' . __('Convert Categories to Tags') . '</h2>';
+ echo '<div class="wrap">';
+ echo '<h2>' . __('Convert Categories to Tags') . '</h2>';
}
function footer() {
- print '</div>';
+ echo '</div>';
}
function populate_all_categories() {
@@ -19,75 +19,101 @@ class WP_Categories_to_Tags {
$categories = get_categories('get=all');
foreach ( $categories as $category ) {
if ( !tag_exists($wpdb->escape($category->name)) )
- $this->all_categories[] = $category;
+ $this->all_categories[] = $category;
}
}
function welcome() {
$this->populate_all_categories();
- print '<div class="narrow">';
+ echo '<div class="narrow">';
if (count($this->all_categories) > 0) {
- print '<p>' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '</p>';
- print '<p>' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '</p>';
+ echo '<p>' . __('Hey there. Here you can selectively converts existing categories to tags. To get started, check the categories you wish to be converted, then click the Convert button.') . '</p>';
+ echo '<p>' . __('Keep in mind that if you convert a category with child categories, the children become top-level orphans.') . '</p>';
$this->categories_form();
} else {
- print '<p>'.__('You have no categories to convert!').'</p>';
+ echo '<p>'.__('You have no categories to convert!').'</p>';
}
- print '</div>';
+ echo '</div>';
}
function categories_form() {
- print '<form action="admin.php?import=wp-cat2tag&amp;step=2" method="post">';
+?>
+<script type="text/javascript">
+<!--
+var checkflag = "false";
+function check_all_rows() {
+ field = document.formlist;
+ if ( 'false' == checkflag ) {
+ for ( i = 0; i < field.length; i++ ) {
+ if ( 'cats_to_convert[]' == field[i].name )
+ field[i].checked = true;
+ }
+ checkflag = 'true';
+ return '<?php _e('Uncheck All') ?>';
+ } else {
+ for ( i = 0; i < field.length; i++ ) {
+ if ( 'cats_to_convert[]' == field[i].name )
+ field[i].checked = false;
+ }
+ checkflag = 'false';
+ return '<?php _e('Check All') ?>';
+ }
+}
+
+// -->
+</script>
+<?php
+ echo '<form name="formlist" id="formlist" action="admin.php?import=wp-cat2tag&amp;step=2" method="post">
+ <p><input type="button" class="button-secondary" value="' . __('Check All') . '"' . ' onClick="this.value=check_all_rows()"></p>';
wp_nonce_field('import-cat2tag');
- print '<ul style="list-style:none">';
+ echo '<ul style="list-style:none">';
$hier = _get_term_hierarchy('category');
foreach ($this->all_categories as $category) {
$category = sanitize_term( $category, 'category', 'display' );
-
+
if ((int) $category->parent == 0) {
- print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>';
+ echo '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>';
if (isset($hier[$category->term_id])) {
$this->_category_children($category, $hier);
}
- print '</li>';
+ echo '</li>';
}
}
- print '</ul>';
+ echo '</ul>';
+
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="' . __('Convert Tags') . '" /></p>';
- print '<p class="submit"><input type="submit" name="submit" value="' . __('Convert &raquo;') . '" /></p>';
- print '</form>';
+ echo '</form>';
}
function _category_children($parent, $hier) {
- print '<ul style="list-style:none">';
+ echo '<ul style="list-style:none">';
foreach ($hier[$parent->term_id] as $child_id) {
$child =& get_category($child_id);
- print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->term_id) . '" /> ' . $child->name . ' (' . $child->count . ')</label>';
+ echo '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->term_id) . '" /> ' . $child->name . ' (' . $child->count . ')</label>';
if (isset($hier[$child->term_id])) {
$this->_category_children($child, $hier);
}
- print '</li>';
+ echo '</li>';
}
- print '</ul>';
+ echo '</ul>';
}
function _category_exists($cat_id) {
- global $wpdb;
-
$cat_id = (int) $cat_id;
$maybe_exists = category_exists($cat_id);
@@ -103,9 +129,9 @@ class WP_Categories_to_Tags {
global $wpdb;
if ( (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) && empty($this->categories_to_convert)) {
- print '<div class="narrow">';
- print '<p>' . sprintf(__('Uh, oh. Something didn\'t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>';
- print '</div>';
+ echo '<div class="narrow">';
+ echo '<p>' . sprintf(__('Uh, oh. Something didn&#8217;t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>';
+ echo '</div>';
return;
}
@@ -114,12 +140,12 @@ class WP_Categories_to_Tags {
$this->categories_to_convert = $_POST['cats_to_convert'];
$hier = _get_term_hierarchy('category');
- print '<ul>';
+ echo '<ul>';
foreach ( (array) $this->categories_to_convert as $cat_id) {
$cat_id = (int) $cat_id;
- print '<li>' . sprintf(__('Converting category #%s ... '), $cat_id);
+ echo '<li>' . sprintf(__('Converting category #%s ... '), $cat_id);
if (!$this->_category_exists($cat_id)) {
_e('Category doesn\'t exist!');
@@ -128,7 +154,7 @@ class WP_Categories_to_Tags {
if ( tag_exists($wpdb->escape($category->name)) ) {
_e('Category is already a tag.');
- print '</li>';
+ echo '</li>';
continue;
}
@@ -138,7 +164,7 @@ class WP_Categories_to_Tags {
$id = $id['term_taxonomy_id'];
$posts = get_objects_in_term($category->term_id, 'category');
foreach ( $posts as $post ) {
- if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") )
+ if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") )
$wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$post', '$id')");
clean_post_cache($post);
}
@@ -166,10 +192,11 @@ class WP_Categories_to_Tags {
_e('Converted successfully.');
}
- print '</li>';
+ echo '</li>';
}
- print '</ul>';
+ echo '</ul>';
+ echo '<p>' . sprintf( __('We&#8217;re all done here, but you can always <a href="%s">convert more</a>.'), 'admin.php?import=wp-cat2tag' ) . '</p>';
}
function init() {
@@ -179,9 +206,9 @@ class WP_Categories_to_Tags {
$this->header();
if (!current_user_can('manage_categories')) {
- print '<div class="narrow">';
- print '<p>' . __('Cheatin&#8217; uh?') . '</p>';
- print '</div>';
+ echo '<div class="narrow">';
+ echo '<p>' . __('Cheatin&#8217; uh?') . '</p>';
+ echo '</div>';
} else {
if ( $step > 1 )
check_admin_referer('import-cat2tag');