Google Sitemap by BestWebSoft - Version 3.2.0

Version Description

  • 08.08.2019 =
  • Bugfix : The bug with recording a large number of posts in the sitemap file has been fixed.
Download this release

Release Info

Developer bestwebsoft
Plugin Icon 128x128 Google Sitemap by BestWebSoft
Version 3.2.0
Comparing to
See all releases

Code changes from version 3.1.9 to 3.2.0

google-sitemap-plugin.php CHANGED
@@ -6,7 +6,7 @@ Description: Generate and add XML sitemap to WordPress website. Help search engi
6
  Author: BestWebSoft
7
  Text Domain: google-sitemap-plugin
8
  Domain Path: /languages
9
- Version: 3.1.9
10
  Author URI: https://bestwebsoft.com/
11
  License: GPLv2 or later
12
  */
@@ -416,107 +416,133 @@ if ( ! function_exists( 'gglstmp_prepare_sitemap' ) ) {
416
  $excluded_posts_string = "AND p.`ID` NOT IN (" . implode( ",", $excluded_posts ) . ")";
417
  }
418
 
419
- $posts = $wpdb->get_results(
420
- "SELECT
421
- `ID`,
422
- `post_author`,
423
- `post_status`,
424
- `post_name`,
425
- `post_parent`,
426
- `post_type`,
427
- `post_date`,
428
- `post_date_gmt`,
429
- `post_modified`,
430
- `post_modified_gmt`,
431
- GROUP_CONCAT(t.`term_id`) as term_id
432
- FROM `{$wpdb->posts}` p
433
- LEFT JOIN {$wpdb->term_relationships} tr
434
- ON p.`ID` = tr.`object_id`
435
- LEFT JOIN {$wpdb->term_taxonomy} tt
436
- ON tt.`term_taxonomy_id` = tr.`term_taxonomy_id`
437
- LEFT JOIN {$wpdb->terms} t
438
- ON t.`term_id` = tt.`term_id`
439
- WHERE
440
- {$post_status_string}
441
- {$post_types_string}
442
- {$excluded_posts_string}
443
- GROUP BY `ID`
444
- ORDER BY `post_date_gmt` DESC;"
445
- );
446
-
447
- if ( ! empty( $posts ) ) {
448
- foreach ( $posts as $post ) {
449
- $priority = 0.8;
450
- if ( $show_on_front && $frontpage_id == $post->ID ) {
451
- $priority = 1.0;
452
- $frontpage_is_added = true;
453
- }
454
-
455
- if ( $gglstmp_options['media_sitemap'] ) {
456
-
457
- /* Prepear video_list and image_list data for sitemap */
458
- $video_list = get_attached_media( 'video', $post );
459
- $image_list = get_attached_media( 'image', $post );
460
-
461
- /* Add image to list */
462
- $image_item = [];
463
-
464
- if ( ! empty( $image_list ) ) {
465
- $image_count = 0;
466
- foreach ( $image_list as $image ) {
467
- $image_count ++;
468
- if ( $image_count > 1000 ) {
469
- break;
470
- }
471
- $attachment_metadata = wp_get_attachment_metadata( $image->ID );
472
-
473
- $explode_metadata = explode( '/', $attachment_metadata['file'] );
474
- array_pop( $explode_metadata );
475
- $image_upload_date = implode( ' ', $explode_metadata );
476
-
477
- $image_guid = basename( $image->guid );
478
- $check_img_exists = gglstmp_if_file_exists( $image_guid, $image_upload_date );
479
- if ( $check_img_exists ) {
480
- $image_item[] = array( 'guid' => $image->guid, 'image_title' => $image->post_title );
481
- }
482
- }
483
- /* Add array image_elements of one post */
484
- $image_elements[] = array(
485
- 'url' => get_permalink( $post ),
486
- 'image_list' => $image_item
487
- );
488
- }
489
- /* Add video to list */
490
- $video_item = [];
491
- if ( ! empty( $video_list ) ) {
492
- $video_count = 0;
493
- foreach ( $video_list as $video ) {
494
- $video_count ++;
495
- if ( $video_count > 1000 ) {
496
- break;
497
- }
498
- $video_info[] = $video->guid;
499
- $video_info[] = $video->post_title;
500
- $video_item[] = $video_info;
501
- }
502
- /* Add array video_elements of one post */
503
- $video_elements[] = array(
504
- 'url' => get_permalink( $post ),
505
- 'video_list_url' => $video_item
506
- );
507
- }
508
- }
509
-
510
- /* Data for default sitemap */
511
- $elements[] = array(
512
- 'url' => get_permalink( $post ),
513
- 'date' => date( 'Y-m-d\TH:i:sP', strtotime( $post->post_modified ) ),
514
- 'frequency' => 'monthly',
515
- 'priority' => $priority
516
- );
517
-
518
- }
519
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
520
  }
