'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'
';
}
function footer() {
echo '';
}
function greet() {
echo '';
echo '
'.__('Howdy! This imports tags from Bunny’s Technorati Tags into WordPress tags.').'
';
echo '
'.__('This is suitable for Bunny’s Technorati Tags version 0.6.').'
';
echo '
'.__('All existing Bunny’s Technorati Tags will be removed after import.').'
';
echo '
'.__('Don’t be stupid - backup your database before proceeding!').'
';
echo '
';
echo '
';
}
function dispatch() {
if ( empty($_GET['step']) )
$step = 0;
else
$step = absint($_GET['step']);
// load the header
$this->header();
switch ( $step ) {
case 0 :
$this->greet();
break;
case 1 :
check_admin_referer('import-btt');
$this->check_post_keyword( true );
break;
case 2 :
check_admin_referer('import-btt');
$this->check_post_keyword( false );
break;
case 3:
$this->done();
break;
}
// load the footer
$this->footer();
}
function check_post_keyword($precheck = true) {
global $wpdb;
echo '';
echo '
'.__('Reading Bunny’s Technorati 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 '
' . __('No Tags Found!') . '
';
return false;
} else {
$count = count($metakeys);
echo '
' . sprintf( _n('Done! %s post with tags were read.', 'Done! %s posts with tags were read.', $count), $count ) . '
';
echo '
';
foreach ( $metakeys as $post_meta ) {
if ( $post_meta->meta_value != '' ) {
$post_keys = explode(' ', $post_meta->meta_value);
foreach ( $post_keys as $keyword ) {
$keyword = addslashes(trim(str_replace('+',' ',$keyword)));
if ( '' != $keyword ) {
echo '- ' . $post_meta->post_id . ' - ' . $keyword . '
';
if ( !$precheck )
wp_add_post_tags($post_meta->post_id, $keyword);
}
}
}
if ( !$precheck )
delete_post_meta($post_meta->post_id, 'tags');
}
echo '
';
}
echo '
';
echo '
';
}
function done() {
echo '