All in One SEO Pack - Version 2.4.1

Version Description

Download this release

Release Info

Developer hallsofmontezuma
Plugin Icon 128x128 All in One SEO Pack
Version 2.4.1
Comparing to
See all releases

Code changes from version 2.4 to 2.4.1

all_in_one_seo_pack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: All In One SEO Pack
4
  Plugin URI: https://semperplugins.com/all-in-one-seo-pack-pro-version/
5
  Description: Out-of-the-box SEO for your WordPress blog. Features like XML Sitemaps, SEO for custom post types, SEO for blogs or business sites, SEO for ecommerce sites, and much more. More than 30 million downloads since 2007.
6
- Version: 2.4
7
  Author: Michael Torbert
8
  Author URI: https://semperplugins.com/all-in-one-seo-pack-pro-version/
9
  Text Domain: all-in-one-seo-pack
@@ -31,14 +31,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
31
  * The original WordPress SEO plugin.
32
  *
33
  * @package All-in-One-SEO-Pack
34
- * @version 2.4
35
  */
36
 
37
  if ( ! defined( 'AIOSEOPPRO' ) ) {
38
  define( 'AIOSEOPPRO', false );
39
  }
40
  if ( ! defined( 'AIOSEOP_VERSION' ) ) {
41
- define( 'AIOSEOP_VERSION', '2.4' );
42
  }
43
  global $aioseop_plugin_name;
44
  $aioseop_plugin_name = 'All in One SEO Pack';
