-
+ C8A75BF7F66D82A5103FD28CC587BA172DDA2913DAA728C7AFEA256566DC277C809DB7B7854BEEE0011ABCDA06313658F8C8F3D0704690E700A4F71D91F41F2Dmp-wp/wp-admin/import/jkw.php(0 . 0)(1 . 192)
18910 <?php
18911 /**
18912 * Jeromes Keyword Plugin Importer
18913 *
18914 * @package WordPress
18915 * @subpackage Importer
18916 */
18917
18918 /**
18919 * Jeromes Keyword Plugin Importer class
18920 *
18921 * Will convert Jeromes Keyword Plugin tags to WordPress taxonomy tags.
18922 *
18923 * @since 2.3
18924 */
18925 class JeromesKeyword_Import {
18926
18927 function header() {
18928 echo '<div class="wrap">';
18929 screen_icon();
18930 echo '<h2>'.__('Import Jerome’s Keywords').'</h2>';
18931 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
18932 }
18933
18934 function footer() {
18935 echo '</div>';
18936 }
18937
18938 function greet() {
18939 echo '<div class="narrow">';
18940 echo '<p>'.__('Howdy! This imports tags from Jerome’s Keywords into WordPress tags.').'</p>';
18941 echo '<p>'.__('This is suitable for Jerome’s Keywords version 1.x and 2.0a.').'</p>';
18942 echo '<p><strong>'.__('All existing Jerome’s Keywords will be removed after import.').'</strong></p>';
18943 echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>';
18944 echo '<form action="admin.php?import=jkw&step=1" method="post">';
18945 wp_nonce_field('import-jkw');
18946 echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Import Version 1.x').'" /></p>';
18947 echo '</form>';
18948 echo '<form action="admin.php?import=jkw&step=3" method="post">';
18949 wp_nonce_field('import-jkw');
18950 echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Import Version 2.0a').'" /></p>';
18951 echo '</form>';
18952 echo '</div>';
18953 }
18954
18955 function dispatch() {
18956 if ( empty($_GET['step']) )
18957 $step = 0;
18958 else
18959 $step = absint($_GET['step']);
18960
18961 // load the header
18962 $this->header();
18963
18964 switch ( $step ) {
18965 case 0 :
18966 $this->greet();
18967 break;
18968 case 1 :
18969 check_admin_referer('import-jkw');
18970 $this->check_V1_post_keyword( true );
18971 break;
18972 case 2 :
18973 check_admin_referer('import-jkw');
18974 $this->check_V1_post_keyword( false );
18975 break;
18976 case 3 :
18977 check_admin_referer('import-jkw');
18978 $this->check_V2_post_keyword( true );
18979 break;
18980 case 4 :
18981 check_admin_referer('import-jkw');
18982 $this->check_V2_post_keyword( false );
18983 break;
18984 case 5:
18985 check_admin_referer('import-jkw');
18986 $this->cleanup_V2_import();
18987 break;
18988 case 6:
18989 $this->done();
18990 break;
18991 }
18992
18993 // load the footer
18994 $this->footer();
18995 }
18996
18997 function check_V1_post_keyword($precheck = true) {
18998 global $wpdb;
18999
19000 echo '<div class="narrow">';
19001 echo '<p><h3>'.__('Reading Jerome’s Keywords Tags…').'</h3></p>';
19002
19003 // import Jerome's Keywords tags
19004 $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'keywords'");
19005 if ( !is_array($metakeys)) {
19006 echo '<p>' . __('No Tags Found!') . '</p>';
19007 return false;
19008 } else {
19009 $count = count($metakeys);
19010 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>';
19011 echo '<ul>';
19012 foreach ( $metakeys as $post_meta ) {
19013 if ( $post_meta->meta_value != '' ) {
19014 $post_keys = explode(',', $post_meta->meta_value);
19015 foreach ( $post_keys as $keyword ) {
19016 $keyword = addslashes(trim($keyword));
19017 if ( '' != $keyword ) {
19018 echo '<li>' . $post_meta->post_id . ' - ' . $keyword . '</li>';
19019 if ( !$precheck )
19020 wp_add_post_tags($post_meta->post_id, $keyword);
19021 }
19022 }
19023 }
19024 if ( !$precheck )
19025 delete_post_meta($post_meta->post_id, 'keywords');
19026 }
19027 echo '</ul>';
19028 }
19029
19030 echo '<form action="admin.php?import=jkw&step='.($precheck? 2:6).'" method="post">';
19031 wp_nonce_field('import-jkw');
19032 echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Next').'" /></p>';
19033 echo '</form>';
19034 echo '</div>';
19035 }
19036
19037 function check_V2_post_keyword($precheck = true) {
19038 global $wpdb;
19039
19040 echo '<div class="narrow">';
19041 echo '<p><h3>'.__('Reading Jerome’s Keywords Tags…').'</h3></p>';
19042
19043 // import Jerome's Keywords tags
19044 $tablename = $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1);
19045 $metakeys = $wpdb->get_results("SELECT post_id, tag_name FROM $tablename");
19046 if ( !is_array($metakeys) ) {
19047 echo '<p>' . __('No Tags Found!') . '</p>';
19048 return false;
19049 } else {
19050 $count = count($metakeys);
19051 echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag were read.', 'Done! <strong>%s</strong> tags were read.', $count), $count ) . '<br /></p>';
19052 echo '<ul>';
19053 foreach ( $metakeys as $post_meta ) {
19054 $keyword = addslashes(trim($post_meta->tag_name));
19055 if ( $keyword != '' ) {
19056 echo '<li>' . $post_meta->post_id . ' - ' . $keyword . '</li>';
19057 if ( !$precheck )
19058 wp_add_post_tags($post_meta->post_id, $keyword);
19059 }
19060 }
19061 echo '</ul>';
19062 }
19063 echo '<form action="admin.php?import=jkw&step='.($precheck? 4:5).'" method="post">';
19064 wp_nonce_field('import-jkw');
19065 echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Next').'" /></p>';
19066 echo '</form>';
19067 echo '</div>';
19068 }
19069
19070 function cleanup_V2_import() {
19071 global $wpdb;
19072
19073 /* options from V2.0a (jeromes-keywords.php) */
19074 $options = array('version', 'keywords_table', 'query_varname', 'template', 'meta_always_include', 'meta_includecats', 'meta_autoheader', 'search_strict', 'use_feed_cats', 'post_linkformat', 'post_tagseparator', 'post_includecats', 'post_notagstext', 'cloud_linkformat', 'cloud_tagseparator', 'cloud_includecats', 'cloud_sortorder', 'cloud_displaymax', 'cloud_displaymin', 'cloud_scalemax', 'cloud_scalemin');
19075
19076 $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1));
19077
19078 foreach ( $options as $o )
19079 delete_option('jkeywords_' . $o);
19080
19081 $this->done();
19082 }
19083
19084 function done() {
19085 echo '<div class="narrow">';
19086 echo '<p><h3>'.__('Import Complete!').'</h3></p>';
19087 echo '</div>';
19088 }
19089
19090 function JeromesKeyword_Import() {
19091 }
19092
19093 }
19094
19095 // create the import object
19096 $jkw_import = new JeromesKeyword_Import();
19097
19098 // add it to the import page!
19099 register_importer('jkw', 'Jerome’s Keywords', __('Import Jerome’s Keywords into WordPress tags.'), array($jkw_import, 'dispatch'));
19100
19101 ?>