Changeset 3427414
- Timestamp:
- 12/25/2025 05:42:43 PM (8 weeks ago)
- Location:
- blogger-importer-extended/trunk
- Files:
-
- 2 edited
-
bootstrap.php (modified) (19 diffs)
-
uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
blogger-importer-extended/trunk/bootstrap.php
r3418466 r3427414 39 39 } 40 40 41 // Import the first 15 images from post contentto avoid timeout41 // Import the first x images to avoid timeout 42 42 if (!defined('BIE_IMAGE_IMPORT_LIMIT')) { 43 43 define('BIE_IMAGE_IMPORT_LIMIT', 15); … … 61 61 // Plugin page links 62 62 add_filter('plugin_action_links_'.plugin_basename(__FILE__), function($links) { 63 $links[] = '<a href="'. admin_url('options-general.php?page=bie-settings').'">'.__('Run Importer').'</a>';64 $links[] = '<a href="'. admin_url('options-general.php?page=bie-settings#redirectsCard').'">301 Redirects</a>';63 $links[] = '<a href="'.esc_url(admin_url('options-general.php?page=bie-settings')).'">'.__('Run Importer').'</a>'; 64 $links[] = '<a href="'.esc_url(admin_url('options-general.php?page=bie-settings#redirectsCard')).'">301 Redirects</a>'; 65 65 return $links; 66 66 }); … … 72 72 bie_create_database_tables(); 73 73 74 if (!get_option('bie_installed_date')) {75 add_option('bie_installed_date', date('Y-m-d'));76 }77 78 74 update_option('default_pingback_flag', ''); 79 75 update_option('default_ping_status', 'closed'); 76 77 // Now we create mu-plugin which ensures all other plugins are disabled when importing content from Blogger (only impacts requests to AJAX from the BIE plugin) 78 79 // Not on multisite 80 if (is_multisite()) { 81 return; 82 } 83 84 $mu_dir = WP_CONTENT_DIR.'/mu-plugins'; 85 $mu_file = $mu_dir.'/blogger-importer-extended-helper.php'; 86 87 if (!is_dir($mu_dir)) { 88 wp_mkdir_p($mu_dir); 89 } 90 91 if (!is_dir($mu_dir) || !is_writable($mu_dir) || file_exists($mu_file)) { 92 return; 93 } 94 95 $code = <<<'PHP' 96 <?php 97 /** 98 * Plugin Name: Blogger Importer Extended - Helper 99 * Description: Create as stable environment for importing content from Blogger. This mu-plugin is only used by the Blogger Importer Extended plugin and is removed when deactivated. If you are not longer using that plugin, you can delete this file. 100 */ 101 102 if (!defined('DOING_AJAX') || !DOING_AJAX) { 103 return; 104 } 105 106 if (empty($_REQUEST['action']) || $_REQUEST['action'] !== 'bie_progress_ajax') { 107 return; 108 } 109 110 add_filter('option_active_plugins', function($plugins) { 111 112 $allowed = array( 113 'blogger-importer-extended/bootstrap.php', 114 ); 115 116 return array_values(array_intersect($plugins, $allowed)); 117 118 }); 119 PHP; 120 121 @file_put_contents($mu_file, $code); 80 122 81 123 }); … … 92 134 delete_option($result->option_name); 93 135 } 136 137 if (is_multisite()) { 138 return; 139 } 140 141 $mu_file = WP_CONTENT_DIR.'/mu-plugins/blogger-importer-extended-helper.php'; 142 143 if (!file_exists($mu_file) || !is_writable($mu_file)) { 144 return; 145 } 146 147 // Delete the mu-plugin created on activation 148 @unlink($mu_file); 94 149 95 150 }); … … 149 204 <div class="notice notice-success"> 150 205 <h2>Blogger Importer</h2> 151 <p>Thank you for installing Blogger Importer Extended! Please go to <a href="<?php echo admin_url('options-general.php?page=bie-settings'); ?>">this page</a> to get started.</p>206 <p>Thank you for installing Blogger Importer Extended! Please go to <a href="<?php echo esc_url(admin_url('options-general.php?page=bie-settings')); ?>">this page</a> to get started.</p> 152 207 <form action="" method="post"> 153 208 <input type="hidden" value="1" name="bie_hide_setup_notice" /> 154 209 <?php wp_nonce_field('sec', 'bie_hide_setup_notice_nonce'); ?> 155 210 <p class="submit" style="margin-top: 5px; padding-top: 5px;"> 156 <a href="<?php echo admin_url('options-general.php?page=bie-settings'); ?>" class="button button-primary" style="margin-right: 5px;">Get Started</a> <input name="submit" class="button" value="Remove this notice" type="submit" />211 <a href="<?php echo esc_url(admin_url('options-general.php?page=bie-settings')); ?>" class="button button-primary" style="margin-right: 5px;">Get Started</a> <input name="submit" class="button" value="Remove this notice" type="submit" /> 157 212 </p> 158 213 </form> … … 243 298 jQuery(document).ready(function($) { 244 299 245 $('#wpwrap').before('<div id="pipdigBloggerImporter"><a id="pipdigBloggerClose" href="<?php echo admin_url('options-general.php?page=bie-settings'); ?>" title="Return to dashboard"><span class="dashicons dashicons-no-alt"></span></a><div id="pipdigBloggerImporterContent"><img src="<?php echo BIE_PATH; ?>img/boxes.svg" alt="" class="fade_out" style="width:150px" /><h2 class="fade_out">Welcome to the Blogger Importer!</h2><div id="bieLicenseChoices"><p>The free version of this plugin can import up to 20 blog posts and pages.</p><p>Alternatively you can purchase an <a href="https://go.pipdig.co/open.php?id=bie-pro" target="_blank" rel="noopener">unlimited license</a> for unlimited posts, pages, comments and images.</p><p>Read more about the differences <a href="https://go.pipdig.co/open.php?id=bie-pro" target="_blank" rel="noopener">here</a>.</p><div style="margin-top:20px"><div class="button" id="bieFreeBtn">20 posts for free</div> <div class="button button-primary" id="bieProBtn">Unlimited license</div></div></div><div id="blogLicenseStep" class="fade_out" style="display:none"><p class="fade_out" style="margin-bottom: 20px;">What is your license key? License keys an be purchased <a href="https://go.pipdig.co/open.php?id=bie-pro" target="_blank" rel="noopener">here</a>.</p><input type="text" value="" class="wide-fat fade_out" style="width:320px;max-width:100%;" id="bieLicenseField"> <input type="button" value="<?php echo esc_attr(__('Submit')); ?>" class="button button-primary fade_out" id="bieLicenseSubmit"><div id="bieCheckingLicense" style="display: none; margin-top: 10px;"><span class="dashicons dashicons-update spin"></span> Checking License...</div><div id="bieCheckingLicenseResult" style="margin-top: 10px;"></div></div><div id="blogIdStep" class="fade_out" style="display:none"><p><span id="bieLicenseSuccessMsg"></span>Please enter your Blog\'s ID in the option below. You can find your Blog ID like <a href="<?php echo BIE_PATH; ?>img/find_blog_id.png" target="_blank" rel="noopener">this example</a>.</p><p style="margin-bottom: 20px;"><span class="dashicons dashicons-warning"></span> Please note that Blogger settings must be <a href="<?php echo BIE_PATH; ?>img/blogger_public.png" target="_blank" rel="noopener">Public</a> during the import.</p><input type="text" value="" class="wide-fat fade_out" style="width:320px;max-width:100%;" id="BlogggerBlogIdField" placeholder="Blog ID should be a number"> <input type="button" value="<?php echo esc_attr(__('Submit')); ?>" class="button button-primary fade_out" id="submitBlogId"></div><div id="pipdigBloggerImpoterMsg1"></div><p id="postImportProgress"></p></div></div><div id="totalPostCount" style="display:none"></div><div id="lastUpdateCountdown" style="display:none"></div>');300 $('#wpwrap').before('<div id="pipdigBloggerImporter"><a id="pipdigBloggerClose" href="<?php echo esc_url(admin_url('options-general.php?page=bie-settings')); ?>" title="Return to dashboard"><span class="dashicons dashicons-no-alt"></span></a><div id="pipdigBloggerImporterContent"><img src="<?php echo BIE_PATH; ?>img/boxes.svg" alt="" class="fade_out" style="width:150px" /><h2 class="fade_out">Welcome to the Blogger Importer!</h2><div id="bieLicenseChoices"><p>The free version of this plugin can import up to 20 blog posts and pages.</p><p>Alternatively you can purchase an <a href="https://go.pipdig.co/open.php?id=bie-pro" target="_blank" rel="noopener">unlimited license</a> for unlimited posts, pages, comments and images.</p><p>Read more about the differences <a href="https://go.pipdig.co/open.php?id=bie-pro" target="_blank" rel="noopener">here</a>.</p><div style="margin-top:20px"><div class="button" id="bieFreeBtn">20 posts for free</div> <div class="button button-primary" id="bieProBtn">Unlimited license</div></div></div><div id="blogLicenseStep" class="fade_out" style="display:none"><p class="fade_out" style="margin-bottom: 20px;">What is your license key? License keys an be purchased <a href="https://go.pipdig.co/open.php?id=bie-pro" target="_blank" rel="noopener">here</a>.</p><input type="text" value="" class="wide-fat fade_out" style="width:320px;max-width:100%;" id="bieLicenseField"> <input type="button" value="<?php echo esc_attr(__('Submit')); ?>" class="button button-primary fade_out" id="bieLicenseSubmit"><div id="bieCheckingLicense" style="display: none; margin-top: 10px;"><span class="dashicons dashicons-update spin"></span> Checking License...</div><div id="bieCheckingLicenseResult" style="margin-top: 10px;"></div></div><div id="blogIdStep" class="fade_out" style="display:none"><p><span id="bieLicenseSuccessMsg"></span>Please enter your Blog\'s ID in the option below. You can find your Blog ID like <a href="<?php echo BIE_PATH; ?>img/find_blog_id.png" target="_blank" rel="noopener">this example</a>.</p><p style="margin-bottom: 20px;"><span class="dashicons dashicons-warning"></span> Please note that Blogger settings must be <a href="<?php echo BIE_PATH; ?>img/blogger_public.png" target="_blank" rel="noopener">Public</a> during the import.</p><input type="text" value="" class="wide-fat fade_out" style="width:320px;max-width:100%;" id="BlogggerBlogIdField" placeholder="Blog ID should be a number"> <input type="button" value="<?php echo esc_attr(__('Submit')); ?>" class="button button-primary fade_out" id="submitBlogId"></div><div id="pipdigBloggerImpoterMsg1"></div><p id="postImportProgress"></p></div></div><div id="totalPostCount" style="display:none"></div><div id="lastUpdateCountdown" style="display:none"></div>'); 246 301 247 302 var bieLicenseField = $('#bieLicenseField'); … … 317 372 $('#bieCheckingLicenseResult').html('This license has expired. Would you like to <a href="https://go.pipdig.co/open.php?id=bie-pro" target="_blank" rel="noopener">purchase a new one</a>?'); 318 373 } else if (response == 3) { 319 $('#bieCheckingLicenseResult').html('This license does not exist. Please check your email receipt for the license key or <a href="<?php echo admin_url('tools.php?page=bie-importer'); ?>">click here</a> to restart the import process.');374 $('#bieCheckingLicenseResult').html('This license does not exist. Please check your email receipt for the license key or <a href="<?php echo esc_url(admin_url('tools.php?page=bie-importer')); ?>">click here</a> to restart the import process.'); 320 375 } else { 321 376 … … 453 508 $('.fade_out').addClass('pipdig_hide'); 454 509 importPostsBtn.addClass('pipdig_hide'); 455 message.html('<img src="<?php echo BIE_PATH; ?>img/moving.svg" alt="" style="width: 150px;" /><h2><span class="dashicons dashicons-update spin"></span> Importing, Please wait...</h2><p>Please <strong>keep this window open</strong>.</p><p>'+importingTimeNotice+'</p><div style="margin-top: 25px"><a href="<?php echo admin_url('tools.php?page=bie-importer'); ?>&bid='+BlogggerBlogIdField.val()+'" class="button fade_out" id="stopImport"><span class="dashicons dashicons-no" style="margin-top: 4px;"></span> Stop the import!</a></div>');510 message.html('<img src="<?php echo BIE_PATH; ?>img/moving.svg" alt="" style="width: 150px;" /><h2><span class="dashicons dashicons-update spin"></span> Importing, Please wait...</h2><p>Please <strong>keep this window open</strong>.</p><p>'+importingTimeNotice+'</p><div style="margin-top: 25px"><a href="<?php echo esc_url(admin_url('tools.php?page=bie-importer')); ?>&bid='+BlogggerBlogIdField.val()+'" class="button fade_out" id="stopImport"><span class="dashicons dashicons-no" style="margin-top: 4px;"></span> Stop the import!</a></div>'); 456 511 457 512 importPosts('', 0, skipComments, skipImages, skipPages, skipAuthors, convertFormatting); … … 509 564 console.log(response); 510 565 if (response.includes("https://go.pipdig.co/open.php?id=2")) { 511 message.html('<img src="<?php echo BIE_PATH; ?>img/battery_low.svg" alt="" style="width: 150px;" />'+response+'<p style="margin-top: 20px"><a class="button" href="<?php echo admin_url('options-general.php?page=bie-settings'); ?>">Return to dashboard</a></p>');566 message.html('<img src="<?php echo BIE_PATH; ?>img/battery_low.svg" alt="" style="width: 150px;" />'+response+'<p style="margin-top: 20px"><a class="button" href="<?php echo esc_url(admin_url('options-general.php?page=bie-settings')); ?>">Return to dashboard</a></p>'); 512 567 } else { 513 message.html('<img src="<?php echo BIE_PATH; ?>img/broken.svg" alt="" style="width: 150px;" /><h2>Connection lost</h2><p>It looks like the importer has stopped working. Don\'t worry though, any progress was not lost! Click the button below to continue.</p><p>Are you seeing this message a lot? <a href="https://support.pipdig.co/articles/blogger-importer-extended-faq/" target="_blank" rel="noopener">Click here</a> for some tips for easier migrations.</p><p style="margin-top: 20px"><a class="button-primary" href="<?php echo admin_url('tools.php?page=bie-importer'); ?>&bid='+BlogggerBlogIdField.val()+'">Continue Importer</a></p>');568 message.html('<img src="<?php echo BIE_PATH; ?>img/broken.svg" alt="" style="width: 150px;" /><h2>Connection lost</h2><p>It looks like the importer has stopped working. Don\'t worry though, any progress was not lost! Click the button below to continue.</p><p>Are you seeing this message a lot? <a href="https://support.pipdig.co/articles/blogger-importer-extended-faq/" target="_blank" rel="noopener">Click here</a> for some tips for easier migrations.</p><p style="margin-top: 20px"><a class="button-primary" href="<?php echo esc_url(admin_url('tools.php?page=bie-importer')); ?>&bid='+BlogggerBlogIdField.val()+'">Continue Importer</a></p>'); 514 569 } 515 570 window.onbeforeunload = null; // Remove navigation prompt … … 530 585 $('#lastUpdateCountdown').text('180'); 531 586 532 /*533 if (resp.latest_imported_id != '' && resp.latest_imported_title != '' && resp.total_posts != 0) {534 $('#postImportProgress').html('<h2>Status Update:</h2>There are now <strong>'+resp.total_posts+'</strong> <a href="<?php echo admin_url('edit.php'); ?>" target="_blank" rel="noopener">blog posts</a> in WordPress.<br /><br />Last item imported:<br /><br /><a href="<?php echo trailingslashit(admin_url()); ?>post.php?post=' + resp.latest_imported_id + '&action=edit" target="_blank" rel="noopener" style="text-decoration:none">' + resp.latest_imported_title + '</a>');535 }536 */537 538 587 if (typeof resp.total_posts !== 'undefined' && resp.total_posts != 0) { 539 588 var time = new Date(); 540 589 var currentTime = time.toLocaleString('en-US', {hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true}); 541 $('#postImportProgress').html('<h2>Status Update:</h2><span style="font-style:italic">'+currentTime+': There are <strong>'+resp.total_posts+'</strong> <a href="<?php echo admin_url('edit.php'); ?>" target="_blank" rel="noopener">blog posts</a> in WordPress.</span>');590 $('#postImportProgress').html('<h2>Status Update:</h2><span style="font-style:italic">'+currentTime+': There are <strong>'+resp.total_posts+'</strong> <a href="<?php echo esc_url(admin_url('edit.php')); ?>" target="_blank" rel="noopener">blog posts</a> in WordPress.</span>'); 542 591 } 543 592 … … 553 602 $('#lastUpdateCountdown').text(''); 554 603 $('#postImportProgress').text(''); 555 message.html('<img src="<?php echo BIE_PATH; ?>img/success.svg" alt="" style="width: 150px;" /><h2>Success!</h2><p>All content was imported successfully.</p><p>What now? Don\'t forget to setup the <a href="<?php echo admin_url('options-general.php?page=bie-settings'); ?>">remaining steps</a>.</p><p style="margin-top: 20px"><a class="button" href="<?php echo admin_url('options-general.php?page=bie-settings'); ?>">Return to dashboard</a></p>');604 message.html('<img src="<?php echo BIE_PATH; ?>img/success.svg" alt="" style="width: 150px;" /><h2>Success!</h2><p>All content was imported successfully.</p><p>What now? Don\'t forget to setup the <a href="<?php echo esc_url(admin_url('options-general.php?page=bie-settings')); ?>">remaining steps</a>.</p><p style="margin-top: 20px"><a class="button" href="<?php echo esc_url(admin_url('options-general.php?page=bie-settings')); ?>">Return to dashboard</a></p>'); 556 605 $('.fade_out').slideUp(550); 557 606 … … 579 628 if (counter === 0) { 580 629 window.onbeforeunload = null; // Remove navigation prompt 581 message.html('<img src="<?php echo BIE_PATH; ?>img/broken.svg" alt="" style="width: 150px;" /><h2>Connection lost</h2><p>It looks like the importer has stopped unexpectedly. Don\'t worry though, any progress was not lost! Click the button below to continue the current import.</p><p>Are you seeing this message a lot? <a href="https://support.pipdig.co/articles/blogger-importer-extended-faq/" target="_blank" rel="noopener">Click here</a> for some tips for easier migrations.</p><p style="margin-top: 20px"><a class="button-primary" href="<?php echo admin_url('tools.php?page=bie-importer'); ?>&bid='+BlogggerBlogIdField.val()+'">Continue Importer</a></p>');630 message.html('<img src="<?php echo BIE_PATH; ?>img/broken.svg" alt="" style="width: 150px;" /><h2>Connection lost</h2><p>It looks like the importer has stopped unexpectedly. Don\'t worry though, any progress was not lost! Click the button below to continue the current import.</p><p>Are you seeing this message a lot? <a href="https://support.pipdig.co/articles/blogger-importer-extended-faq/" target="_blank" rel="noopener">Click here</a> for some tips for easier migrations.</p><p style="margin-top: 20px"><a class="button-primary" href="<?php echo esc_url(admin_url('tools.php?page=bie-importer')); ?>&bid='+BlogggerBlogIdField.val()+'">Continue Importer</a></p>'); 582 631 $('#lastUpdateCountdown').text(''); 583 632 return; … … 727 776 } else { 728 777 // no previous import found 729 echo '<div class="button button-primary fade_out" id="startImport" style="margin-top: 10px" data-total-posts="'.absint($response->posts).'"><span class="dashicons dashicons-controls-play" style="margin-top: 4px;"></span> Start import!</div> <a href="'. admin_url('tools.php?page=bie-importer').'" class="button fade_out" style="margin-top: 10px">Cancel</a>';778 echo '<div class="button button-primary fade_out" id="startImport" style="margin-top: 10px" data-total-posts="'.absint($response->posts).'"><span class="dashicons dashicons-controls-play" style="margin-top: 4px;"></span> Start import!</div> <a href="'.esc_url(admin_url('tools.php?page=bie-importer')).'" class="button fade_out" style="margin-top: 10px">Cancel</a>'; 730 779 } 731 780 … … 794 843 wp_defer_term_counting(true); 795 844 wp_defer_comment_counting(true); 796 remove_action('post_updated', 'wp_save_post_revision');797 add_filter(' intermediate_image_sizes_advanced', 'pipdig_blogger_skip_image_sizes'); // disable image sizes from generating, temporarily whilst uploading845 add_filter('intermediate_image_sizes_advanced', '__return_empty_array'); 846 add_filter('big_image_size_threshold', '__return_false'); 798 847 799 848 if (!defined('WP_IMPORTING')) define('WP_IMPORTING', true); … … 869 918 ); 870 919 $wpdb->insert($wpdb->prefix.'bie_redirects', $row, $formats); 871 872 /*873 $title = get_the_title($post_id);874 $latest_imported_title = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); // convert chars like & https://stackoverflow.com/a/6684000875 $latest_imported_id = $post_id;876 */877 920 878 921 } else { … … 963 1006 964 1007 wp_suspend_cache_invalidation(false); 965 wp_defer_term_counting(false);966 wp_defer_comment_counting(false);967 add_action('post_updated', 'wp_save_post_revision');968 remove_filter('intermediate_image_sizes_advanced', 'pipdig_blogger_skip_image_sizes'); // return image sizes to normal after969 1008 970 1009 $total_posts = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = 'post'"); … … 973 1012 'next_page' => $next_page_token, 974 1013 'posts_imported' => $x, 975 //'latest_imported_title' => !empty($latest_imported_title) ? strip_tags($latest_imported_title) : '',976 //'latest_imported_id' => !empty($latest_imported_id) ? strip_tags($latest_imported_id) : '',977 1014 'total_posts' => $total_posts, 978 1015 ); … … 1108 1145 } 1109 1146 1110 }1111 1112 function pipdig_blogger_skip_image_sizes($sizes) {1113 return array();1114 1147 } 1115 1148 … … 1251 1284 } 1252 1285 1253 // Add lazy load and srcset if supported1254 /*1255 if (function_exists('wp_filter_content_tags')) {1256 $content = wp_filter_content_tags($content);1257 }1258 */1259 1260 1286 return array( 1261 1287 'content' => $content, -
blogger-importer-extended/trunk/uninstall.php
r3418466 r3427414 8 8 delete_option('bie_license'); 9 9 delete_option('bie_hide_setup_notice'); 10 delete_option('bie_installed_date'); 10 11 11 12 global $wpdb; … … 14 15 delete_option($result->option_name); 15 16 } 16 17 /*18 // Do we want to delete the redirects on uninstall? Maybe not19 global $wpdb;20 $table_name = $wpdb->prefix.'bie_redirects';21 $wpdb->query("DROP TABLE IF EXISTS $table_name");22 */
Note: See TracChangeset
for help on using the changeset viewer.