@@ -464,6 +464,7 @@ if ( is_admin() ) {
464
  add_action( 'wp_ajax_aioseo_dismiss_yst_notice', 'aioseop_update_yst_detected_notice' );
465
  add_action( 'wp_ajax_aioseo_dismiss_visibility_notice', 'aioseop_update_user_visibilitynotice' );
466
  add_action( 'wp_ajax_aioseo_dismiss_woo_upgrade_notice', 'aioseop_woo_upgrade_notice_dismissed' );
 
467
  if ( AIOSEOPPRO ) {
468
  add_action( 'wp_ajax_aioseop_ajax_update_oembed', 'aioseop_ajax_update_oembed' );
469
  }
3
  Plugin Name: All In One SEO Pack
4
  Plugin URI: https://semperplugins.com/all-in-one-seo-pack-pro-version/
5
  Description: Out-of-the-box SEO for your WordPress blog. Features like XML Sitemaps, SEO for custom post types, SEO for blogs or business sites, SEO for ecommerce sites, and much more. More than 30 million downloads since 2007.
6
+ Version: 2.4.1
7
  Author: Michael Torbert
8
  Author URI: https://semperplugins.com/all-in-one-seo-pack-pro-version/
9
  Text Domain: all-in-one-seo-pack
31
  * The original WordPress SEO plugin.
32
  *
33
  * @package All-in-One-SEO-Pack
34
+ * @version 2.4.1
35
  */
36
 
37
  if ( ! defined( 'AIOSEOPPRO' ) ) {
38
  define( 'AIOSEOPPRO', false );
39
  }
40
  if ( ! defined( 'AIOSEOP_VERSION' ) ) {
41
+ define( 'AIOSEOP_VERSION', '2.4.1' );
42
  }
43
  global $aioseop_plugin_name;
44
  $aioseop_plugin_name = 'All in One SEO Pack';
464
  add_action( 'wp_ajax_aioseo_dismiss_yst_notice', 'aioseop_update_yst_detected_notice' );
465
  add_action( 'wp_ajax_aioseo_dismiss_visibility_notice', 'aioseop_update_user_visibilitynotice' );
466
  add_action( 'wp_ajax_aioseo_dismiss_woo_upgrade_notice', 'aioseop_woo_upgrade_notice_dismissed' );
467
+ add_action( 'wp_ajax_aioseo_dismiss_sitemap_max_url_notice', 'aioseop_sitemap_max_url_notice_dismissed' );
468
  if ( AIOSEOPPRO ) {
469
  add_action( 'wp_ajax_aioseop_ajax_update_oembed', 'aioseop_ajax_update_oembed' );
470
  }
inc/aioseop_functions.php CHANGED
@@ -958,6 +958,11 @@ function aioseop_woo_upgrade_notice_dismissed() {
958
  update_user_meta( get_current_user_id(), 'aioseop_woo_upgrade_notice_dismissed', true );
959
  }
960
 
 
 
 
 
 
961
  /**
962
  * Returns home_url() value compatible for any use.
963
  * Thought for compatibility purposes.
958
  update_user_meta( get_current_user_id(), 'aioseop_woo_upgrade_notice_dismissed', true );
959
  }
960
 
961
+ function aioseop_sitemap_max_url_notice_dismissed() {
962
+
963
+ update_user_meta( get_current_user_id(), 'aioseop_sitemap_max_url_notice_dismissed', true );
964
+ }
965
+
966
  /**
967
  * Returns home_url() value compatible for any use.
968
  * Thought for compatibility purposes.
js/quickedit_functions.js CHANGED
@@ -31,6 +31,17 @@ jQuery(document).on( 'click', '.woo-upgrade-notice', function() {
31
 
32
  })
33
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  function aioseop_ajax_edit_meta_form( post_id, meta, nonce ) {
36
  var uform = jQuery('#aioseop_'+meta+'_' + post_id);
@@ -63,7 +74,7 @@ function handle_post_meta( p, t, m, n ) {
63
  loading += '</label><div style="float:left">Please wait…</div>';
64
  jQuery("div#aioseop_"+m+"_"+p).fadeIn('fast', function() {
65
  var aioseop_sack = new sack(aioseopadmin.requestUrl);
66
- aioseop_sack.execute = 1;
67
  aioseop_sack.method = 'POST';
68
  aioseop_sack.setVar( "action", "aioseop_ajax_save_meta");
69
  aioseop_sack.setVar( "post_id", p );
@@ -76,6 +87,6 @@ function handle_post_meta( p, t, m, n ) {
76
  })
77
  jQuery("div#aioseop_"+m+"_"+p).html(loading);
78
  jQuery("div#aioseop_"+m+"_"+p).attr( "class", "aioseop_mpc_admin_meta_options" );
79
-
80
  })
81
- }
31
 
32
  })
33
 
34
+ jQuery(document).on( 'click', '.sitemap_max_urls_notice', function() {
35
+
36
+ jQuery.ajax({
37
+ url: ajaxurl,
38
+ data: {
39
+ action: 'aioseo_dismiss_sitemap_max_url_notice'
40
+ }
41
+ })
42
+
43
+ })
44
+
45
 
46
  function aioseop_ajax_edit_meta_form( post_id, meta, nonce ) {
47
  var uform = jQuery('#aioseop_'+meta+'_' + post_id);
74
  loading += '</label><div style="float:left">Please wait…</div>';
75
  jQuery("div#aioseop_"+m+"_"+p).fadeIn('fast', function() {
76
  var aioseop_sack = new sack(aioseopadmin.requestUrl);
77
+ aioseop_sack.execute = 1;
78
  aioseop_sack.method = 'POST';
79
  aioseop_sack.setVar( "action", "aioseop_ajax_save_meta");
80
  aioseop_sack.setVar( "post_id", p );
87
  })
88
  jQuery("div#aioseop_"+m+"_"+p).html(loading);
89
  jQuery("div#aioseop_"+m+"_"+p).attr( "class", "aioseop_mpc_admin_meta_options" );
90
+
91
  })
92
+ }
modules/aioseop_sitemap.php CHANGED
@@ -20,7 +20,6 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
20
  var $comment_string;
21
  var $start_memory_usage = 0;
22
  var $max_posts = 50000;
23
- var $paginate = false;
24
  var $prio;
25
  var $prio_sel;
26
  var $freq;
@@ -28,6 +27,18 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
28
  var $extra_sitemaps;
29
  var $excludes = array();
30
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  /**
32
  * All_in_One_SEO_Pack_Sitemap constructor.
33
  */
@@ -46,7 +57,6 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
46
  'filename' => __( "Specifies the name of your sitemap file. This will default to 'sitemap'.", 'all-in-one-seo-pack' ),
47
  'daily_cron' => __( 'Notify search engines based on the selected schedule, and also update static sitemap daily if in use. (this uses WP-Cron, so make sure this is working properly on your server as well)', 'all-in-one-seo-pack' ),
48
  'indexes' => __( 'Organize sitemap entries into distinct files in your sitemap. Enable this only if your sitemap contains over 50,000 URLs or the file is over 5MB in size.', 'all-in-one-seo-pack' ),
49
- 'paginate' => __( 'Split long sitemaps into separate files.', 'all-in-one-seo-pack' ),
50
  'max_posts' => __( 'Allows you to specify the maximum number of posts in a sitemap (up to 50,000).', 'all-in-one-seo-pack' ),
51
  'posttypes' => __( 'Select which Post Types appear in your sitemap.', 'all-in-one-seo-pack' ),
52
  'taxonomies' => __( 'Select which taxonomy archives appear in your sitemap', 'all-in-one-seo-pack' ),
@@ -67,7 +77,6 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
67
  'filename' => '#filename-prefix',
68
  'daily_cron' => '#schedule-updates',
69
  'indexes' => '#enable-sitemap-indexes',
70
- 'paginate' => '#enable-sitemap-indexes',
71
  'max_posts' => '#enable-sitemap-indexes',
72
  'posttypes' => '#post-types-and-taxonomies',
73
  'taxonomies' => '#post-types-and-taxonomies',
@@ -103,15 +112,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
103
  'default' => 0,
104
  ),
