Changeset 3418466
- Timestamp:
- 12/12/2025 06:03:16 PM (2 months ago)
- Location:
- blogger-importer-extended/trunk
- Files:
-
- 4 edited
-
bootstrap.php (modified) (10 diffs)
-
redirects.php (modified) (3 diffs)
-
settings.php (modified) (2 diffs)
-
uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
blogger-importer-extended/trunk/bootstrap.php
r3341752 r3418466 3 3 Plugin Name: Blogger Importer Extended 4 4 Plugin URI: https://wordpress.org/plugins/blogger-importer-extended/ 5 Description: The only plugin you need to move from Blogger to WordPress. Import all yourcontent and setup 301 redirects automatically.5 Description: The only plugin you need to move from Blogger to WordPress. Import all content and setup 301 redirects automatically. 6 6 Author: pipdig 7 7 Version: 3.2.7 … … 34 34 define('BIE_PATH', plugin_dir_url(__FILE__)); 35 35 36 // Wait time between import batches36 // Wait time between import batches 37 37 if (!defined('BIE_WAIT_TIME')) { 38 38 define('BIE_WAIT_TIME', 1500); 39 } 40 41 // Import the first 15 images from post content to avoid timeout 42 if (!defined('BIE_IMAGE_IMPORT_LIMIT')) { 43 define('BIE_IMAGE_IMPORT_LIMIT', 15); 39 44 } 40 45 … … 499 504 $.post(ajaxurl, data, function(response) { 500 505 501 //console.log(response);506 console.log(response); 502 507 503 508 if (!checkIsJsonString(response)) { … … 798 803 foreach ($response->items as $item) { 799 804 800 $exists = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT post_id FROM '.$wpdb->prefix.'bie_redirects WHERE blogger_post_id = %s', $item->id) );805 $exists = (int) $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM {$wpdb->prefix}bie_redirects WHERE blogger_post_id = %s LIMIT 1", $item->id) ); 801 806 802 807 if ($exists !== 0) { … … 900 905 foreach ($response->items as $item) { 901 906 902 $exists = (int) $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_value = %s AND meta_key = 'blogger_post_id'", $item->id) );907 $exists = (int) $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = %s AND meta_key = 'blogger_post_id' LIMIT 1", $item->id) ); 903 908 904 909 if ($exists !== 0) { … … 1043 1048 1044 1049 $query_args['page_query'] = $response->nextPageToken; // request next page, keep other args 1045 1050 1046 1051 $response = pipdig_blogger_get_response($query_args); 1047 1052 … … 1145 1150 } 1146 1151 1152 $images = array_unique($images); // remove dupes 1153 1147 1154 if (!empty($images)) { 1148 1155 1149 $x = 0; 1150 1151 foreach ($images as $found_image) { 1152 1153 // skip if returns 404 1154 $headers = get_headers($found_image, 1); 1155 if (isset($headers[0]) && strpos($headers[0], '404') !== false) { 1156 continue; 1156 foreach ($images as $i => $found_image) { 1157 1158 if ($i >= BIE_IMAGE_IMPORT_LIMIT) { 1159 break; 1157 1160 } 1158 1161 1159 1162 $found_image_original = $found_image; // keep original for later, we need it for str_replace in content 1160 1163 1161 /*1162 preg_match('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $found_image, $matches);1163 1164 if (empty($matches[0])) {1165 continue;1166 }1167 */1168 1169 // check mime1170 $file_size = getimagesize($found_image);1171 1172 $lets_go = false;1173 1174 if (!empty($file_size['mime'])) {1175 1176 $mime = strtolower($file_size['mime']);1177 1178 $allowed_types = ['jpg', 'jpeg', 'jpe', 'png', 'gif', 'webp'];1179 1180 foreach ($allowed_types as $allowed_type) {1181 1182 if (strpos($mime, $allowed_type) !== false) {1183 $file_ext = '.'.$allowed_type;1184 $lets_go = true;1185 break;1186 }1187 1188 }1189 1190 }1191 1192 if (!$lets_go) {1193 continue;1194 }1195 1196 1164 // urldecode twice to better rename imported Chinese characters. See support ticket #47809 for more info 1197 $name = urldecode(urldecode(wp_basename($found_image))); 1198 1199 // Are Chinese characters in $name? 1200 if (preg_match("/\p{Han}+/u", $name)) { 1201 1202 // Chinese chars found, so urldecode twice for better filename 1203 $found_image = urldecode(urldecode($found_image)); // needed to overcome long filenames. 1204 1205 } else { 1206 // No Chinese characters found, so revert back to standard filename. 1207 // TODO - This might not be necessary if it is safe to double urldecode any filenames. Needs more testing to confirm. 1208 $name = wp_basename($found_image); 1209 } 1165 $name = wp_basename(urldecode(urldecode($found_image))); 1166 $found_image = urldecode(urldecode($found_image)); 1210 1167 1211 1168 if (empty($name)) { 1212 1169 continue; 1213 1170 } 1171 1172 $tmp = download_url($found_image); 1173 if (is_wp_error($tmp)) { 1174 continue; 1175 } 1176 1177 $info = getimagesize($tmp); 1178 if (!$info || empty($info['mime'])) { 1179 @unlink($tmp); 1180 continue; 1181 } 1182 1183 $ext_map = [ 1184 'image/jpeg' => '.jpg', 1185 'image/png' => '.png', 1186 'image/gif' => '.gif', 1187 'image/webp' => '.webp', 1188 ]; 1189 1190 $file_ext = isset($ext_map[$info['mime']]) ? $ext_map[$info['mime']] : '.jpg'; 1214 1191 1215 1192 // Some filesystems can't handle long filenames. So fallback to post slug. … … 1230 1207 $file = array( 1231 1208 'name' => $name, 1232 'tmp_name' => download_url($found_image),1209 'tmp_name' => $tmp, 1233 1210 ); 1234 1211 1235 if (is_wp_error($file['tmp_name'])) { 1236 @unlink($file['tmp_name']); 1237 continue; 1238 } 1239 1240 // remove extension if it's ther. E.g. rtim .jpeg first, then re-add it after. Needed in case there isn't an extension already set 1241 $filename = rtrim($file['name'], $file_ext).$file_ext; 1212 // remove extension if it's there. E.g. rtim .jpeg first, then re-add it after. Needed in case there isn't an extension already set 1213 $filename = pathinfo($file['name'], PATHINFO_FILENAME).$file_ext; 1242 1214 1243 1215 $image_id = media_handle_sideload($file, $post_id, $filename, array('post_date' => $post_date, 'post_author' => $author_id)); … … 1260 1232 1261 1233 // if this is the first image, include it in the return as the featured_image_id 1262 if ($ x=== 0) {1234 if ($i === 0) { 1263 1235 1264 1236 $featured_image_id = $image_id; … … 1271 1243 } 1272 1244 1273 $x++;1274 1275 1245 } 1276 1246 -
blogger-importer-extended/trunk/redirects.php
r3018368 r3418466 98 98 99 99 } 100 100 101 101 if (!$redirect) { 102 102 if (isset($options['redirect_404s']) && $options['redirect_404s']) { … … 195 195 jQuery(document).ready(function($) { 196 196 197 varhrefBlogger301Redirect = $('tr[data-slug="blogger-301-redirect"] .deactivate a').attr('href');197 let hrefBlogger301Redirect = $('tr[data-slug="blogger-301-redirect"] .deactivate a').attr('href'); 198 198 if (hrefBlogger301Redirect) { 199 199 $('#showDeactivateBlogger301RedirectText').show(); … … 201 201 $('#deactivateBlogger301RedirectPlugin').attr('href', hrefBlogger301Redirect); 202 202 203 varhrefBloggerToWordPress = $('tr[data-slug="blogger-to-wordpress-redirection"] .deactivate a').attr('href');203 let hrefBloggerToWordPress = $('tr[data-slug="blogger-to-wordpress-redirection"] .deactivate a').attr('href'); 204 204 if (hrefBloggerToWordPress) { 205 205 $('#showDeactivateBloggerToWordPressText').show(); 206 206 } 207 207 $('#deactivateBloggerToWordPress').attr('href', hrefBloggerToWordPress); 208 208 209 }); 209 210 </script> -
blogger-importer-extended/trunk/settings.php
r3147993 r3418466 31 31 #bieNoticeOk { 32 32 display: block !important; 33 /* max-width: 691px; */34 33 } 35 34 .card { … … 350 349 351 350 die; 351 352 352 }); -
blogger-importer-extended/trunk/uninstall.php
r2566267 r3418466 10 10 11 11 global $wpdb; 12 $results = $wpdb->get_results("SELECT option_name FROM $wpdb->optionsWHERE option_name LIKE 'bie_page_token_%'");12 $results = $wpdb->get_results("SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE 'bie_page_token_%'"); 13 13 foreach ($results as $result) { 14 14 delete_option($result->option_name); … … 16 16 17 17 /* 18 // Do we want to delete the redirects on uninstall? 19 // Todo - add option to settings page 18 // Do we want to delete the redirects on uninstall? Maybe not 20 19 global $wpdb; 21 20 $table_name = $wpdb->prefix.'bie_redirects';
Note: See TracChangeset
for help on using the changeset viewer.