521
 
522
  if ( ! $frontpage_is_added ) {
6
  Author: BestWebSoft
7
  Text Domain: google-sitemap-plugin
8
  Domain Path: /languages
9
+ Version: 3.2.0
10
  Author URI: https://bestwebsoft.com/
11
  License: GPLv2 or later
12
  */
416
  $excluded_posts_string = "AND p.`ID` NOT IN (" . implode( ",", $excluded_posts ) . ")";
417
  }
418
 
419
+ // get the number of posts for sitemap
420
+ $count_posts = $wpdb->query( "
421
+ SELECT COUNT( * )
422
+ FROM `{$wpdb->posts}` p
423
+ LEFT JOIN {$wpdb->term_relationships} tr
424
+ ON p.`ID` = tr.`object_id`
425
+ LEFT JOIN {$wpdb->term_taxonomy} tt
426
+ ON tt.`term_taxonomy_id` = tr.`term_taxonomy_id`
427
+ LEFT JOIN {$wpdb->terms} t
428
+ ON t.`term_id` = tt.`term_id`
429
+ WHERE
430
+ {$post_status_string}
431
+ {$post_types_string}
432
+ {$excluded_posts_string}
433
+ GROUP BY `ID`
434
+ " );
435
+
436
+ // count the number of iterations needed
437
+ $counter = ( int ) ceil( $count_posts / 5000 );
438
+
439
+ // loop to limit 5000 posts for iteration
440
+ for (
441
+ $i = 0, $offset = 0, $limit = 5000;
442
+ $i < $counter;
443
+ $i++, $offset += 5000
444
+ ) {
445
+ $posts = $wpdb->get_results(
446
+ "SELECT
447
+ `ID`,
448
+ `post_author`,
449
+ `post_status`,
450
+ `post_name`,
451
+ `post_parent`,
452
+ `post_type`,
453
+ `post_date`,
454
+ `post_date_gmt`,
455
+ `post_modified`,
456
+ `post_modified_gmt`,
457
+ GROUP_CONCAT(t.`term_id`) as term_id
458
+ FROM `{$wpdb->posts}` p
459
+ LEFT JOIN {$wpdb->term_relationships} tr
460
+ ON p.`ID` = tr.`object_id`
461
+ LEFT JOIN {$wpdb->term_taxonomy} tt
462
+ ON tt.`term_taxonomy_id` = tr.`term_taxonomy_id`
463
+ LEFT JOIN {$wpdb->terms} t
464
+ ON t.`term_id` = tt.`term_id`
465
+ WHERE
466
+ {$post_status_string}
467
+ {$post_types_string}
468
+ {$excluded_posts_string}
469
+ GROUP BY `ID`
470
+ ORDER BY `post_date_gmt` DESC LIMIT {$offset}, {$limit};"
471
+ );
472
+
473
+ if ( ! empty( $posts ) ) {
474
+ foreach ( $posts as $post ) {
475
+ $priority = 0.8;
476
+ if ( $show_on_front && $frontpage_id == $post->ID ) {
477
+ $priority = 1.0;
478
+ $frontpage_is_added = true;
479
+ }
480
+
481
+ if ( $gglstmp_options['media_sitemap'] ) {
482
+
483
+ /* Prepear video_list and image_list data for sitemap */
484
+ $video_list = get_attached_media( 'video', $post );
485
+ $image_list = get_attached_media( 'image', $post );
486
+
487
+ /* Add image to list */
488
+ $image_item = [];
489
+
490
+ if ( ! empty( $image_list ) ) {
491
+ $image_count = 0;
492
+ foreach ( $image_list as $image ) {
493
+ $image_count ++;
494
+ if ( $image_count > 1000 ) {
495
+ break;
496
+ }
497
+ $attachment_metadata = wp_get_attachment_metadata( $image->ID );
498
+
499
+ $explode_metadata = explode( '/', $attachment_metadata['file'] );
500
+ array_pop( $explode_metadata );
501
+ $image_upload_date = implode( ' ', $explode_metadata );
502
+
503
+ $image_guid = basename( $image->guid );
504
+ $check_img_exists = gglstmp_if_file_exists( $image_guid, $image_upload_date );
505
+ if ( $check_img_exists ) {
506
+ $image_item[] = array( 'guid' => $image->guid, 'image_title' => $image->post_title );
507
+ }
508
+ }
509
+ /* Add array image_elements of one post */
510
+ $image_elements[] = array(
511
+ 'url' => get_permalink( $post ),
512
+ 'image_list' => $image_item
513
+ );
514
+ }
515
+ /* Add video to list */
516
+ $video_item = [];
517
+ if ( ! empty( $video_list ) ) {
518
+ $video_count = 0;
519
+ foreach ( $video_list as $video ) {
520
+ $video_count ++;
521
+ if ( $video_count > 1000 ) {
522
+ break;
523
+ }
524
+ $video_info[] = $video->guid;
525
+ $video_info[] = $video->post_title;
526
+ $video_item[] = $video_info;
527
+ }
528
+ /* Add array video_elements of one post */
529
+ $video_elements[] = array(
530
+ 'url' => get_permalink( $post ),
531
+ 'video_list_url' => $video_item
532
+ );
533
+ }
534
+ }
535
+
536
+ /* Data for default sitemap */
537
+ $elements[] = array(
538
+ 'url' => get_permalink( $post ),
539
+ 'date' => date( 'Y-m-d\TH:i:sP', strtotime( $post->post_modified ) ),
540
+ 'frequency' => 'monthly',
541
+ 'priority' => $priority
542
+ );
543
+ }
544
+ }
545
+ }
546
  }