105
  'indexes' => array( 'name' => __( 'Enable Sitemap Indexes', 'all-in-one-seo-pack' ) ),
106
- 'paginate' => array(
107
- 'name' => __( 'Paginate Sitemap Indexes', 'all-in-one-seo-pack' ),
108
- 'condshow' => array( "{$this->prefix}indexes" => 'on' ),
109
- ),
110
  'max_posts' => array(
111
- 'name' => __( 'Maximum Posts Per Sitemap', 'all-in-one-seo-pack' ),
112
  'type' => 'text',
113
  'default' => 50000,
114
- 'condshow' => array( "{$this->prefix}indexes" => 'on', "{$this->prefix}paginate" => 'on' ),
115
  ),
116
  'posttypes' => array(
117
  'name' => __( 'Post Types', 'all-in-one-seo-pack' ),
@@ -311,8 +316,53 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
311
  add_action( 'init', array( $this, 'make_dynamic_xsl' ) );
312
  add_action( 'transition_post_status', array( $this, 'update_sitemap_from_posts' ), 10, 3 );
313
  add_action( 'after_doing_aioseop_updates', array( $this, 'scan_sitemaps' ) );
 
314
  }
315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
 
317
  /**
318
  * Update sitemap from posts.
@@ -398,8 +448,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
398
  function load_sitemap_options() {
399
  // Load initial options / set defaults.
400
  $this->update_options();
401
- if ( ! empty( $this->options["{$this->prefix}indexes"] ) && ! empty( $this->options["{$this->prefix}paginate"] ) ) {
402
- $this->paginate = true;
403
  if ( $this->options["{$this->prefix}max_posts"] && ( $this->options["{$this->prefix}max_posts"] > 0 ) && ( $this->options["{$this->prefix}max_posts"] < 50000 ) ) {
404
  $this->max_posts = $this->options["{$this->prefix}max_posts"];
405
  }
@@ -1121,7 +1170,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1121
  */
1122
  function query_var_hook( $vars ) {
1123
  $vars[] = "{$this->prefix}path";
1124
- if ( $this->paginate ) {
1125
  $vars[] = "{$this->prefix}page";
1126
  }
1127
 
@@ -1348,15 +1397,13 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1348
  * @param string $message
1349
  */
1350
  function do_sitemaps( $message = '' ) {
1351
- if ( ! empty( $this->options["{$this->prefix}indexes"] ) && ! empty( $this->options["{$this->prefix}paginate"] ) ) {
1352
- $this->paginate = true;
1353
  if ( $this->options["{$this->prefix}max_posts"] && ( $this->options["{$this->prefix}max_posts"] > 0 ) && ( $this->options["{$this->prefix}max_posts"] < 50000 ) ) {
1354
  $this->max_posts = $this->options["{$this->prefix}max_posts"];
1355
  } else {
1356
  $this->max_posts = 50000;
1357
  }
1358
  } else {
1359
- $this->paginate = false;
1360
  $this->max_posts = 50000;
1361
  }
1362
  if ( ! $this->options["{$this->prefix}rewrite"] ) {
@@ -1570,7 +1617,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1570
  if ( 0 == $post_counts[ $sm ] ) {
1571
  continue;
1572
  }
1573
- if ( $this->paginate ) {
1574
  if ( $post_counts[ $sm ] > $this->max_posts ) {
1575
  $count = 1;
1576
  for ( $post_count = 0; $post_count < $post_counts[ $sm ]; $post_count += $this->max_posts ) {
@@ -1615,7 +1662,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1615
  foreach ( $options["{$this->prefix}taxonomies"] as $sm ) {
1616
  $term_count = wp_count_terms( $sm, array( 'hide_empty' => true ) );
1617
  if ( ! is_wp_error( $term_count ) && ( $term_count > 0 ) ) {
1618
- if ( $this->paginate ) {
1619
  if ( $term_count > $this->max_posts ) {
1620
  $count = 1;
1621
  for ( $tc = 0; $tc < $term_count; $tc += $this->max_posts ) {
@@ -1741,7 +1788,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1741
  if ( 0 === $post_counts[ $posttype ] ) {
1742
  continue;
1743
  }
1744
- if ( $this->paginate && ( $post_counts[ $posttype ] > $this->max_posts ) ) {
1745
  $count = 1;
1746
  for ( $post_count = 0; $post_count < $post_counts[ $posttype ]; $post_count += $this->max_posts ) {
1747
  $this->do_write_sitemap( $posttype, $count - 1, $options["{$this->prefix}filename"] . "_{$posttype}_{$count}" );
@@ -1757,7 +1804,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1757
  foreach ( $options["{$this->prefix}taxonomies"] as $taxonomy ) {
1758
  $term_count = wp_count_terms( $taxonomy, array( 'hide_empty' => true ) );
1759
  if ( ! is_wp_error( $term_count ) && ( $term_count > 0 ) ) {
1760
- if ( $this->paginate ) {
1761
  if ( $term_count > $this->max_posts ) {
1762
  $count = 1;
1763
  for ( $tc = 0; $tc < $term_count; $tc += $this->max_posts ) {
@@ -1828,7 +1875,6 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1828
  'image:image' => $this->get_images_from_post( (int) get_option( 'page_on_front' ) ),
1829
  );
1830
 
1831
- $this->paginate = false;
1832
  if ( $posts ) {
1833
  $posts = $this->get_permalink( $posts );
1834
  if ( $posts == $home['loc'] ) {
@@ -2624,7 +2670,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
2624
 
2625
  return $prio;
2626
  }
2627
-
2628
  /**
2629
  * Return the images attached to the term.
2630
  *
@@ -2635,11 +2681,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
2635
  * @return array
2636
  */
2637
  private function get_images_from_term( $term ) {
2638
-
2639
  if ( false === apply_filters( 'aioseo_include_images_in_sitemap', true ) ) {
2640
  return array();
2641
  }
2642
-
2643
  $images = array();
2644
  $thumbnail_id = get_term_meta( $term->term_id, 'thumbnail_id', true );
2645
  if ( $thumbnail_id ) {
@@ -2699,8 +2745,19 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
2699
  $images[] = $attached_url;
2700
  }
2701
 
2702
- // Check images in the content.
2703
  $content = $post->post_content;
 
 
 
 
 
 
 
 
 
 
 
2704
  $total = substr_count( $content, '<img ' ) + substr_count( $content, '<IMG ' );
2705
  if ( $total > 0 ) {
2706
  $dom = new domDocument();
@@ -2717,12 +2774,16 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
2717
  }
2718
  }
2719
 
 
 
2720
  if ( $images ) {
2721
  $tmp = $images;
2722
  if ( 1 < count( $images ) ) {
2723
  // Filter out duplicates.
2724
  $tmp = array_unique( $images );
2725
  }
 
 
2726
  $images = array();
2727
  foreach ( $tmp as $image ) {
2728
  $images[] = array(
@@ -2734,6 +2795,71 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
2734
  return $images;
2735
  }
2736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2737
  /**
2738
  * Return excluded categories for taxonomy queries.
2739
  *
@@ -2746,7 +2872,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
2746
  if ( $this->option_isset( 'excl_categories' ) ) {
2747
  $args['exclude'] = $this->options[ $this->prefix . 'excl_categories' ];
2748
  }
2749
- if ( $this->paginate ) {
2750
  $args['number'] = $this->max_posts;
2751
  $args['offset'] = $page * $this->max_posts;
2752
 
@@ -2814,7 +2940,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
2814
  */
2815
  function get_all_post_priority_data( $include = 'any', $status = 'publish', $page = 0 ) {
2816
  $posts = $page_query = array();
2817
- if ( $this->paginate ) {
2818
  $page_query = array( 'offset' => $page * $this->max_posts );
2819
  }
2820
  if ( ( 'publish' === $status ) && ( 'attachment' === $include ) ) {
20
  var $comment_string;
21
  var $start_memory_usage = 0;
22
  var $max_posts = 50000;
 
23
  var $prio;
24
  var $prio_sel;
25
  var $freq;
27
  var $extra_sitemaps;
28
  var $excludes = array();
29
 
30
+ /**
31
+ * The allowed image extensions.
32
+ *
33
+ * @var array $image_extensions The allowed image extensions.
34
+ */
35
+ private static $image_extensions = array(
36
+ 'jpg',
37
+ 'jpeg',
38
+ 'png',
39
+ 'gif',
40
+ );
41
+
42
  /**
43
  * All_in_One_SEO_Pack_Sitemap constructor.
44
  */
57
  'filename' => __( "Specifies the name of your sitemap file. This will default to 'sitemap'.", 'all-in-one-seo-pack' ),
58
  'daily_cron' => __( 'Notify search engines based on the selected schedule, and also update static sitemap daily if in use. (this uses WP-Cron, so make sure this is working properly on your server as well)', 'all-in-one-seo-pack' ),
59
  'indexes' => __( 'Organize sitemap entries into distinct files in your sitemap. Enable this only if your sitemap contains over 50,000 URLs or the file is over 5MB in size.', 'all-in-one-seo-pack' ),
 
60
  'max_posts' => __( 'Allows you to specify the maximum number of posts in a sitemap (up to 50,000).', 'all-in-one-seo-pack' ),
61
  'posttypes' => __( 'Select which Post Types appear in your sitemap.', 'all-in-one-seo-pack' ),
62
  'taxonomies' => __( 'Select which taxonomy archives appear in your sitemap', 'all-in-one-seo-pack' ),
77
  'filename' => '#filename-prefix',
78
  'daily_cron' => '#schedule-updates',
79
  'indexes' => '#enable-sitemap-indexes',
 
80
  'max_posts' => '#enable-sitemap-indexes',
81
  'posttypes' => '#post-types-and-taxonomies',
82
  'taxonomies' => '#post-types-and-taxonomies',
112
  'default' => 0,
113
  ),
114
  'indexes' => array( 'name' => __( 'Enable Sitemap Indexes', 'all-in-one-seo-pack' ) ),
 
 
 
 
115
  'max_posts' => array(
116
+ 'name' => __( 'Maximum Posts Per Sitemap Page', 'all-in-one-seo-pack' ),
117
  'type' => 'text',
118
  'default' => 50000,
119
+ 'condshow' => array( "{$this->prefix}indexes" => 'on', "{$this->prefix}indexes" => 'on' ),
120
  ),
121
  'posttypes' => array(
122
  'name' => __( 'Post Types', 'all-in-one-seo-pack' ),
316
  add_action( 'init', array( $this, 'make_dynamic_xsl' ) );
317
  add_action( 'transition_post_status', array( $this, 'update_sitemap_from_posts' ), 10, 3 );
318
  add_action( 'after_doing_aioseop_updates', array( $this, 'scan_sitemaps' ) );
319
+ add_action( 'all_admin_notices', array( $this, 'sitemap_notices' ) );
320
  }
321
 
322
+ /**
323
+ * Sitemap notices.
324
+ *
325
+ * @since 2.4.1
326
+ */
327
+ function sitemap_notices() {
328
+
329
+ $sitemap_max_url_notice_dismissed = get_user_meta( get_current_user_id(), 'aioseop_sitemap_max_url_notice_dismissed', true );
330
+ if ( ! empty( $sitemap_max_url_notice_dismissed ) ) {
331
+ return;
332
+ }
333
+
334
+ global $options;
335
+ $options = $this->options;
336
+
337
+ if ( isset( $options["{$this->prefix}indexes"] ) && 'on ' !== $options["{$this->prefix}indexes"] &&
338
+ 1001 < $options["{$this->prefix}max_posts"] ) {
339
+
340
+ $post_counts = $this->get_total_post_count( array(
341
+ 'post_type' => $options["{$this->prefix}posttypes"],
342
+ 'post_status' => 'publish',
343
+ ) );
344
+
345
+ $num_terms = array_sum( $this->get_all_term_counts( array( 'taxonomy' => $options["{$this->prefix}taxonomies"] ) ) );
346
+
347
+ $sitemap_urls = $post_counts + $num_terms;
348
+
349
+ if ( 1001 > $sitemap_urls ) {
350
+ return;
351
+ }
352
+
353
+ $aioseop_plugin_dirname = AIOSEOP_PLUGIN_DIRNAME;
354
+
355
+ printf( '
356
+ <div id="message" class="notice-warning notice is-dismissible aioseop-notice sitemap_max_urls_notice visibility-notice">
357
+ <p>
358
+ <strong>%1$s</strong><br />
359
+ %2$s
360
+ </p>
361
+ </div>',
362
+ __( 'Notice: To avoid problems with your XML Sitemap, we strongly recommend you enable Sitemap Indexes and set the Maximum Posts per Sitemap Page to 1000.', 'all-in-one-seo-pack' ),
363
+ sprintf( __( '%s Click here%s to make these recommended changes.', 'all-in-one-seo-pack' ), sprintf( '<a href="%s">', esc_url( get_admin_url( null, "admin.php?page=$aioseop_plugin_dirname/modules/aioseop_sitemap.php" ) ) ), '</a>' ) );
364
+ }
365
+ }
366
 
367
  /**
368
  * Update sitemap from posts.
448
  function load_sitemap_options() {
449
  // Load initial options / set defaults.
450
  $this->update_options();
451
+ if ( ! empty( $this->options["{$this->prefix}indexes"] ) ) {
 
452
  if ( $this->options["{$this->prefix}max_posts"] && ( $this->options["{$this->prefix}max_posts"] > 0 ) && ( $this->options["{$this->prefix}max_posts"] < 50000 ) ) {
453
  $this->max_posts = $this->options["{$this->prefix}max_posts"];
454
  }
1170
  */
1171
  function query_var_hook( $vars ) {
1172
  $vars[] = "{$this->prefix}path";
1173
+ if ( ! empty( $this->options["{$this->prefix}indexes"] ) ) {
1174
  $vars[] = "{$this->prefix}page";
1175
  }
1176
 
1397
  * @param string $message
1398
  */
1399
  function do_sitemaps( $message = '' ) {
1400
+ if ( ! empty( $this->options["{$this->prefix}indexes"] ) ) {
 
1401
  if ( $this->options["{$this->prefix}max_posts"] && ( $this->options["{$this->prefix}max_posts"] > 0 ) && ( $this->options["{$this->prefix}max_posts"] < 50000 ) ) {
1402
  $this->max_posts = $this->options["{$this->prefix}max_posts"];
1403
  } else {
1404
  $this->max_posts = 50000;
1405
  }
1406
  } else {
 
1407
  $this->max_posts = 50000;
1408
  }
1409
  if ( ! $this->options["{$this->prefix}rewrite"] ) {
1617
  if ( 0 == $post_counts[ $sm ] ) {
1618
  continue;
1619
  }
1620
+ if ( ! empty( $this->options["{$this->prefix}indexes"] ) ) {
1621
  if ( $post_counts[ $sm ] > $this->max_posts ) {
1622
  $count = 1;
1623
  for ( $post_count = 0; $post_count < $post_counts[ $sm ]; $post_count += $this->max_posts ) {
1662
  foreach ( $options["{$this->prefix}taxonomies"] as $sm ) {
1663
  $term_count = wp_count_terms( $sm, array( 'hide_empty' => true ) );
1664
  if ( ! is_wp_error( $term_count ) && ( $term_count > 0 ) ) {
1665
+ if ( ! empty( $this->options["{$this->prefix}indexes"] ) ) {
1666
  if ( $term_count > $this->max_posts ) {
1667
  $count = 1;
1668
  for ( $tc = 0; $tc < $term_count; $tc += $this->max_posts ) {
1788
  if ( 0 === $post_counts[ $posttype ] ) {
1789
  continue;
1790
  }
1791
+ if ( ! empty( $this->options["{$this->prefix}indexes"] ) && ( $post_counts[ $posttype ] > $this->max_posts ) ) {
1792
  $count = 1;
1793
  for ( $post_count = 0; $post_count < $post_counts[ $posttype ]; $post_count += $this->max_posts ) {
1794
  $this->do_write_sitemap( $posttype, $count - 1, $options["{$this->prefix}filename"] . "_{$posttype}_{$count}" );
1804
  foreach ( $options["{$this->prefix}taxonomies"] as $taxonomy ) {
1805
  $term_count = wp_count_terms( $taxonomy, array( 'hide_empty' => true ) );
1806
  if ( ! is_wp_error( $term_count ) && ( $term_count > 0 ) ) {
1807
+ if ( ! empty( $this->options["{$this->prefix}indexes"] ) ) {
1808
  if ( $term_count > $this->max_posts ) {
1809
  $count = 1;
1810
  for ( $tc = 0; $tc < $term_count; $tc += $this->max_posts ) {
1875
  'image:image' => $this->get_images_from_post( (int) get_option( 'page_on_front' ) ),
1876
  );
1877
 
 
1878
  if ( $posts ) {
1879
  $posts = $this->get_permalink( $posts );
1880
  if ( $posts == $home['loc'] ) {
2670
 
2671
  return $prio;
2672
  }
2673
+
2674
  /**
2675
  * Return the images attached to the term.
2676
  *
2681
  * @return array
2682
  */
2683
  private function get_images_from_term( $term ) {
2684
+
2685
  if ( false === apply_filters( 'aioseo_include_images_in_sitemap', true ) ) {
2686
  return array();
2687
  }
2688
+
2689
  $images = array();
2690
  $thumbnail_id = get_term_meta( $term->term_id, 'thumbnail_id', true );
2691
  if ( $thumbnail_id ) {
2745
  $images[] = $attached_url;
2746
  }
2747
 
2748
+ $content = '';
2749
  $content = $post->post_content;
2750
+
2751
+ // Check images galleries in the content. DO NOT run the_content filter here as it might cause issues with other shortcodes.
2752
+ if ( has_shortcode( $content, 'gallery' ) ) {
2753
+ $galleries = get_post_galleries( $post, false );
2754
+ if ( $galleries ) {
2755
+ foreach ( $galleries as $gallery ) {
2756
+ $images = array_merge( $images, $gallery['src'] );
2757
+ }
2758
+ }
2759
+ }
2760
+
2761
  $total = substr_count( $content, '<img ' ) + substr_count( $content, '<IMG ' );
2762
  if ( $total > 0 ) {
2763
  $dom = new domDocument();
2774
  }
2775
  }
2776
 
2777
+ $this->parse_content_for_images( $content, $images );
2778
+
2779
  if ( $images ) {
2780
  $tmp = $images;
2781
  if ( 1 < count( $images ) ) {
2782
  // Filter out duplicates.
2783
  $tmp = array_unique( $images );
2784
  }
2785
+ // remove any invalid/empty images.
2786
+ $tmp = array_filter( $images, array( $this, 'is_image_valid' ) );
2787
  $images = array();
2788
  foreach ( $tmp as $image ) {
2789
  $images[] = array(
2795
  return $images;
2796
  }
2797
 
2798
+
2799
+ /**
2800
+ * Validate the image.
2801
+ *
2802
+ * @param string $image The image src.
2803
+ *
2804
+ * @since 2.4.1
2805
+ *
2806
+ * @return bool
2807
+ */
2808
+ function is_image_valid( $image ) {
2809
+ // Bail if empty image.
2810
+ if ( empty( $image ) ) {
2811
+ return false;
2812
+ }
2813
+
2814
+ $extn = pathinfo( wp_parse_url( $image, PHP_URL_PATH ), PATHINFO_EXTENSION );
2815
+ $allowed = apply_filters( 'aioseop_allowed_image_extensions', self::$image_extensions );
2816
+ // Bail if image does not refer to an image file otherwise google webmaster tools might reject the sitemap.
2817
+ if ( ! in_array( $extn, $allowed, true ) ) {
2818
+ return false;
2819
+ }
2820
+
2821
+ return true;
2822
+ }
2823
+
2824
+ /**
2825
+ * Parse the post for images.
2826
+ *
2827
+ * @param string $content the post content.
2828
+ * @param array $images the array of images.
2829
+ */
2830
+ function parse_content_for_images( $content, &$images ) {
2831
+ $total = substr_count( $content, '<img ' ) + substr_count( $content, '<IMG ' );
2832
+ // no images found.
2833
+ if ( 0 === $total ) {
2834
+ return;
2835
+ }
2836
+
2837
+ if ( class_exists( 'DOMDocument' ) ) {
2838
+ $dom = new domDocument();
2839
+ // Non-compliant HTML might give errors, so ignore them.
2840
+ libxml_use_internal_errors( true );
2841
+ $dom->loadHTML( $content );
2842
+ libxml_clear_errors();
2843
+ $dom->preserveWhiteSpace = false;
2844
+ $matches = $dom->getElementsByTagName( 'img' );
2845
+ foreach ( $matches as $match ) {
2846
+ $images[] = $match->getAttribute( 'src' );
2847
+ }
2848
+ } else {
2849
+ // Fall back to regex, but also report an error.
2850
+ global $img_err_msg;
2851
+ if ( ! isset( $img_err_msg ) ) {
2852
+ // we will log this error message only once, not per post.
2853
+ $img_err_msg = true;
2854
+ $this->debug_message( 'DOMDocument not found; using REGEX' );
2855
+ }
2856
+ preg_match_all( '/<img.*src=([\'"])?(.*?)\\1/', $content, $matches );
2857
+ if ( $matches && isset( $matches[2] ) ) {
2858
+ $images = array_merge( $images, $matches[2] );
2859
+ }
2860
+ }
2861
+ }
2862
+
2863
  /**
2864
  * Return excluded categories for taxonomy queries.
2865
  *
2872
  if ( $this->option_isset( 'excl_categories' ) ) {
2873
  $args['exclude'] = $this->options[ $this->prefix . 'excl_categories' ];
2874
  }
2875
+ if ( ! empty( $this->options["{$this->prefix}indexes"] ) ) {
2876
  $args['number'] = $this->max_posts;
2877
  $args['offset'] = $page * $this->max_posts;
2878
 
2940
  */
2941
  function get_all_post_priority_data( $include = 'any', $status = 'publish', $page = 0 ) {
2942
  $posts = $page_query = array();
2943
+ if ( ! empty( $this->options["{$this->prefix}indexes"] ) ) {
2944
  $page_query = array( 'offset' => $page * $this->max_posts );
2945
  }
2946
  if ( ( 'publish' === $status ) && ( 'attachment' === $include ) ) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtor
4
  Tags: seo, all in one seo, google, twitter, page, image seo, social, search engine optimization, sitemap, WordPress SEO, meta, meta description, xml sitemap, google sitemap, sitemaps, robots meta, yahoo, bing, news sitemaps, multisite, canonical, nofollow, noindex, keywords, description, webmaster tools, google webmaster tools, google analytics
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
- Stable tag: 2.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
4
  Tags: seo, all in one seo, google, twitter, page, image seo, social, search engine optimization, sitemap, WordPress SEO, meta, meta description, xml sitemap, google sitemap, sitemaps, robots meta, yahoo, bing, news sitemaps, multisite, canonical, nofollow, noindex, keywords, description, webmaster tools, google webmaster tools, google analytics
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
+ Stable tag: 2.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10