547
 
548
  if ( ! $frontpage_is_added ) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://bestwebsoft.com/donate/
4
  Tags: add pages to sitemap, add posts to sitemap, add sitemap, google, google sitemap, google sitemap plugin, sitemap file path, update sitemap, google webmaster tools, site map, sitemaps, webmaster tools
5
  Requires at least: 3.9
6
  Tested up to: 5.2.2
7
- Stable tag: 3.1.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -55,7 +55,7 @@ https://www.youtube.com/watch?v=CgYXKRXpj_0
55
  > * Your website content changes for all pages
56
  > * External sitemap file update
57
  > * Configure all subsites on the network
58
- > * Add custom URLs to the sitemap file [NEW]
59
  > * Get answer to your support question within one business day ([Support Policy](https://bestwebsoft.com/support-policy/))
60
  >
61
  > [Upgrade to Pro Now](https://bestwebsoft.com/products/wordpress/plugins/google-sitemap/?k=8b735c0f7ca51187b5062d5e4f40058b)
@@ -149,7 +149,10 @@ Please make sure that the problem hasn't been discussed yet on our forum (<https
149
 
150
  == Changelog ==
151
 
152
- = V3.1.9 - 1.07.2019 =
 
 
 
153
  * Bugfix : The bug the possibility of using image title in the image_sitemap.xml file has been fixed.
154
 
155
  = V3.1.8 - 02.05.2019 =
@@ -362,6 +365,9 @@ Please make sure that the problem hasn't been discussed yet on our forum (<https
362
 
363
  == Upgrade Notice ==
364
 
 
 
 
365
  = V3.1.9 =
366
  * Bugs fixed.
367
 
4
  Tags: add pages to sitemap, add posts to sitemap, add sitemap, google, google sitemap, google sitemap plugin, sitemap file path, update sitemap, google webmaster tools, site map, sitemaps, webmaster tools
5
  Requires at least: 3.9
6
  Tested up to: 5.2.2
7
+ Stable tag: 3.2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
55
  > * Your website content changes for all pages
56
  > * External sitemap file update
57
  > * Configure all subsites on the network
58
+ > * Add custom URLs to the sitemap file
59
  > * Get answer to your support question within one business day ([Support Policy](https://bestwebsoft.com/support-policy/))
60
  >
61
  > [Upgrade to Pro Now](https://bestwebsoft.com/products/wordpress/plugins/google-sitemap/?k=8b735c0f7ca51187b5062d5e4f40058b)
149
 
150
  == Changelog ==
151
 
152
+ = V3.2.0 - 08.08.2019 =
153
+ * Bugfix : The bug with recording a large number of posts in the sitemap file has been fixed.
154
+
155
+ = V3.1.9 - 01.07.2019 =
156
  * Bugfix : The bug the possibility of using image title in the image_sitemap.xml file has been fixed.
157
 
158
  = V3.1.8 - 02.05.2019 =
365
 
366
  == Upgrade Notice ==
367
 
368
+ = V3.2.0 =
369
+ * Bugs fixed.
370
+
371
  = V3.1.9 =
372
  * Bugs fixed.
373
 
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file