All in One SEO Pack - Version 2.1.7

Version Description

Download this release

Release Info

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

Code changes from version 2.1.5.1 to 2.1.7

aioseop_class.php CHANGED
@@ -173,6 +173,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
173
  "ga_use_universal_analytics" => __( "Use the new Universal Analytics tracking code for Google Analytics; do this for new analytics accounts.", 'all_in_one_seo_pack' ),
174
  "ga_domain" => __( "Enter your domain name if you have enabled tracking of Subdomains in Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
175
  "ga_multi_domain" => __( "Check this if you have enabled tracking of Multiple top-level domains in Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
 
176
  "ga_display_advertising"=> __( "Support for Doubleclick Display Advertising tracking.", 'all_in_one_seo_pack' ),
177
  "ga_exclude_users" => __( "Exclude logged-in users from Google Analytics tracking by role.", 'all_in_one_seo_pack' ),
178
  "ga_track_outbound_links"=> __( "Check this if you want to track outbound links with Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
@@ -183,8 +184,11 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
183
  "archive_author_noindex"=> __( "Check this to ask search engines not to index Author Archives. Useful for avoiding duplicate content.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
184
  "tags_noindex" => __( "Check this to ask search engines not to index Tag Archives. Useful for avoiding duplicate content.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
185
  "search_noindex" => __( "Check this to ask search engines not to index the Search page. Useful for avoiding duplicate content.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
 
 
186
  "generate_descriptions" => __( "Check this and your Meta Descriptions will be auto-generated from your excerpt or content.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
187
  "hide_paginated_descriptions"=> __( "Check this and your Meta Descriptions will be removed from page 2 or later of paginated content.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
 
188
  "unprotect_meta" => __( "Check this to unprotect internal postmeta fields for use with XMLRPC. If you don't know what that is, leave it unchecked.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
189
  "ex_pages" => __( "Enter a comma separated list of pages here to be excluded by All in One SEO Pack. This is helpful when using plugins which generate their own non-WordPress dynamic pages. Ex: <em>/forum/, /contact/</em> For instance, if you want to exclude the virtual pages generated by a forum plugin, all you have to do is add forum or /forum or /forum/ or and any URL with the word \"forum\" in it, such as http://mysite.com/forum or http://mysite.com/forum/someforumpage here and it will be excluded from All in One SEO Pack.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
190
  "post_meta_tags" => __( "What you enter here will be copied verbatim to the header of all Posts. You can enter whatever additional headers you want here, even references to stylesheets.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
@@ -396,6 +400,10 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
396
  'name' => __( 'Track Multiple Domains:', 'all_in_one_seo_pack' ),
397
  'default' => 0,
398
  'condshow' => Array( 'aiosp_google_analytics_id' => Array( 'lhs' => 'aiosp_google_analytics_id', 'op' => '!=', 'rhs' => '' ) ) ),
 
 
 
 
399
  "ga_display_advertising"=> Array(
400
  'name' => __( '"Display Advertising" Tracking:', 'all_in_one_seo_pack' ),
401
  'type' => 'checkbox',
@@ -435,12 +443,21 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
435
  "search_noindex"=> Array(
436
  'name' => __( 'Use noindex for the Search page:', 'all_in_one_seo_pack' ),
437
  'default' => 0),
 
 
 
 
 
 
438
  "generate_descriptions"=> Array(
439
  'name' => __( 'Autogenerate Descriptions:', 'all_in_one_seo_pack' ),
440
  'default' => 1),
441
  "hide_paginated_descriptions"=> Array(
442
  'name' => __( 'Remove Descriptions For Paginated Pages:', 'all_in_one_seo_pack' ),
443
  'default' => 0),
 
 
 
444
  "unprotect_meta"=> Array(
445
  'name' => __( 'Unprotect Post Meta Fields:', 'all_in_one_seo_pack' ),
446
  'default' => 0),
@@ -487,7 +504,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
487
  });
488
  });
489
  </script>
490
- <div class="preview_snippet"><div id="aioseop_snippet"><h3><a id="aioseop_snippet_title">%s</a></h3><div><div><cite id="aioseop_snippet_link">%s</cite></div><span id="aioseop_snippet_description">%s</span></div></div></div>' ),
491
  'title' => Array( 'name' => __( 'Title', 'all_in_one_seo_pack' ), 'type' => 'text', 'count' => true, 'size' => 60 ),
492
  'description' => Array( 'name' => __( 'Description', 'all_in_one_seo_pack' ), 'type' => 'textarea', 'count' => true, 'cols' => 80, 'rows' => 2 ),
493
  'keywords' => Array( 'name' => __( 'Keywords (comma separated)', 'all_in_one_seo_pack' ), 'type' => 'text' ),
@@ -552,17 +569,17 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
552
  'name' => __( 'Google Settings', 'all_in_one_seo_pack' ),
553
  'help_link' => 'http://semperplugins.com/documentation/google-settings/',
554
  'options' => Array( "google_publisher", "google_disable_profile", "google_author_advanced", "google_author_location", "google_enable_publisher" , "google_specify_publisher",
555
- "google_connect", "google_analytics_id", "ga_use_universal_analytics", "ga_domain", "ga_multi_domain", "ga_display_advertising", "ga_exclude_users", "ga_track_outbound_links" )
556
  ),
557
  'noindex' => Array(
558
  'name' => __( 'Noindex Settings', 'all_in_one_seo_pack' ),
559
  'help_link' => 'http://semperplugins.com/documentation/noindex-settings/',
560
- 'options' => Array( 'cpostnoindex', 'cpostnofollow', 'category_noindex', 'archive_date_noindex', 'archive_author_noindex', 'tags_noindex', 'search_noindex' )
561
  ),
562
  'advanced' => Array(
563
  'name' => __( 'Advanced Settings', 'all_in_one_seo_pack' ),
564
  'help_link' => 'http://semperplugins.com/documentation/advanced-settings/',
565
- 'options' => Array( 'generate_descriptions', 'hide_paginated_descriptions', 'unprotect_meta', 'ex_pages', 'post_meta_tags', 'page_meta_tags', 'front_meta_tags', 'home_meta_tags' )
566
  )
567
  );
568
 
@@ -594,6 +611,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
594
  $wp_query->is_attachment = true;
595
  else
596
  $wp_query->is_single = true;
 
597
  if ( get_option( 'show_on_front' ) == 'page' ) {
598
  if ( is_page() && $post->ID == get_option( 'page_on_front' ) )
599
  $wp_query->is_front_page = true;
@@ -606,20 +624,53 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
606
  $args['options']['save'] = false;
607
  $wp_query->queried_object = $post;
608
 
609
- $title = $this->wp_title();
610
- if ( empty( $title ) ) $title = $post->post_title;
 
 
 
 
 
 
 
 
611
 
612
  if ( ( $aioseop_options['aiosp_can'] ) && ( $url = $this->aiosp_mrt_get_url( $wp_query ) ) )
613
  $url = apply_filters( 'aioseop_canonical_url', $url );
614
  if ( !$url ) $url = get_permalink();
615
 
 
 
616
  $description = $this->get_aioseop_description( $post );
617
- $description = apply_filters( 'aioseop_description', $description );
 
618
 
619
  if ( $this->strlen( $title ) > 70 ) $title = $this->trim_excerpt_without_filters( $title, 70 ) . '...';
620
  if ( $this->strlen( $description ) > 156 ) $description = $this->trim_excerpt_without_filters( $description, 156 ) . '...';
621
 
622
- $args['value'] = sprintf( $args['value'], esc_attr( strip_tags( $title ) ), esc_url( $url ), esc_attr( strip_tags( $description ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  $buf = $this->get_option_row( $args['name'], $args['options'], $args );
624
 
625
  wp_reset_postdata();
@@ -1206,20 +1257,11 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1206
  else if ( is_single() || is_page() || is_home() || $this->is_static_posts_page() )
1207
  $description = $this->get_aioseop_description( $post );
1208
 
1209
- $description = $this->trim_excerpt_without_filters( $description );
1210
-
1211
- $description = apply_filters( 'aioseop_description', $description );
1212
-
1213
- /*
1214
- if ( $this->is_static_front_page() )
1215
- $description = trim( stripslashes( $this->internationalize( $aioseop_options['aiosp_home_description'] ) ) );
1216
- elseif ( !empty( $blog_page ) )
1217
- $description = $this->get_post_description( $blog_page );
1218
- if ( empty( $description ) && is_object( $post ) && !is_archive() && empty( $blog_page ) )
1219
- $description = $this->get_post_description( $post );
1220
 
1221
  $description = apply_filters( 'aioseop_description', $description );
1222
- */
1223
 
1224
  if ( isset($description) && ( $this->strlen($description) > $this->minimum_description_length ) && !( $is_front_page && is_paged() ) ) {
1225
  $description = trim( strip_tags( $description ) );
@@ -1257,7 +1299,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1257
  }
1258
  $meta_string .= sprintf( "<meta name=\"description\" content=\"%s\" />\n", $description );
1259
  }
1260
-
1261
  $keywords = apply_filters( 'aioseop_keywords', $keywords );
1262
 
1263
  if ( isset( $aioseop_options['aiosp_togglekeywords'] ) )
@@ -1272,6 +1314,8 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1272
  }
1273
 
1274
  $is_tag = is_tag();
 
 
1275
 
1276
  $robots_meta = '';
1277
 
@@ -1286,15 +1330,15 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1286
  $aiosp_nofollow = htmlspecialchars( stripslashes( get_post_meta( $post->ID, '_aioseop_nofollow', true ) ) );
1287
  $aiosp_noodp = htmlspecialchars( stripslashes( get_post_meta( $post->ID, '_aioseop_noodp', true ) ) );
1288
  $aiosp_noydir = htmlspecialchars( stripslashes( get_post_meta( $post->ID, '_aioseop_noydir', true ) ) );
1289
- if ( $aiosp_noindex || $aiosp_nofollow || $aiosp_noodp || $aiosp_noydir || !empty( $aioseop_options['aiosp_cpostnoindex'] ) || !empty( $aioseop_options['aiosp_cpostnofollow'] ) ) {
1290
  $noindex = "index";
1291
  $nofollow = "follow";
1292
  $noodp = $noydir = '';
1293
- if ( ( $aiosp_noindex == 'on' ) || ( ( $aiosp_noindex == '' ) &&
1294
- ( !empty( $aioseop_options['aiosp_cpostnoindex'] ) ) && ( in_array( $post_type, $aioseop_options['aiosp_cpostnoindex'] ) ) ) )
1295
  $noindex = "no" . $noindex;
1296
- if ( ( $aiosp_nofollow == 'on' ) || ( ( $aiosp_nofollow == '' ) &&
1297
- ( !empty( $aioseop_options['aiosp_cpostnofollow'] ) ) && ( in_array( $post_type, $aioseop_options['aiosp_cpostnofollow'] ) ) ) )
1298
  $nofollow = "no" . $nofollow;
1299
  if ( $aiosp_noodp ) $nofollow .= ',noodp';
1300
  if ( $aiosp_noydir ) $nofollow .= ',noydir';
@@ -1303,6 +1347,8 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1303
  }
1304
  }
1305
 
 
 
1306
  $robots_meta = apply_filters( 'aioseop_robots_meta', $robots_meta );
1307
  if ( !empty( $robots_meta ) )
1308
  $meta_string .= '<meta name="robots" content="' . esc_attr( $robots_meta ) . '" />' . "\n";
@@ -1314,7 +1360,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1314
 
1315
  foreach( Array( 'page_meta', 'post_meta', 'home_meta', 'front_meta' ) as $meta ) {
1316
  if ( !empty( $aioseop_options["aiosp_{$meta}_tags" ] ) )
1317
- $$meta = html_entity_decode( stripslashes( $aioseop_options["aiosp_{$meta}_tags" ] ) );
1318
  else
1319
  $$meta = '';
1320
  }
@@ -1337,7 +1383,6 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1337
  if ( empty( $googleplus ) && !empty( $aioseop_options['aiosp_google_publisher'] ) )
1338
  $googleplus = $aioseop_options['aiosp_google_publisher'];
1339
 
1340
- $page = $this->get_page_number();
1341
  if ( ( $is_front_page ) && ( $page < 2 ) ) {
1342
  if ( !empty( $aioseop_options['aiosp_google_publisher'] ) )
1343
  $publisher = $aioseop_options['aiosp_google_publisher'];
@@ -1367,7 +1412,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1367
  } else {
1368
  if ( in_array( 'all', $aioseop_options['aiosp_google_author_location'] ) ) {
1369
  if ( is_singular() && !is_singular( $aioseop_options['aiosp_google_author_location'] ) )
1370
- $author = '';
1371
  } else {
1372
  if ( !is_singular( $aioseop_options['aiosp_google_author_location'] ) )
1373
  $author = '';
@@ -1636,7 +1681,6 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1636
 
1637
  function oauth_connect( $count = 0 ) {
1638
  global $aiosp_activation;
1639
- $url = '';
1640
  if ( !class_exists( 'OAuthConsumer' ) ) require_once( 'OAuth.php' );
1641
  $callback_url = NULL;
1642
  $consumer_key = "anonymous";
@@ -1707,9 +1751,13 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1707
  if ( !empty( $aioseop_options['aiosp_ga_multi_domain'] ) ) {
1708
  $allow_linker = "'allowLinker': true";
1709
  }
1710
- $display_advertising = '';
1711
  if (!empty( $aioseop_options['aiosp_ga_display_advertising'] ) ) {
1712
- $display_advertising = "ga('require', 'displayfeatures');";
 
 
 
 
1713
  }
1714
  $js_options = Array();
1715
  foreach( Array( 'cookie_domain', 'allow_linker' ) as $opts ) {
@@ -1728,7 +1776,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
1728
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
1729
 
1730
  ga('create', '{$analytics_id}'{$js_options});
1731
- {$display_advertising}
1732
  ga('send', 'pageview');
1733
  </script>
1734
 
@@ -1760,6 +1808,11 @@ function aiosp_google_analytics() {
1760
  _gaq.push(['_setAccount', '<?php
1761
  echo $aioseop_options['aiosp_google_analytics_id'];
1762
  ?>']);
 
 
 
 
 
1763
  <?php if ( !empty( $aioseop_options['aiosp_ga_multi_domain'] ) ) {
1764
  ?> _gaq.push(['_setAllowLinker', true]);
1765
  <?php
@@ -1823,19 +1876,25 @@ function aiosp_google_analytics() {
1823
  }
1824
  }
1825
  }
 
 
 
 
 
 
 
1826
 
1827
  aiosp_addLoadEvent(function () {
1828
  var links = document.getElementsByTagName('a');
1829
  for (var x=0; x < links.length; x++) {
1830
  if (typeof links[x] == 'undefined') continue;
1831
- if (typeof links[x].onclick != 'undefined') continue;
1832
- links[x].onclick = function () {
1833
  var mydomain = new RegExp(document.domain, 'i');
1834
  href = getAttr(this, 'href');
1835
- if(href && href.toLowerCase().indexOf('http') === 0 && !mydomain.test(href)) {
1836
  recordOutboundLink(this, 'Outbound Links', href);
1837
  }
1838
- }
1839
  }
1840
  });
1841
  </script>
@@ -1894,7 +1953,7 @@ function aiosp_google_analytics() {
1894
  if ( function_exists( 'icl_get_home_url' ) ) {
1895
  $link = icl_get_home_url();
1896
  } else {
1897
- $link = get_option( 'home' );
1898
  }
1899
  }
1900
  } elseif ( $query->is_tax && $haspost ) {
@@ -1903,14 +1962,14 @@ function aiosp_google_analytics() {
1903
  if ( !empty( $term ) )
1904
  $link = get_term_link( $term, $taxonomy );
1905
  } elseif ( $query->is_archive && function_exists( 'get_post_type_archive_link' ) && ( $post_type = get_query_var( 'post_type' ) ) ) {
1906
- if ( is_array( $post_type ) )
1907
  $post_type = reset( $post_type );
1908
- $link = get_post_type_archive_link( $post_type );
1909
  } else {
1910
  return false;
1911
  }
1912
  if ( empty( $link ) || !is_string( $link ) ) return false;
1913
- return $this->yoast_get_paged( $link );
1914
  }
1915
 
1916
  function get_page_number() {
@@ -1920,13 +1979,16 @@ function aiosp_google_analytics() {
1920
  return $page;
1921
  }
1922
 
1923
- function yoast_get_paged( $link ) {
 
1924
  $page = $this->get_page_number();
 
 
1925
  if ( !empty( $page ) && $page > 1 ) {
1926
  if ( get_query_var( 'page' ) == $page )
1927
  $link = trailingslashit( $link ) . "$page";
1928
  else
1929
- $link = trailingslashit( $link ) ."page/". "$page";
1930
  $link = user_trailingslashit( $link, 'paged' );
1931
  }
1932
  return $link;
@@ -1988,14 +2050,14 @@ function aiosp_google_analytics() {
1988
  $description = $this->get_post_description( $blog_page );
1989
  if ( empty( $description ) && is_object( $post ) && !is_archive() && empty( $blog_page ) )
1990
  $description = $this->get_post_description( $post );
 
1991
  return $description;
1992
  }
1993
 
1994
  function replace_title( $content, $title ) {
1995
  $title = trim( strip_tags( $title ) );
1996
- $title_tag_start = "<title>";
1997
- $title_tag_end = "</title>";
1998
- $len_start = $this->strlen( $title_tag_start );
1999
  $title = stripslashes( trim( $title ) );
2000
  $start = $this->strpos( $content, $title_tag_start );
2001
  $end = $this->strpos( $content, $title_tag_end );
@@ -2004,7 +2066,7 @@ function aiosp_google_analytics() {
2004
  $this->title_end = $end;
2005
  $this->orig_title = $title;
2006
 
2007
- return preg_replace( '/<title>(.*?)<\/title>/is', '<title>' . preg_replace('/(\$|\\\\)(?=\d)/', '\\\\\1', strip_tags( $title ) ) . '</title>', $content, 1 );
2008
  }
2009
 
2010
  function internationalize( $in ) {
@@ -2159,15 +2221,6 @@ function aiosp_google_analytics() {
2159
  global $s, $STagging;
2160
  if ( is_front_page() ) {
2161
  $title = $this->internationalize( $aioseop_options['aiosp_home_title'] );
2162
- if ( empty( $title ) && !empty( $post ) && $this->is_static_front_page() ) {
2163
- // $title = $this->internationalize( get_post_meta( $post->ID, "_aioseop_title", true ) );
2164
- // if ( empty( $title ) )
2165
- // $title = $this->internationalize( $post->post_title );
2166
- // if ( empty( $title ) )
2167
- // $title = $this->internationalize( $this->get_original_title( '', false ) );
2168
- // if ( !empty( $title ) )
2169
- // $title = $this->apply_page_title_format( $title );
2170
- }
2171
  if (empty( $title ) )
2172
  $title = $this->internationalize( get_option( 'blogname' ) ) . ' | ' . $this->internationalize( get_bloginfo( 'description' ) );
2173
  return $this->paged_title( $title );
@@ -2179,7 +2232,7 @@ function aiosp_google_analytics() {
2179
  $title = $this->internationalize( $post->post_title );
2180
  if ( !$title )
2181
  $title = $this->internationalize( $this->get_original_title( '', false ) );
2182
- $title = get_the_title( $post->post_parent ) . ' ' . $title . ' ' . get_option( 'blogname' );
2183
  apply_filters( 'aioseop_attachment_title', $title );
2184
  } else if ( is_page() || $this->is_static_posts_page() || ( is_home() && !$this->is_static_posts_page() ) ) {
2185
  if ( $post === null ) return false;
@@ -2332,8 +2385,11 @@ function aiosp_google_analytics() {
2332
  global $aioseop_options;
2333
  $title = false;
2334
  $post = $this->get_queried_object();
2335
- if ( !empty( $aioseop_options['aiosp_rewrite_titles'] ) )
2336
  $title = $this->get_aioseop_title( $post );
 
 
 
2337
  if ( $title === false )
2338
  $title = $this->get_original_title();
2339
  return apply_filters( 'aioseop_title', $title );
@@ -2386,10 +2442,19 @@ function aiosp_google_analytics() {
2386
  $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
2387
  $text = strip_tags( $text );
2388
  if ( !$max ) $max = $this->maximum_description_length;
2389
-
2390
- if ( $max < $this->strlen( $text ) ) {
2391
- while( $text[$max] != ' ' && $max > $this->minimum_description_length ) {
2392
- $max--;
 
 
 
 
 
 
 
 
 
2393
  }
2394
  }
2395
  $text = $this->substr( $text, 0, $max );
173
  "ga_use_universal_analytics" => __( "Use the new Universal Analytics tracking code for Google Analytics; do this for new analytics accounts.", 'all_in_one_seo_pack' ),
174
  "ga_domain" => __( "Enter your domain name if you have enabled tracking of Subdomains in Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
175
  "ga_multi_domain" => __( "Check this if you have enabled tracking of Multiple top-level domains in Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
176
+ "ga_anonymize_ip" => __( "Support for IP Anonymization in Google Analytics.", 'all_in_one_seo_pack' ),
177
  "ga_display_advertising"=> __( "Support for Doubleclick Display Advertising tracking.", 'all_in_one_seo_pack' ),
178
  "ga_exclude_users" => __( "Exclude logged-in users from Google Analytics tracking by role.", 'all_in_one_seo_pack' ),
179
  "ga_track_outbound_links"=> __( "Check this if you want to track outbound links with Google Analytics.<br /><a href='http://semperplugins.com/documentation/google-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
184
  "archive_author_noindex"=> __( "Check this to ask search engines not to index Author Archives. Useful for avoiding duplicate content.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
185
  "tags_noindex" => __( "Check this to ask search engines not to index Tag Archives. Useful for avoiding duplicate content.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
186
  "search_noindex" => __( "Check this to ask search engines not to index the Search page. Useful for avoiding duplicate content.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
187
+ "paginated_noindex" => __( "Check this to ask search engines not to index paginated pages/posts. Useful for avoiding duplicate content.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
188
+ "paginated_nofollow" => __( "Check this to ask search engines not to follow links from paginated pages/posts. Useful for avoiding duplicate content.<br /><a href='http://semperplugins.com/documentation/noindex-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
189
  "generate_descriptions" => __( "Check this and your Meta Descriptions will be auto-generated from your excerpt or content.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
190
  "hide_paginated_descriptions"=> __( "Check this and your Meta Descriptions will be removed from page 2 or later of paginated content.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
191
+ "dont_truncate_descriptions"=> __( "Check this to prevent your Description from being truncated regardless of its length.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
192
  "unprotect_meta" => __( "Check this to unprotect internal postmeta fields for use with XMLRPC. If you don't know what that is, leave it unchecked.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
193
  "ex_pages" => __( "Enter a comma separated list of pages here to be excluded by All in One SEO Pack. This is helpful when using plugins which generate their own non-WordPress dynamic pages. Ex: <em>/forum/, /contact/</em> For instance, if you want to exclude the virtual pages generated by a forum plugin, all you have to do is add forum or /forum or /forum/ or and any URL with the word \"forum\" in it, such as http://mysite.com/forum or http://mysite.com/forum/someforumpage here and it will be excluded from All in One SEO Pack.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
194
  "post_meta_tags" => __( "What you enter here will be copied verbatim to the header of all Posts. You can enter whatever additional headers you want here, even references to stylesheets.<br /><a href='http://semperplugins.com/documentation/advanced-settings/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
400
  'name' => __( 'Track Multiple Domains:', 'all_in_one_seo_pack' ),
401
  'default' => 0,
402
  'condshow' => Array( 'aiosp_google_analytics_id' => Array( 'lhs' => 'aiosp_google_analytics_id', 'op' => '!=', 'rhs' => '' ) ) ),
403
+ "ga_anonymize_ip"=> Array(
404
+ 'name' => __( 'Anonymize IP Addresses:', 'all_in_one_seo_pack' ),
405
+ 'type' => 'checkbox',
406
+ 'condshow' => Array( 'aiosp_google_analytics_id' => Array( 'lhs' => 'aiosp_google_analytics_id', 'op' => '!=', 'rhs' => '' ) ) ),
407
  "ga_display_advertising"=> Array(
408
  'name' => __( '"Display Advertising" Tracking:', 'all_in_one_seo_pack' ),
409
  'type' => 'checkbox',
443
  "search_noindex"=> Array(
444
  'name' => __( 'Use noindex for the Search page:', 'all_in_one_seo_pack' ),
445
  'default' => 0),
446
+ "paginated_noindex" => Array(
447
+ 'name' => __( 'Use noindex for paginated pages/posts:', 'all_in_one_seo_pack' ),
448
+ 'default' => 0),
449
+ "paginated_nofollow"=> Array(
450
+ 'name' => __( 'Use nofollow for paginated pages/posts:', 'all_in_one_seo_pack' ),
451
+ 'default' => 0),
452
  "generate_descriptions"=> Array(
453
  'name' => __( 'Autogenerate Descriptions:', 'all_in_one_seo_pack' ),
454
  'default' => 1),
455
  "hide_paginated_descriptions"=> Array(
456
  'name' => __( 'Remove Descriptions For Paginated Pages:', 'all_in_one_seo_pack' ),
457
  'default' => 0),
458
+ "dont_truncate_descriptions"=> Array(
459
+ 'name' => __( 'Never Shorten Long Descriptions:', 'all_in_one_seo_pack' ),
460
+ 'default' => 0),
461
  "unprotect_meta"=> Array(
462
  'name' => __( 'Unprotect Post Meta Fields:', 'all_in_one_seo_pack' ),
463
  'default' => 0),
504
  });
505
  });
506
  </script>
507
+ <div class="preview_snippet"><div id="aioseop_snippet"><h3><a>%s</a></h3><div><div><cite id="aioseop_snippet_link">%s</cite></div><span id="aioseop_snippet_description">%s</span></div></div></div>' ),
508
  'title' => Array( 'name' => __( 'Title', 'all_in_one_seo_pack' ), 'type' => 'text', 'count' => true, 'size' => 60 ),
509
  'description' => Array( 'name' => __( 'Description', 'all_in_one_seo_pack' ), 'type' => 'textarea', 'count' => true, 'cols' => 80, 'rows' => 2 ),
510
  'keywords' => Array( 'name' => __( 'Keywords (comma separated)', 'all_in_one_seo_pack' ), 'type' => 'text' ),
569
  'name' => __( 'Google Settings', 'all_in_one_seo_pack' ),
570
  'help_link' => 'http://semperplugins.com/documentation/google-settings/',
571
  'options' => Array( "google_publisher", "google_disable_profile", "google_author_advanced", "google_author_location", "google_enable_publisher" , "google_specify_publisher",
572
+ "google_connect", "google_analytics_id", "ga_use_universal_analytics", "ga_domain", "ga_multi_domain", "ga_anonymize_ip", "ga_display_advertising", "ga_exclude_users", "ga_track_outbound_links" )
573
  ),
574
  'noindex' => Array(
575
  'name' => __( 'Noindex Settings', 'all_in_one_seo_pack' ),
576
  'help_link' => 'http://semperplugins.com/documentation/noindex-settings/',
577
+ 'options' => Array( 'cpostnoindex', 'cpostnofollow', 'category_noindex', 'archive_date_noindex', 'archive_author_noindex', 'tags_noindex', 'search_noindex', 'paginated_noindex', 'paginated_nofollow' )
578
  ),
579
  'advanced' => Array(
580
  'name' => __( 'Advanced Settings', 'all_in_one_seo_pack' ),
581
  'help_link' => 'http://semperplugins.com/documentation/advanced-settings/',
582
+ 'options' => Array( 'generate_descriptions', 'hide_paginated_descriptions', 'dont_truncate_descriptions', 'unprotect_meta', 'ex_pages', 'post_meta_tags', 'page_meta_tags', 'front_meta_tags', 'home_meta_tags' )
583
  )
584
  );
585
 
611
  $wp_query->is_attachment = true;
612
  else
613
  $wp_query->is_single = true;
614
+ if ( empty( $wp_query->is_front_page ) ) $wp_query->is_front_page = false;
615
  if ( get_option( 'show_on_front' ) == 'page' ) {
616
  if ( is_page() && $post->ID == get_option( 'page_on_front' ) )
617
  $wp_query->is_front_page = true;
624
  $args['options']['save'] = false;
625
  $wp_query->queried_object = $post;
626
 
627
+ if ( !empty( $post ) && !$wp_query->is_home && !$wp_query->is_front_page ) {
628
+ $title = $this->internationalize( get_post_meta( $post->ID, "_aioseop_title", true ) );
629
+ if ( empty( $title ) ) $title = $post->post_title;
630
+ }
631
+
632
+ $title_format = '';
633
+ if ( empty( $title ) ) {
634
+ $title = $this->wp_title();
635
+ $title_format = '%post_title%';
636
+ }
637
 
638
  if ( ( $aioseop_options['aiosp_can'] ) && ( $url = $this->aiosp_mrt_get_url( $wp_query ) ) )
639
  $url = apply_filters( 'aioseop_canonical_url', $url );
640
  if ( !$url ) $url = get_permalink();
641
 
642
+ $title = $this->apply_cf_fields( $title );
643
+
644
  $description = $this->get_aioseop_description( $post );
645
+ $description = $this->apply_cf_fields( $description );
646
+ $description = apply_filters( 'aioseop_description', $description );
647
 
648
  if ( $this->strlen( $title ) > 70 ) $title = $this->trim_excerpt_without_filters( $title, 70 ) . '...';
649
  if ( $this->strlen( $description ) > 156 ) $description = $this->trim_excerpt_without_filters( $description, 156 ) . '...';
650
 
651
+ if ( empty( $title_format ) ) {
652
+ if ( is_page() )
653
+ $title_format = $aioseop_options['aiosp_page_title_format'];
654
+ elseif ( is_single() )
655
+ $title_format = $this->get_post_title_format();
656
+ }
657
+ $extra_title_len = 0;
658
+ if ( empty( $title_format ) ) {
659
+ $title = '<span id="aioseop_snippet_title">' . esc_attr( strip_tags( $title ) ) . '</span>';
660
+ } else {
661
+ $title_format = str_replace( '%blog_title%', get_bloginfo( 'name' ), $title_format );
662
+ $title_format = $this->apply_cf_fields( $title_format );
663
+ $replace_title = '<span id="aioseop_snippet_title">' . esc_attr( strip_tags( $title ) ) . '</span>';
664
+ $title_format = str_replace( '%post_title%', $replace_title, $title_format );
665
+ $title_format = str_replace( '%page_title%', $replace_title, $title_format );
666
+ $title_format = preg_replace( '/%([^%]*?)%/', '', $title_format );
667
+ $title = $title_format;
668
+ $extra_title_len = strlen( str_replace( $replace_title, '', $title_format ) );
669
+ }
670
+
671
+ $args['value'] = sprintf( $args['value'], $title, esc_url( $url ), esc_attr( strip_tags( $description ) ) );
672
+ $extra_title_len = (int)$extra_title_len;
673
+ $args['value'] .= "<script>var aiosp_title_extra = {$extra_title_len};</script>";
674
  $buf = $this->get_option_row( $args['name'], $args['options'], $args );
675
 
676
  wp_reset_postdata();
1257
  else if ( is_single() || is_page() || is_home() || $this->is_static_posts_page() )
1258
  $description = $this->get_aioseop_description( $post );
1259
 
1260
+ if ( empty( $aioseop_options['aiosp_dont_truncate_descriptions'] ) ) {
1261
+ $description = $this->trim_excerpt_without_filters( $description );
1262
+ }
 
 
 
 
 
 
 
 
1263
 
1264
  $description = apply_filters( 'aioseop_description', $description );
 
1265
 
1266
  if ( isset($description) && ( $this->strlen($description) > $this->minimum_description_length ) && !( $is_front_page && is_paged() ) ) {
1267
  $description = trim( strip_tags( $description ) );
1299
  }
1300
  $meta_string .= sprintf( "<meta name=\"description\" content=\"%s\" />\n", $description );
1301
  }
1302
+ $keywords = $this->apply_cf_fields( $keywords );
1303
  $keywords = apply_filters( 'aioseop_keywords', $keywords );
1304
 
1305
  if ( isset( $aioseop_options['aiosp_togglekeywords'] ) )
1314
  }
1315
 
1316
  $is_tag = is_tag();
1317
+
1318
+ $page = $this->get_page_number();
1319
 
1320
  $robots_meta = '';
1321
 
1330
  $aiosp_nofollow = htmlspecialchars( stripslashes( get_post_meta( $post->ID, '_aioseop_nofollow', true ) ) );
1331
  $aiosp_noodp = htmlspecialchars( stripslashes( get_post_meta( $post->ID, '_aioseop_noodp', true ) ) );
1332
  $aiosp_noydir = htmlspecialchars( stripslashes( get_post_meta( $post->ID, '_aioseop_noydir', true ) ) );
1333
+ if ( $aiosp_noindex || $aiosp_nofollow || $aiosp_noodp || $aiosp_noydir || !empty( $aioseop_options['aiosp_cpostnoindex'] ) || !empty( $aioseop_options['aiosp_cpostnofollow'] ) || !empty( $aioseop_options['aiosp_paginated_noindex'] ) || !empty( $aioseop_options['aiosp_paginated_nofollow'] ) ) {
1334
  $noindex = "index";
1335
  $nofollow = "follow";
1336
  $noodp = $noydir = '';
1337
+ if ( ( $aiosp_noindex == 'on' ) || ( ( !empty( $aioseop_options['aiosp_paginated_noindex'] ) ) && ( ( $page > 1 ) ) ) ||
1338
+ ( ( $aiosp_noindex == '' ) && ( !empty( $aioseop_options['aiosp_cpostnoindex'] ) ) && ( in_array( $post_type, $aioseop_options['aiosp_cpostnoindex'] ) ) ) )
1339
  $noindex = "no" . $noindex;
1340
+ if ( ( $aiosp_nofollow == 'on' ) || ( ( !empty( $aioseop_options['aiosp_paginated_nofollow'] ) ) && ( ( $page > 1 ) ) ) ||
1341
+ ( ( $aiosp_nofollow == '' ) && ( !empty( $aioseop_options['aiosp_cpostnofollow'] ) ) && ( in_array( $post_type, $aioseop_options['aiosp_cpostnofollow'] ) ) ) )
1342
  $nofollow = "no" . $nofollow;
1343
  if ( $aiosp_noodp ) $nofollow .= ',noodp';
1344
  if ( $aiosp_noydir ) $nofollow .= ',noydir';
1347
  }
1348
  }
1349
 
1350
+ if ( $robots_meta == 'index,follow' ) $robots_meta = '';
1351
+
1352
  $robots_meta = apply_filters( 'aioseop_robots_meta', $robots_meta );
1353
  if ( !empty( $robots_meta ) )
1354
  $meta_string .= '<meta name="robots" content="' . esc_attr( $robots_meta ) . '" />' . "\n";
1360
 
1361
  foreach( Array( 'page_meta', 'post_meta', 'home_meta', 'front_meta' ) as $meta ) {
1362
  if ( !empty( $aioseop_options["aiosp_{$meta}_tags" ] ) )
1363
+ $$meta = html_entity_decode( stripslashes( $aioseop_options["aiosp_{$meta}_tags" ] ), ENT_QUOTES );
1364
  else
1365
  $$meta = '';
1366
  }
1383
  if ( empty( $googleplus ) && !empty( $aioseop_options['aiosp_google_publisher'] ) )
1384
  $googleplus = $aioseop_options['aiosp_google_publisher'];
1385
 
 
1386
  if ( ( $is_front_page ) && ( $page < 2 ) ) {
1387
  if ( !empty( $aioseop_options['aiosp_google_publisher'] ) )
1388
  $publisher = $aioseop_options['aiosp_google_publisher'];
1412
  } else {
1413
  if ( in_array( 'all', $aioseop_options['aiosp_google_author_location'] ) ) {
1414
  if ( is_singular() && !is_singular( $aioseop_options['aiosp_google_author_location'] ) )
1415
+ $author = '';
1416
  } else {
1417
  if ( !is_singular( $aioseop_options['aiosp_google_author_location'] ) )
1418
  $author = '';
1681
 
1682
  function oauth_connect( $count = 0 ) {
1683
  global $aiosp_activation;
 
1684
  if ( !class_exists( 'OAuthConsumer' ) ) require_once( 'OAuth.php' );
1685
  $callback_url = NULL;
1686
  $consumer_key = "anonymous";
1751
  if ( !empty( $aioseop_options['aiosp_ga_multi_domain'] ) ) {
1752
  $allow_linker = "'allowLinker': true";
1753
  }
1754
+ $extra_options = '';
1755
  if (!empty( $aioseop_options['aiosp_ga_display_advertising'] ) ) {
1756
+ $extra_options = "ga('require', 'displayfeatures');";
1757
+ }
1758
+ if ( !empty( $aioseop_options['aiosp_ga_anonymize_ip'] ) ) {
1759
+ if ( !empty( $extra_options ) ) $extra_options .= "\n\t\t\t";
1760
+ $extra_options .= "ga('set', 'anonymizeIp', true);";
1761
  }
1762
  $js_options = Array();
1763
  foreach( Array( 'cookie_domain', 'allow_linker' ) as $opts ) {
1776
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
1777
 
1778
  ga('create', '{$analytics_id}'{$js_options});
1779
+ {$extra_options}
1780
  ga('send', 'pageview');
1781
  </script>
1782
 
1808
  _gaq.push(['_setAccount', '<?php
1809
  echo $aioseop_options['aiosp_google_analytics_id'];
1810
  ?>']);
1811
+ <?php if ( !empty( $aioseop_options['aiosp_ga_anonymize_ip'] ) ) {
1812
+ ?> _gaq.push(['_gat._anonymizeIp']);
1813
+ <?php
1814
+ }
1815
+ ?>
1816
  <?php if ( !empty( $aioseop_options['aiosp_ga_multi_domain'] ) ) {
1817
  ?> _gaq.push(['_setAllowLinker', true]);
1818
  <?php
1876
  }
1877
  }
1878
  }
1879
+
1880
+ function aiosp_addEvent(element, evnt, funct){
1881
+ if (element.attachEvent)
1882
+ return element.attachEvent('on'+evnt, funct);
1883
+ else
1884
+ return element.addEventListener(evnt, funct, false);
1885
+ }
1886
 
1887
  aiosp_addLoadEvent(function () {
1888
  var links = document.getElementsByTagName('a');
1889
  for (var x=0; x < links.length; x++) {
1890
  if (typeof links[x] == 'undefined') continue;
1891
+ aiosp_addEvent( links[x], 'onclick', function () {
 
1892
  var mydomain = new RegExp(document.domain, 'i');
1893
  href = getAttr(this, 'href');
1894
+ if (href && href.toLowerCase().indexOf('http') === 0 && !mydomain.test(href)) {
1895
  recordOutboundLink(this, 'Outbound Links', href);
1896
  }
1897
+ });
1898
  }
1899
  });
1900
  </script>
1953
  if ( function_exists( 'icl_get_home_url' ) ) {
1954
  $link = icl_get_home_url();
1955
  } else {
1956
+ $link = trailingslashit( home_url() );
1957
  }
1958
  }
1959
  } elseif ( $query->is_tax && $haspost ) {
1962
  if ( !empty( $term ) )
1963
  $link = get_term_link( $term, $taxonomy );
1964
  } elseif ( $query->is_archive && function_exists( 'get_post_type_archive_link' ) && ( $post_type = get_query_var( 'post_type' ) ) ) {
1965
+ if ( is_array( $post_type ) )
1966
  $post_type = reset( $post_type );
1967
+ $link = get_post_type_archive_link( $post_type );
1968
  } else {
1969
  return false;
1970
  }
1971
  if ( empty( $link ) || !is_string( $link ) ) return false;
1972
+ return $this->get_paged( $link );
1973
  }
1974
 
1975
  function get_page_number() {
1979
  return $page;
1980
  }
1981
 
1982
+ function get_paged( $link ) {
1983
+ global $wp_rewrite;
1984
  $page = $this->get_page_number();
1985
+ $page_name = 'page';
1986
+ if ( !empty( $wp_rewrite ) && !empty( $wp_rewrite->pagination_base ) ) $page_name = $wp_rewrite->pagination_base;
1987
  if ( !empty( $page ) && $page > 1 ) {
1988
  if ( get_query_var( 'page' ) == $page )
1989
  $link = trailingslashit( $link ) . "$page";
1990
  else
1991
+ $link = trailingslashit( $link ) . trailingslashit( $page_name ) . $page;
1992
  $link = user_trailingslashit( $link, 'paged' );
1993
  }
1994
  return $link;
2050
  $description = $this->get_post_description( $blog_page );
2051
  if ( empty( $description ) && is_object( $post ) && !is_archive() && empty( $blog_page ) )
2052
  $description = $this->get_post_description( $post );
2053
+ $description = $this->apply_cf_fields( $description );
2054
  return $description;
2055
  }
2056
 
2057
  function replace_title( $content, $title ) {
2058
  $title = trim( strip_tags( $title ) );
2059
+ $title_tag_start = "<title";
2060
+ $title_tag_end = "</title";
 
2061
  $title = stripslashes( trim( $title ) );
2062
  $start = $this->strpos( $content, $title_tag_start );
2063
  $end = $this->strpos( $content, $title_tag_end );
2066
  $this->title_end = $end;
2067
  $this->orig_title = $title;
2068
 
2069
+ return preg_replace( '/<title([^>]*?)\s*>([^<]*?)<\/title\s*>/is', '<title\\1>' . preg_replace('/(\$|\\\\)(?=\d)/', '\\\\\1', strip_tags( $title ) ) . '</title>', $content, 1 );
2070
  }
2071
 
2072
  function internationalize( $in ) {
2221
  global $s, $STagging;
2222
  if ( is_front_page() ) {
2223
  $title = $this->internationalize( $aioseop_options['aiosp_home_title'] );
 
 
 
 
 
 
 
 
 
2224
  if (empty( $title ) )
2225
  $title = $this->internationalize( get_option( 'blogname' ) ) . ' | ' . $this->internationalize( get_bloginfo( 'description' ) );
2226
  return $this->paged_title( $title );
2232
  $title = $this->internationalize( $post->post_title );
2233
  if ( !$title )
2234
  $title = $this->internationalize( $this->get_original_title( '', false ) );
2235
+ $title = get_the_title( $post->post_parent ) . ' ' . $title . ' - ' . get_option( 'blogname' );
2236
  apply_filters( 'aioseop_attachment_title', $title );
2237
  } else if ( is_page() || $this->is_static_posts_page() || ( is_home() && !$this->is_static_posts_page() ) ) {
2238
  if ( $post === null ) return false;
2385
  global $aioseop_options;
2386
  $title = false;
2387
  $post = $this->get_queried_object();
2388
+ if ( !empty( $aioseop_options['aiosp_rewrite_titles'] ) ) {
2389
  $title = $this->get_aioseop_title( $post );
2390
+ $title = $this->apply_cf_fields( $title );
2391
+ }
2392
+
2393
  if ( $title === false )
2394
  $title = $this->get_original_title();
2395
  return apply_filters( 'aioseop_title', $title );
2442
  $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
2443
  $text = strip_tags( $text );
2444
  if ( !$max ) $max = $this->maximum_description_length;
2445
+ $len = $this->strlen( $text );
2446
+ if ( $max < $len ) {
2447
+ if ( function_exists( 'mb_strrpos' ) ) {
2448
+ $pos = mb_strrpos( $text, ' ', -($len - $max) );
2449
+ if ( $pos > $this->minimum_description_length ) {
2450
+ $max = $pos;
2451
+ } else {
2452
+ $max = $this->minimum_description_length;
2453
+ }
2454
+ } else {
2455
+ while( $text[$max] != ' ' && $max > $this->minimum_description_length ) {
2456
+ $max--;
2457
+ }
2458
  }
2459
  }
2460
  $text = $this->substr( $text, 0, $max );
aioseop_functions.php CHANGED
@@ -579,13 +579,37 @@ if ( !function_exists( 'aioseop_filter_callback' ) ) {
579
 
580
  if ( !function_exists( 'aioseop_add_contactmethods' ) ) {
581
  function aioseop_add_contactmethods( $contactmethods ) {
582
- global $aioseop_options;
583
  if ( empty( $aioseop_options['aiosp_google_disable_profile'] ) )
584
  $contactmethods['googleplus'] = __( 'Google+', 'all_in_one_seo_pack' );
 
 
 
 
 
 
585
  return $contactmethods;
586
  }
587
  }
588
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
589
  /***
590
  * JSON support for PHP < 5.2
591
  */
@@ -644,4 +668,4 @@ if ( !function_exists( 'parse_ini_string' ) ) {
644
  parse_ini_filter::$buf = $string;
645
  return parse_ini_file( "php://filter/read=parse_ini/resource=php://memory", $process_sections );
646
  }
647
- }
579
 
580
  if ( !function_exists( 'aioseop_add_contactmethods' ) ) {
581
  function aioseop_add_contactmethods( $contactmethods ) {
582
+ global $aioseop_options, $aioseop_modules;
583
  if ( empty( $aioseop_options['aiosp_google_disable_profile'] ) )
584
  $contactmethods['googleplus'] = __( 'Google+', 'all_in_one_seo_pack' );
585
+ if ( !empty( $aioseop_modules ) && is_object( $aioseop_modules ) ) {
586
+ $m = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_Opengraph' );
587
+ if ( ( $m !== false ) && is_object( $m ) && $m->option_isset( 'twitter_creator' ) ) {
588
+ $contactmethods['twitter'] = __( 'Twitter', 'all_in_one_seo_pack' );
589
+ }
590
+ }
591
  return $contactmethods;
592
  }
593
  }
594
 
595
+ /***
596
+ * Utility function for inserting elements into associative arrays by key
597
+ */
598
+ if ( !function_exists( 'aioseop_array_insert_after' ) ) {
599
+ function aioseop_array_insert_after( $arr, $insertKey, $newValues ) {
600
+ $keys = array_keys($arr);
601
+ $vals = array_values($arr);
602
+ $insertAfter = array_search($insertKey, $keys) + 1;
603
+ $keys2 = array_splice($keys, $insertAfter);
604
+ $vals2 = array_splice($vals, $insertAfter);
605
+ foreach( $newValues as $k => $v ) {
606
+ $keys[] = $k;
607
+ $vals[] = $v;
608
+ }
609
+ return array_merge(array_combine($keys, $vals), array_combine($keys2, $vals2));
610
+ }
611
+ }
612
+
613
  /***
614
  * JSON support for PHP < 5.2
615
  */
668
  parse_ini_filter::$buf = $string;
669
  return parse_ini_file( "php://filter/read=parse_ini/resource=php://memory", $process_sections );
670
  }
671
+ }
aioseop_module.js CHANGED
@@ -12,7 +12,11 @@ function toggleVisibility(id) {
12
  }
13
 
14
  function countChars(field,cntfield) {
15
- cntfield.value = field.value.length;
 
 
 
 
16
  }
17
 
18
  function aioseop_get_field_value( field ) {
12
  }
13
 
14
  function countChars(field,cntfield) {
15
+ var extra = 0;
16
+ if ( ( field.name == 'aiosp_title' ) && ( typeof aiosp_title_extra !== 'undefined' ) ) {
17
+ extra = aiosp_title_extra;
18
+ }
19
+ cntfield.value = field.value.length + extra;
20
  }
21
 
22
  function aioseop_get_field_value( field ) {
aioseop_module_class.php CHANGED
@@ -288,6 +288,27 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Module' ) ) {
288
  return $output;
289
  }
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  /**
292
  * Returns child blogs of parent in a multisite.
293
  */
@@ -725,12 +746,7 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Module' ) ) {
725
  wp_enqueue_script( 'wp-pointer', false, array( 'jquery' ) );
726
  $this->script_data['pointers'] = $this->pointers;
727
  }
728
- global $wp_version;
729
- if ( version_compare( $wp_version, '3.3', '>=' ) ) {
730
- wp_enqueue_script( 'aioseop-module-script', $this->plugin_path['url'] . 'aioseop_module.js' );
731
- } else {
732
- wp_enqueue_script( 'aioseop-module-script', $this->plugin_path['url'] . 'aioseop_module_old.js' );
733
- }
734
  if ( !empty( $this->script_data ) ) {
735
  $data = Array( 'json' => json_encode( $this->script_data ) );
736
  wp_localize_script( 'aioseop-module-script', 'aioseop_data', $data );
@@ -978,9 +994,11 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Module' ) ) {
978
  if ( in_array( $options['type'], Array( 'multiselect', 'select', 'multicheckbox', 'radio', 'checkbox', 'textarea', 'text', 'submit', 'hidden' ) ) && ( is_string( $value ) ) )
979
  $value = esc_attr( $value );
980
  $buf = '';
 
981
  if ( !empty( $options['count'] ) ) {
982
  $n++;
983
  $attr .= " onKeyDown='countChars(document.post.$name,document.post.{$prefix}length$n)' onKeyUp='countChars(document.post.$name,document.post.{$prefix}length$n)'";
 
984
  }
985
  if ( isset( $opts['id'] ) ) $attr .= " id=\"{$opts['id']}\" ";
986
  switch ( $options['type'] ) {
@@ -1010,6 +1028,7 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Module' ) ) {
1010
  $count_desc = __( ' characters. Most search engines use a maximum of %s chars for the %s.', 'all_in_one_seo_pack' );
1011
  $buf .= "<br /><input readonly type='text' name='{$prefix}length$n' size='3' maxlength='3' style='width:53px;height:23px;margin:0px;padding:0px 0px 0px 10px;' value='" . $this->strlen($value) . "' />"
1012
  . sprintf( $count_desc, $size, $this->strtolower( $options['name'] ) );
 
1013
  }
1014
  return $buf;
1015
  }
288
  return $output;
289
  }
290
 
291
+ /*** adds support for using %cf_(name of field)% for using custom fields / Advanced Custom Fields in titles / descriptions etc. ***/
292
+ function apply_cf_fields( $format ) {
293
+ return preg_replace_callback( '/%cf_([^%]*?)%/', Array( $this, 'cf_field_replace' ), $format );
294
+ }
295
+
296
+ function cf_field_replace( $matches ) {
297
+ $result = '';
298
+ if ( !empty( $matches ) ) {
299
+ if ( !empty( $matches[1] ) ) {
300
+ if ( function_exists( 'get_field' ) ) $result = get_field( $matches[1] );
301
+ if ( empty( $result ) ) {
302
+ global $post;
303
+ if ( !empty( $post ) ) $result = get_post_meta( $post->ID, $matches[1], true );
304
+ }
305
+ if ( empty( $result ) ) $result = $matches[0];
306
+ } else $result = $matches[0];
307
+ }
308
+ $result = strip_tags( $result );
309
+ return $result;
310
+ }
311
+
312
  /**
313
  * Returns child blogs of parent in a multisite.
314
  */
746
  wp_enqueue_script( 'wp-pointer', false, array( 'jquery' ) );
747
  $this->script_data['pointers'] = $this->pointers;
748
  }
749
+ wp_enqueue_script( 'aioseop-module-script', $this->plugin_path['url'] . 'aioseop_module.js' );
 
 
 
 
 
750
  if ( !empty( $this->script_data ) ) {
751
  $data = Array( 'json' => json_encode( $this->script_data ) );
752
  wp_localize_script( 'aioseop-module-script', 'aioseop_data', $data );
994
  if ( in_array( $options['type'], Array( 'multiselect', 'select', 'multicheckbox', 'radio', 'checkbox', 'textarea', 'text', 'submit', 'hidden' ) ) && ( is_string( $value ) ) )
995
  $value = esc_attr( $value );
996
  $buf = '';
997
+ $onload = '';
998
  if ( !empty( $options['count'] ) ) {
999
  $n++;
1000
  $attr .= " onKeyDown='countChars(document.post.$name,document.post.{$prefix}length$n)' onKeyUp='countChars(document.post.$name,document.post.{$prefix}length$n)'";
1001
+ $onload = "countChars(document.post.$name,document.post.{$prefix}length$n);";
1002
  }
1003
  if ( isset( $opts['id'] ) ) $attr .= " id=\"{$opts['id']}\" ";
1004
  switch ( $options['type'] ) {
1028
  $count_desc = __( ' characters. Most search engines use a maximum of %s chars for the %s.', 'all_in_one_seo_pack' );
1029
  $buf .= "<br /><input readonly type='text' name='{$prefix}length$n' size='3' maxlength='3' style='width:53px;height:23px;margin:0px;padding:0px 0px 0px 10px;' value='" . $this->strlen($value) . "' />"
1030
  . sprintf( $count_desc, $size, $this->strtolower( $options['name'] ) );
1031
+ if ( !empty( $onload ) ) $buf .= "<script>{$onload}</script>";
1032
  }
1033
  return $buf;
1034
  }
aioseop_module_old.js DELETED
@@ -1,240 +0,0 @@
1
- if ( typeof aioseop_data != 'undefined' ) {
2
- aioseop_data = aioseop_data.json.replace(/&quot;/g, '"');
3
- try {
4
- aioseop_data = jQuery.parseJSON( aioseop_data );
5
- } catch(e) {
6
- aioseop_data = {};
7
- }
8
- }
9
-
10
- function toggleVisibility(id) {
11
- var e = document.getElementById(id);
12
- if (e.style.display == 'block')
13
- e.style.display = 'none';
14
- else
15
- e.style.display = 'block';
16
- }
17
-
18
- function countChars(field,cntfield) {
19
- cntfield.value = field.value.length;
20
- }
21
-
22
- function aioseop_get_field_value( field ) {
23
- cur = jQuery('[name=' + field + ']');
24
- if ( cur.length == 0 ) return field;
25
- type = cur.attr('type');
26
- if ( type == "checkbox" || type == "radio" )
27
- cur = jQuery('input[name=' + field + ']:checked');
28
- return cur.val();
29
- }
30
-
31
- function aioseop_eval_condshow_logic( statement ) {
32
- var lhs, rhs;
33
- if ( ( typeof statement ) == 'object' ) {
34
- lhs = statement['lhs'];
35
- rhs = statement['rhs'];
36
- if ( lhs !== null && ( ( typeof lhs ) == 'object' ) )
37
- lhs = aioseop_eval_condshow_logic( statement['lhs'] );
38
- if ( rhs !== null && ( typeof rhs ) == 'object' )
39
- rhs = aioseop_eval_condshow_logic( statement['rhs'] );
40
- lhs = aioseop_get_field_value( lhs );
41
- rhs = aioseop_get_field_value( rhs );
42
- switch ( statement['op'] ) {
43
- case 'NOT': return ( ! lhs );
44
- case 'AND': return ( lhs && rhs );
45
- case 'OR' : return ( lhs || rhs );
46
- case '==' : return ( lhs == rhs );
47
- case '!=' : return ( lhs != rhs );
48
- default : return null;
49
- }
50
- }
51
- return statement;
52
- }
53
-
54
- function aioseop_do_condshow_match( index, value ) {
55
- if ( typeof value != 'undefined' ) {
56
- matches = true;
57
- jQuery.each(value, function(subopt, setting) {
58
- var statement;
59
- if ( ( typeof setting ) == 'object' ) {
60
- statement = aioseop_eval_condshow_logic( setting );
61
- if ( !statement ) {
62
- matches = false;
63
- }
64
- } else {
65
- cur = aioseop_get_field_value( subopt );
66
- if ( cur != setting ) {
67
- matches = false;
68
- }
69
- }
70
- });
71
- if ( matches ) {
72
- jQuery('#' + index + '_wrapper' ).show();
73
- } else {
74
- jQuery('#' + index + '_wrapper' ).hide();
75
- }
76
- return matches;
77
- }
78
- return false;
79
- }
80
-
81
- function aioseop_add_condshow_handlers( index, value ) {
82
- if ( typeof value != 'undefined' ) {
83
- jQuery.each(value, function(subopt, setting) {
84
- jQuery('[name=' + subopt + ']').bind( "change keyup", function() {
85
- aioseop_do_condshow_match( index, value );
86
- });
87
- });
88
- }
89
- }
90
-
91
- function aioseop_do_condshow( condshow ) {
92
- if ( typeof aioseop_data.condshow != 'undefined' ) {
93
- jQuery.each(aioseop_data.condshow, function(index, value) {
94
- aioseop_do_condshow_match( index, value );
95
- aioseop_add_condshow_handlers( index, value );
96
- });
97
- }
98
- }
99
-
100
- function aioseop_show_pointer( handle, value ) {
101
- if ( typeof( jQuery( value.pointer_target ).pointer) != 'undefined' ) {
102
- jQuery(value.pointer_target).pointer({
103
- content : value.pointer_text,
104
- close : function() {
105
- jQuery.post( ajaxurl, {
106
- pointer: handle,
107
- action: 'dismiss-wp-pointer'
108
- });
109
- }
110
- }).pointer('open');
111
- }
112
- }
113
-
114
- jQuery(document).ready(function(){
115
- if (typeof aioseop_data != 'undefined') {
116
- if ( typeof aioseop_data.condshow != 'undefined' ) {
117
- aioseop_do_condshow( aioseop_data.condshow );
118
- }
119
- }
120
- });
121
-
122
- jQuery(document).ready(function() {
123
- var image_field;
124
- jQuery('.aioseop_upload_image_button').click(function() {
125
- window.send_to_editor = aioseopNewSendToEditor;
126
- image_field = jQuery(this).next();
127
- formfield = image_field.attr('name');
128
- tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
129
- return false;
130
- });
131
- aioseopStoreSendToEditor = window.send_to_editor;
132
- aioseopNewSendToEditor = function(html) {
133
- imgurl = jQuery('img',html).attr('src');
134
- if ( typeof(imgurl) !== undefined )
135
- image_field.val(imgurl);
136
- tb_remove();
137
- window.send_to_editor = aioseopStoreSendToEditor;
138
- };
139
- });
140
-
141
- // props to commentluv for this fix
142
- // workaround for bug that causes radio inputs to lose settings when meta box is dragged.
143
- // http://core.trac.wordpress.org/ticket/16972
144
- jQuery(document).ready(function(){
145
- // listen for drag drop of metaboxes , bind mousedown to .hndle so it only fires when starting to drag
146
- jQuery('.hndle').mousedown(function(){
147
- // set live event listener for mouse up on the content .wrap and wait a tick to give the dragged div time to settle before firing the reclick function
148
- jQuery('.wrap').mouseup(function(){store_radio(); setTimeout('reclick_radio();',50);});
149
- })
150
- });
151
- /**
152
- * stores object of all radio buttons that are checked for entire form
153
- */
154
- if(typeof store_radio != 'function') {
155
- function store_radio(){
156
- var radioshack = {};
157
- jQuery('input[type="radio"]').each(function(){
158
- if(jQuery(this).is(':checked')){
159
- radioshack[jQuery(this).attr('name')] = jQuery(this).val();
160
- }
161
- jQuery(document).data('radioshack',radioshack);
162
- });
163
- }
164
- }
165
- /**
166
- * detect mouseup and restore all radio buttons that were checked
167
- */
168
- if(typeof reclick_radio != 'function') {
169
- function reclick_radio(){
170
- // get object of checked radio button names and values
171
- var radios = jQuery(document).data('radioshack');
172
- //step thru each object element and trigger a click on it's corresponding radio button
173
- for(key in radios){
174
- jQuery('input[name="'+key+'"]').filter('[value="'+radios[key]+'"]').trigger('click');
175
- }
176
- // unbind the event listener on .wrap (prevents clicks on inputs from triggering function)
177
- jQuery('.wrap').unbind('mouseup');
178
- }
179
- }
180
-
181
- function aioseop_handle_post_url( action, settings, options) {
182
- jQuery("div#aiosp_"+settings).fadeOut('fast', function() {
183
- var loading = '<label class="aioseop_loading aioseop_'+settings+'_loading"></label> Please wait...';
184
- jQuery("div#aiosp_"+settings).fadeIn('fast', function() {
185
- var aioseop_sack = new sack(ajaxurl);
186
- aioseop_sack.execute = 1;
187
- aioseop_sack.method = 'POST';
188
- aioseop_sack.setVar( "action", action );
189
- aioseop_sack.setVar( "settings", settings );
190
- aioseop_sack.setVar( "options", options );
191
- aioseop_sack.setVar( "nonce-aioseop", jQuery('input[name="nonce-aioseop"]').val() );
192
- aioseop_sack.onError = function() {alert('Ajax error on saving.'); };
193
- aioseop_sack.runAJAX();
194
- });
195
- jQuery("div#aiosp_"+settings).html(loading);
196
- })
197
- };
198
-
199
- function aioseop_is_overflowed(element) {
200
- return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
201
- }
202
-
203
- function aioseop_overflow_border( el ) {
204
- if ( aioseop_is_overflowed(el) ) {
205
- el.className = 'aioseop_option_div aioseop_overflowed';
206
- } else {
207
- el.className = 'aioseop_option_div';
208
- }
209
- }
210
-
211
- jQuery(document).ready(function() {
212
- if ( typeof aioseop_data.pointers != 'undefined' ) {
213
- jQuery.each(aioseop_data.pointers, function(index, value) {
214
- if ( value != 'undefined' && value.pointer_text != '' ) {
215
- aioseop_show_pointer( index, value );
216
- }
217
- });
218
- }
219
- var selectors = "div.aioseop_multicheckbox_type div.aioseop_option_div, #aiosp_performance_status div.aioseop_option_div";
220
- jQuery(selectors).each(function() {
221
- aioseop_overflow_border(this);
222
- });
223
- var resizeTimer;
224
- jQuery(window).resize(function() {
225
- clearTimeout(resizeTimer);
226
- resizeTimer = setTimeout(jQuery(selectors).each(function() {
227
- aioseop_overflow_border(this);
228
- }), 250);
229
- });
230
- jQuery(".aioseop_tab:not(:first)").hide();
231
- jQuery(".aioseop_tab:first").show();
232
- jQuery("a.aioseop_header_tab").click(function(){
233
- var stringref = jQuery(this).attr("href").split('#')[1];
234
- jQuery('.aioseop_tab:not(#'+stringref+')').hide('slow');
235
- jQuery('.aioseop_tab#' + stringref).show('slow');
236
- jQuery('.aioseop_header_tab[href!=#'+stringref+']').removeClass('active');
237
- jQuery('.aioseop_header_tab[href=#' + stringref+']').addClass('active');
238
- return false;
239
- });
240
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aioseop_opengraph.php CHANGED
@@ -62,7 +62,8 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
62
  'movie' => __( 'Movie', 'all_in_one_seo_pack' ),
63
  'product' => __( 'Product', 'all_in_one_seo_pack' ),
64
  'song' => __( 'Song', 'all_in_one_seo_pack' ),
65
- 'tv_show' => __( 'TV Show', 'all_in_one_seo_pack' )
 
66
  ),'Websites' => Array(
67
  'article' => __( 'Article', 'all_in_one_seo_pack' ),
68
  'blog' => __( 'Blog', 'all_in_one_seo_pack' ),
@@ -90,10 +91,16 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
90
  "customimg" => __( "This option lets you upload an image to use as the Open Graph image for this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
91
  "imagewidth" => __( "Enter the width for your Open Graph image in pixels (i.e. 600).<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
92
  "imageheight" => __( "Enter the height for your Open Graph image in pixels (i.e. 600).<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
 
 
 
 
 
93
  "types" => __( "Select which Post Types you want to use All in One SEO Pack to set Open Graph meta values for.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
94
  "title" => __( "This is the Open Graph title of this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
95
  "desc" => __( "This is the Open Graph description of this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
96
- "category" => __( "Select the Open Graph type that best describes the content of this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' )
 
97
  );
98
  $count_desc = __( " characters. Open Graph allows up to a maximum of %s chars for the %s.", 'all_in_one_seo_pack' );
99
  $this->default_options = array(
@@ -123,6 +130,15 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
123
  'type' => 'text', 'default' => '' ),
124
  'imageheight' => Array( 'name' => __( 'Specify Image Height', 'all_in_one_seo_pack' ),
125
  'type' => 'text', 'default' => '' ),
 
 
 
 
 
 
 
 
 
126
  'types' => Array( 'name' => __( 'Enable Facebook Meta for', 'all_in_one_seo_pack'),
127
  'type' => 'multicheckbox', 'initial_options' => $this->get_post_type_titles( Array( '_builtin' => false ) ),
128
  'default' => Array( 'post' => 'post', 'page' => 'page' ) ),
@@ -134,7 +150,9 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
134
  'type' => 'select', 'style' => '',
135
  'initial_options' => $this->fb_object_types,
136
  'default' => ''
137
- )
 
 
138
  );
139
 
140
  if ( !empty( $help_text ) )
@@ -149,10 +167,10 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
149
 
150
  $this->locations = array(
151
  'opengraph' => Array( 'name' => $this->name, 'prefix' => 'aiosp_', 'type' => 'settings',
152
- 'options' => Array('scan_header', 'setmeta', 'key', 'sitename', 'hometitle', 'description', 'homeimage', 'disable_jetpack', 'generate_descriptions', 'defimg', 'fallback', 'dimg', 'meta_key', 'categories', 'types') ),
153
  'settings' => Array( 'name' => __('Social Settings', 'all_in_one_seo_pack'),
154
  'type' => 'metabox', 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#pagepost_settings',
155
- 'options' => Array( 'title', 'desc', 'image', 'customimg', 'imagewidth', 'imageheight', 'category' ),
156
  'display' => $display, 'prefix' => 'aioseop_opengraph_'
157
  )
158
  );
@@ -232,6 +250,9 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
232
  if ( isset( $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ) ) {
233
  $settings[$prefix . 'category']['initial_options'] = array_merge( Array( '' => 'Default - ' . $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ), $settings[$prefix . 'category']['initial_options'] );
234
  }
 
 
 
235
  }
236
  if ( isset( $current[ $prefix . 'setmeta' ] ) && $current[ $prefix . 'setmeta' ] )
237
  foreach ( $opts as $opt )
@@ -300,6 +321,7 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
300
  $dimg = $this->options['aiosp_opengraph_dimg'];
301
  $current_post_type = get_post_type();
302
  $title = $description = $image = '';
 
303
 
304
  $sitename = $this->options['aiosp_opengraph_sitename'];
305
 
@@ -310,9 +332,7 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
310
  $first_page = true;
311
  }
312
  $url = $aiosp->aiosp_mrt_get_url( $wp_query );
313
- $home_url = get_option( 'home' );
314
- if ( $url == $home_url ) $url = trailingslashit( $url );
315
- $url = apply_filters( 'aioseop_canonical_url',$url );
316
  $setmeta = $this->options['aiosp_opengraph_setmeta'];
317
  if ( is_home( ) || $aiosp->is_static_front_page() ) {
318
  $title = $this->options['aiosp_opengraph_hometitle'];
@@ -348,6 +368,9 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
348
  } elseif ( isset( $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ) ) {
349
  $type = $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"];
350
  }
 
 
 
351
 
352
  $image = $metabox['aioseop_opengraph_settings_image'];
353
  $title = $metabox['aioseop_opengraph_settings_title'];
@@ -370,7 +393,10 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
370
  if ( !empty( $description ) )
371
  $description = $aiosp->trim_excerpt_without_filters( $aiosp->internationalize( preg_replace( '/\s+/', ' ', $description ) ), 1000 );
372
 
373
- /* Data Validation */
 
 
 
374
  $title = strip_tags( esc_attr( $title ) );
375
  $sitename = strip_tags( esc_attr( $sitename ) );
376
  $description = strip_tags( esc_attr( $description ) );
@@ -418,8 +444,23 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
418
  }
419
 
420
  $card = 'summary';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
 
422
- /* OG only: */
423
  $meta = Array(
424
  'facebook' => Array(
425
  'title' => 'og:title',
@@ -430,10 +471,14 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
430
  'height' => 'og:image:height',
431
  'sitename' => 'og:site_name',
432
  'key' => 'fb:admins',
433
- 'description' => 'og:description'
 
434
  ),
435
  'twitter' => Array(
436
  'card' => 'twitter:card',
 
 
 
437
  'description' => 'twitter:description',
438
  )
439
  );
@@ -472,16 +517,6 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
472
  );
473
  */
474
 
475
- /*
476
- Note -- add support for these too, as per https://dev.twitter.com/docs/cards
477
-
478
- Card Property Description Required
479
- twitter:site @username for the website used in the card footer. No
480
- twitter:site:id Same as twitter:site, but the website's Twitter user ID instead. Note that user ids never change, while @usernames can be changed by the user. No
481
- twitter:creator @username for the content creator / author. No
482
- twitter:creator:id Same as twitter:creator, but the Twitter user's ID. No
483
- */
484
-
485
  $tags = Array(
486
  'facebook' => Array( 'name' => 'property', 'value' => 'content' ),
487
  'twitter' => Array( 'name' => 'name', 'value' => 'content' ),
62
  'movie' => __( 'Movie', 'all_in_one_seo_pack' ),
63
  'product' => __( 'Product', 'all_in_one_seo_pack' ),
64
  'song' => __( 'Song', 'all_in_one_seo_pack' ),
65
+ 'tv_show' => __( 'TV Show', 'all_in_one_seo_pack' ),
66
+ 'episode' => __( 'Episode', 'all_in_one_seo_pack' )
67
  ),'Websites' => Array(
68
  'article' => __( 'Article', 'all_in_one_seo_pack' ),
69
  'blog' => __( 'Blog', 'all_in_one_seo_pack' ),
91
  "customimg" => __( "This option lets you upload an image to use as the Open Graph image for this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
92
  "imagewidth" => __( "Enter the width for your Open Graph image in pixels (i.e. 600).<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
93
  "imageheight" => __( "Enter the height for your Open Graph image in pixels (i.e. 600).<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
94
+ "defcard" => __( "Select the default type of Twitter card to display.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
95
+ "setcard" => __( "Select the default type of Twitter card to display.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
96
+ "twitter_site" => __( "Enter the Twitter username associated with your website here.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
97
+ "twitter_creator" => __( "Allows your authors to be identified by their Twitter usernames as content creators on the Twitter cards for their posts.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
98
+ "twitter_domain" => __( "Enter the name of your website here.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
99
  "types" => __( "Select which Post Types you want to use All in One SEO Pack to set Open Graph meta values for.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
100
  "title" => __( "This is the Open Graph title of this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
101
  "desc" => __( "This is the Open Graph description of this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
102
+ "category" => __( "Select the Open Graph type that best describes the content of this Page or Post.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' ),
103
+ "tag" => __( "This Open Graph meta allows you to add a list of keywords that best describe this content.<br /><a href='http://semperplugins.com/documentation/social-meta-module/' target='_blank'>Click here for documentation on this setting</a>", 'all_in_one_seo_pack' )
104
  );
105
  $count_desc = __( " characters. Open Graph allows up to a maximum of %s chars for the %s.", 'all_in_one_seo_pack' );
106
  $this->default_options = array(
130
  'type' => 'text', 'default' => '' ),
131
  'imageheight' => Array( 'name' => __( 'Specify Image Height', 'all_in_one_seo_pack' ),
132
  'type' => 'text', 'default' => '' ),
133
+ 'defcard' => Array( 'name' => __( 'Default Twitter Card', 'all_in_one_seo_pack' ),
134
+ 'type' => 'select', 'initial_options' => Array( 'summary' => __( 'Summary', 'all_in_one_seo_pack' ), 'summary_large_image' => __( 'Summary Large Image', 'all_in_one_seo_pack' ), 'photo' => __( 'Photo', 'all_in_one_seo_pack' ) ), 'default' => 'summary' ),
135
+ 'setcard' => Array( 'name' => __( 'Twitter Card Type', 'all_in_one_seo_pack' ),
136
+ 'type' => 'select', 'initial_options' => Array( 'summary' => __( 'Summary', 'all_in_one_seo_pack' ), 'summary_large_image' => __( 'Summary Large Image', 'all_in_one_seo_pack' ), 'photo' => __( 'Photo', 'all_in_one_seo_pack' ) ) ),
137
+ 'twitter_site' => Array( 'name' => __( 'Twitter Site', 'all_in_one_seo_pack' ),
138
+ 'type' => 'text', 'default' => '' ),
139
+ 'twitter_creator'=>Array( 'name' => __( 'Show Twitter Author', 'all_in_one_seo_pack' ) ),
140
+ 'twitter_domain'=> Array( 'name' => __( 'Twitter Domain', 'all_in_one_seo_pack' ),
141
+ 'type' => 'text', 'default' => '' ),
142
  'types' => Array( 'name' => __( 'Enable Facebook Meta for', 'all_in_one_seo_pack'),
143
  'type' => 'multicheckbox', 'initial_options' => $this->get_post_type_titles( Array( '_builtin' => false ) ),
144
  'default' => Array( 'post' => 'post', 'page' => 'page' ) ),
150
  'type' => 'select', 'style' => '',
151
  'initial_options' => $this->fb_object_types,
152
  'default' => ''
153
+ ),
154
+ 'tag' => Array( 'name' => __( 'Article Tags', 'all_in_one_seo_pack' ),
155
+ 'type' => 'text', 'default' => '', 'condshow' => Array( 'aioseop_opengraph_settings_category' => 'article' ) ),
156
  );
157
 
158
  if ( !empty( $help_text ) )
167
 
168
  $this->locations = array(
169
  'opengraph' => Array( 'name' => $this->name, 'prefix' => 'aiosp_', 'type' => 'settings',
170
+ 'options' => Array('scan_header', 'setmeta', 'key', 'sitename', 'hometitle', 'description', 'homeimage', 'disable_jetpack', 'generate_descriptions', 'defimg', 'fallback', 'dimg', 'meta_key', 'categories', 'defcard', 'twitter_site', 'twitter_creator', 'twitter_domain', 'types') ),
171
  'settings' => Array( 'name' => __('Social Settings', 'all_in_one_seo_pack'),
172
  'type' => 'metabox', 'help_link' => 'http://semperplugins.com/documentation/social-meta-module/#pagepost_settings',
173
+ 'options' => Array( 'title', 'desc', 'image', 'customimg', 'imagewidth', 'imageheight', 'category', 'tag', 'setcard' ),
174
  'display' => $display, 'prefix' => 'aioseop_opengraph_'
175
  )
176
  );
250
  if ( isset( $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ) ) {
251
  $settings[$prefix . 'category']['initial_options'] = array_merge( Array( '' => 'Default - ' . $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ), $settings[$prefix . 'category']['initial_options'] );
252
  }
253
+ if ( isset( $this->options["aiosp_opengraph_defcard"] ) ) {
254
+ $settings[$prefix . 'setcard']['default'] = $this->options["aiosp_opengraph_defcard"];
255
+ }
256
  }
257
  if ( isset( $current[ $prefix . 'setmeta' ] ) && $current[ $prefix . 'setmeta' ] )
258
  foreach ( $opts as $opt )
321
  $dimg = $this->options['aiosp_opengraph_dimg'];
322
  $current_post_type = get_post_type();
323
  $title = $description = $image = '';
324
+ $type = 'article';
325
 
326
  $sitename = $this->options['aiosp_opengraph_sitename'];
327
 
332
  $first_page = true;
333
  }
334
  $url = $aiosp->aiosp_mrt_get_url( $wp_query );
335
+ $url = apply_filters( 'aioseop_canonical_url', $url );
 
 
336
  $setmeta = $this->options['aiosp_opengraph_setmeta'];
337
  if ( is_home( ) || $aiosp->is_static_front_page() ) {
338
  $title = $this->options['aiosp_opengraph_hometitle'];
368
  } elseif ( isset( $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"] ) ) {
369
  $type = $this->options["aiosp_opengraph_{$current_post_type}_fb_object_type"];
370
  }
371
+ if ( $type == 'article' && ( !empty( $metabox['aioseop_opengraph_settings_tag'] ) ) ) {
372
+ $tag = $metabox['aioseop_opengraph_settings_tag'];
373
+ }
374
 
375
  $image = $metabox['aioseop_opengraph_settings_image'];
376
  $title = $metabox['aioseop_opengraph_settings_title'];
393
  if ( !empty( $description ) )
394
  $description = $aiosp->trim_excerpt_without_filters( $aiosp->internationalize( preg_replace( '/\s+/', ' ', $description ) ), 1000 );
395
 
396
+ $title = $this->apply_cf_fields( $title );
397
+ $description = $this->apply_cf_fields( $description );
398
+
399
+ /* Data Validation */
400
  $title = strip_tags( esc_attr( $title ) );
401
  $sitename = strip_tags( esc_attr( $sitename ) );
402
  $description = strip_tags( esc_attr( $description ) );
444
  }
445
 
446
  $card = 'summary';
447
+ if ( !empty( $this->options['aiosp_opengraph_defcard'] ) )
448
+ $card = $this->options['aiosp_opengraph_defcard'];
449
+
450
+ if ( !empty( $metabox['aioseop_opengraph_settings_setcard'] ) )
451
+ $card = $metabox['aioseop_opengraph_settings_setcard'];
452
+
453
+ $site = $domain = $creator = '';
454
+
455
+ if ( !empty( $this->options['aiosp_opengraph_twitter_site'] ) )
456
+ $site = $this->options['aiosp_opengraph_twitter_site'];
457
+
458
+ if ( !empty( $this->options['aiosp_opengraph_twitter_domain'] ) )
459
+ $domain = $this->options['aiosp_opengraph_twitter_domain'];
460
+
461
+ if ( !empty( $post ) && isset( $post->post_author ) && !empty( $this->options['aiosp_opengraph_twitter_creator'] ) )
462
+ $creator = get_the_author_meta( 'twitter', $post->post_author );
463
 
 
464
  $meta = Array(
465
  'facebook' => Array(
466
  'title' => 'og:title',
471
  'height' => 'og:image:height',
472
  'sitename' => 'og:site_name',
473
  'key' => 'fb:admins',
474
+ 'description' => 'og:description',
475
+ 'tag' => 'article:tag'
476
  ),
477
  'twitter' => Array(
478
  'card' => 'twitter:card',
479
+ 'site' => 'twitter:site',
480
+ 'creator' => 'twitter:creator',
481
+ 'domain' => 'twitter:domain',
482
  'description' => 'twitter:description',
483
  )
484
  );
517
  );
518
  */
519
 
 
 
 
 
 
 
 
 
 
 
520
  $tags = Array(
521
  'facebook' => Array( 'name' => 'property', 'value' => 'content' ),
522
  'twitter' => Array( 'name' => 'name', 'value' => 'content' ),
aioseop_sitemap.php CHANGED
@@ -13,12 +13,19 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
13
  var $start_memory_usage = 0;
14
  var $max_posts = 50000;
15
  var $paginate = false;
16
-
 
 
 
 
 
17
  function All_in_One_SEO_Pack_Sitemap( ) {
18
  if ( get_class( $this ) === 'All_in_One_SEO_Pack_Sitemap' ) { // Set this up only when instantiated as this class
19
  $this->name = __( 'XML Sitemap', 'all_in_one_seo_pack' ); // Human-readable name of the plugin
20
  $this->prefix = 'aiosp_sitemap_'; // option prefix
21
  $this->file = __FILE__; // the current file
 
 
22
  }
23
  parent::__construct();
24
  $this->comment_string = __( "Sitemap %s generated by All in One SEO Pack %s by Michael Torbert of Semper Fi Web Design on %s", 'all_in_one_seo_pack' );
@@ -85,16 +92,20 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
85
  )
86
  );
87
 
88
- $prio = Array( 'no' => 'Do Not Override' );
89
-
90
  for( $i = 0; $i <= 10; $i++ ) {
91
  $str = sprintf( "%0.1f", $i / 10.0 );
92
  $prio[ $str ] = $str;
93
  }
 
 
 
 
94
 
95
- $freq = Array( 'no' => 'Do Not Override' );
96
-
97
  foreach ( Array( 'always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never' ) as $f ) $freq[ $f ] = $f;
 
 
98
 
99
  foreach( Array( 'prio' => __( 'priority', 'all_in_one_seo_pack' ), 'freq' => __( 'frequency', 'all_in_one_seo_pack' ) ) as $k => $v ) {
100
  $s = "{$k}_options";
@@ -105,7 +116,13 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
105
  'archive' => __( 'archive pages', 'all_in_one_seo_pack' ),
106
  'author' => __( 'author pages', 'all_in_one_seo_pack' ) ) as $opt => $val ) {
107
  $arr = $$s;
108
- $arr[ $k . '_' . $opt ] = Array( 'name' => $this->ucwords( $val ), 'help_text' => sprintf( __( "Manually set the %s of your %s.", 'all_in_one_seo_pack' ), $v, $val ), 'type' => 'select', 'initial_options' => $$k, 'default' => 'no' );
 
 
 
 
 
 
109
  if ( ( $opt == 'archive' ) || ( $opt == 'author' ) ) $arr[ $k . '_' . $opt ][ 'condshow' ] = Array( $this->prefix . $opt => 'on' );
110
  $$s = $arr;
111
  }
@@ -168,7 +185,7 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
168
  function load_sitemap_options() {
169
  // load initial options / set defaults
170
  $this->update_options( );
171
- if ( !empty( $this->options["{$this->prefix}paginate"] ) ) {
172
  $this->paginate = true;
173
  if ( ( $this->options["{$this->prefix}max_posts"] ) && ( $this->options["{$this->prefix}max_posts"] > 0 ) && ( $this->options["{$this->prefix}max_posts"] < 50000 ) )
174
  $this->max_posts = $this->options["{$this->prefix}max_posts"];
@@ -236,12 +253,33 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
236
  /** Add post type details for settings once post types have been registered. **/
237
  function add_post_types() {
238
  $post_type_titles = $this->get_post_type_titles( Array( 'public' => true ) );
 
239
  if ( isset( $post_type_titles['attachment'] ) ) $post_type_titles['attachment'] = __( "Media / Attachments", 'all_in_one_seo_pack' );
240
  $this->default_options['posttypes' ]['initial_options'] = array_merge( Array( 'all' => __( 'All Post Types', 'all_in_one_seo_pack' ) ), $post_type_titles );
241
- $this->default_options['taxonomies']['initial_options'] = array_merge( Array( 'all' => __( 'All Taxonomies', 'all_in_one_seo_pack' ) ), $this->get_taxonomy_titles( Array( 'public' => true ) ) );
242
  $this->default_options['posttypes' ]['default'] = array_keys( $this->default_options['posttypes' ]['initial_options'] );
243
  $this->default_options['taxonomies']['default'] = array_keys( $this->default_options['taxonomies']['initial_options'] );
244
  $this->default_options['excl_categories']['initial_options'] = $this->get_category_titles();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  $this->update_options();
246
  }
247
 
@@ -392,7 +430,8 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
392
  }
393
  }
394
  }
395
- return apply_filters( $this->prefix . 'sitemap_urls', $siteurls );
 
396
  }
397
 
398
  /** Scan for sitemaps on filesystem. **/
@@ -656,30 +695,39 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
656
  exit();
657
  }
658
  }
659
-
660
- /** Output sitemaps dynamically based on rewrite rules. **/
661
- function do_rewrite_sitemap( $sitemap_type, $page = 0 ) {
662
- $this->add_post_types();
663
- $comment = __( "dynamically", 'all_in_one_seo_pack' );
664
  if ( $this->options["{$this->prefix}indexes"] ) {
665
  $posttypes = $this->options["{$this->prefix}posttypes"];
666
  if ( empty( $posttypes ) ) $posttypes = Array();
667
  $taxonomies = $this->options["{$this->prefix}taxonomies"];
668
  if ( empty( $taxonomies ) ) $taxonomies = Array();
669
  if ( $sitemap_type === 'root' ) {
670
- $this->output_sitemap_index( array_merge( $this->get_sitemap_index_filenames() ), $comment );
671
  } elseif ( $sitemap_type === 'addl' ) {
672
- $this->output_sitemap( $this->get_addl_pages(), $comment );
673
  } elseif ( $sitemap_type === 'archive' && $this->option_isset( 'archive' ) ) {
674
- $this->output_sitemap( $this->get_archive_prio_data(), $comment );
675
  } elseif ( $sitemap_type === 'author' && $this->option_isset( 'author' ) ) {
676
- $this->output_sitemap( $this->get_author_prio_data(), $comment );
677
  } elseif ( in_array( $sitemap_type, $posttypes ) ) {
678
- $this->output_sitemap( $this->get_all_post_priority_data( $sitemap_type, 'publish', $page ), $comment );
679
  } elseif ( in_array( $sitemap_type, $taxonomies ) ) {
680
- $this->output_sitemap( $this->get_term_priority_data( get_terms( $sitemap_type, $this->get_tax_args( $page ) ) ), $comment );
 
 
 
681
  }
682
- } elseif ( $sitemap_type === 'root' ) echo $this->do_simple_sitemap( $comment );
 
 
 
 
 
 
 
 
683
  }
684
 
685
  /** Build a url to the sitemap. **/
@@ -722,7 +770,7 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
722
 
723
  /** Build static sitemaps on submit if rewrite rules are not in use, do logging. **/
724
  function do_sitemaps() {
725
- if ( !empty( $this->options["{$this->prefix}paginate"] ) ) {
726
  $this->paginate = true;
727
  if ( ( $this->options["{$this->prefix}max_posts"] ) && ( $this->options["{$this->prefix}max_posts"] > 0 ) && ( $this->options["{$this->prefix}max_posts"] < 50000 ) )
728
  $this->max_posts = $this->options["{$this->prefix}max_posts"];
@@ -771,40 +819,39 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
771
  return $this->save_file( $filename, $contents );
772
  }
773
 
774
- /** Get priority settings for sitemap entries. **/
775
- function get_default_priority( $item, $nodefaults = false ) {
776
- $defaults = Array( 'homepage' => '1.0', 'blog' => '0.9', 'sitemap' => '0.8', 'post' => '0.7', 'archive' => '0.5', 'author' => '0.3', 'taxonomies' => '0.3' );
777
- static $cache = Array();
778
- if ( !empty( $cache[ $item ] ) ) return $cache[ $item ];
779
  if ( !empty( $defaults[ $item ] ) ) {
780
- $field = $this->prefix . 'prio_' . $item;
781
- if ( $this->option_isset( 'prio_' . $item ) && $this->options[ $field ] != 'no' ) {
782
- $cache[ $item ] = $this->options[ $field ];
783
- return $this->options[ $field ];
 
 
 
 
784
  }
785
  if ( $nodefaults ) return false;
786
  return $defaults[ $item ];
787
  }
788
  return false;
789
  }
790
-
 
 
 
 
 
 
 
791
  /** Get frequency settings for sitemap entries. **/
792
- function get_default_frequency( $item, $nodefaults = false ) {
793
  $defaults = Array( 'homepage' => 'always', 'blog' => 'daily', 'sitemap' => 'hourly', 'post' => 'weekly', 'archive' => 'monthly', 'author' => 'weekly', 'taxonomies' => 'monthly' );
794
  static $cache = Array();
795
- if ( !empty( $cache[ $item ] ) ) return $cache[ $item ];
796
- if ( !empty( $defaults[ $item ] ) ) {
797
- $field = $this->prefix . 'freq_' . $item;
798
- if ( $this->option_isset( 'freq_' . $item ) && $this->options[ $field ] != 'no' ) {
799
- $cache[ $item ] = $this->options[ $field ];
800
- return $this->options[ $field ];
801
- }
802
- if ( $nodefaults ) return false;
803
- return $defaults[ $item ];
804
- }
805
- return false;
806
  }
807
-
808
  /** Build an index of sitemaps used. **/
809
  function get_sitemap_index_filenames() {
810
  $files = Array();
@@ -822,6 +869,9 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
822
  $prio = $this->get_default_priority( 'post' );
823
  $freq = $this->get_default_frequency( 'post' );
824
  $post_counts = $this->get_all_post_counts( Array('post_type' => $options["{$this->prefix}posttypes"], 'post_status' => 'publish') );
 
 
 
825
  foreach( $options["{$this->prefix}posttypes"] as $sm ) {
826
  if ( $post_counts[$sm] == 0 ) continue;
827
  if ( $this->paginate ) {
@@ -859,56 +909,70 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
859
  $files[] = Array( 'loc' => $csm, 'priority' => $this->get_default_priority( 'sitemap' ), 'changefreq' => $this->get_default_frequency( 'sitemap' ) );
860
  return $files;
861
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
 
863
  /** Build all the indexes. **/
864
  function do_indexed_sitemaps() {
865
  $this->start_memory_usage = memory_get_peak_usage();
866
  $options = $this->options;
867
- $comment = __( "file '%s' statically", 'all_in_one_seo_pack' );
868
- $this->write_sitemaps( $options["{$this->prefix}filename"],
869
- $this->build_sitemap_index( $this->get_sitemap_index_filenames() ), sprintf( $comment, $options["{$this->prefix}filename"] ) );
870
- $this->write_sitemaps( $options["{$this->prefix}filename"] . "_addl",
871
- $this->build_sitemap( $this->get_addl_pages(), sprintf( $comment, $options["{$this->prefix}filename"] . "_addl" ) ) );
 
 
872
  if ( ( !isset( $options["{$this->prefix}posttypes"] ) ) || ( !is_array( $options["{$this->prefix}posttypes"] ) ) ) $options["{$this->prefix}posttypes"] = Array();
873
  if ( ( !isset( $options["{$this->prefix}taxonomies"] ) ) || ( !is_array( $options["{$this->prefix}taxonomies"] ) ) ) $options["{$this->prefix}taxonomies"] = Array();
874
  $options["{$this->prefix}posttypes"] = array_diff( $options["{$this->prefix}posttypes"], Array( 'all' ) );
875
  $options["{$this->prefix}taxonomies"] = array_diff( $options["{$this->prefix}taxonomies"], Array( 'all' ) );
876
-
877
  if ( !empty( $options["{$this->prefix}posttypes"] ) ) {
878
  $post_counts = $this->get_all_post_counts( Array('post_type' => $options["{$this->prefix}posttypes"], 'post_status' => 'publish') );
879
  foreach ( $options["{$this->prefix}posttypes"] as $posttype ) {
880
  if ( $post_counts[$posttype] === 0 ) continue;
881
  if ( $this->paginate && ( $post_counts[$posttype] > $this->max_posts ) ) {
882
  $count = 1;
883
- for( $post_count = 0; $post_count < $post_counts[$posttype]; $post_count += $this->max_posts ) {
884
- $comment = sprintf( $comment, $options["{$this->prefix}filename"] . "_{$posttype}_{$count}" );
885
- $this->write_sitemaps( $options["{$this->prefix}filename"] . "_{$posttype}_{$count}",
886
- $this->build_sitemap( $this->get_all_post_priority_data( $posttype, 'publish', ( $count - 1 ) ), $comment ) );
887
  $count++;
888
  }
889
  } else {
890
- $comment = sprintf( $comment, $options["{$this->prefix}filename"] . "_$posttype" );
891
- $this->write_sitemaps( $options["{$this->prefix}filename"] . "_$posttype",
892
- $this->build_sitemap( $this->get_all_post_priority_data( $posttype ), $comment ) );
893
  }
894
- }
895
  }
896
 
897
- if ( $this->option_isset( 'archive') ) {
898
- $comment = sprintf( $comment, $options["{$this->prefix}filename"] . "_archive" );
899
- $this->write_sitemaps( $options["{$this->prefix}filename"] . "_archive",
900
- $this->build_sitemap( $this->get_archive_prio_data(), $comment ) );
901
- }
902
- if ( $this->option_isset( 'author') ) {
903
- $comment = sprintf( $comment, $options["{$this->prefix}filename"] . "_author" );
904
- $this->write_sitemaps( $options["{$this->prefix}filename"] . "_author",
905
- $this->build_sitemap( $this->get_author_prio_data(), $comment ) );
906
- }
907
- if ( !empty( $options["{$this->prefix}taxonomies"] ) )
908
- foreach ( $options["{$this->prefix}taxonomies"] as $taxonomy ) {
909
-
910
- }
911
-
912
  if ( !empty( $options["{$this->prefix}taxonomies"] ) )
913
  foreach( $options["{$this->prefix}taxonomies"] as $taxonomy ) {
914
  $term_count = wp_count_terms( $taxonomy, array('hide_empty' => true) );
@@ -916,30 +980,22 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
916
  if ( $this->paginate ) {
917
  if ( $term_count > $this->max_posts ) {
918
  $count = 1;
919
- for( $tc = 0; $tc < $term_count; $tc += $this->max_posts ) {
920
- $comment = sprintf( $comment, $options["{$this->prefix}filename"] . "_$taxonomy_$count" );
921
- $this->write_sitemaps( $options["{$this->prefix}filename"] . "_$taxonomy_$count",
922
- $this->build_sitemap( $this->get_term_priority_data( get_terms( $taxonomy, $this->get_tax_args( $tc ) ), $comment ) ) );
923
  $count++;
924
  }
925
  } else {
926
- $comment = sprintf( $comment, $options["{$this->prefix}filename"] . "_$taxonomy" );
927
- $this->write_sitemaps( $options["{$this->prefix}filename"] . "_$taxonomy",
928
- $this->build_sitemap( $this->get_term_priority_data( get_terms( $taxonomy, $this->get_tax_args() ), $comment ) ) );
929
  }
930
  } else {
931
- $comment = sprintf( $comment, $options["{$this->prefix}filename"] . "_$taxonomy" );
932
- $this->write_sitemaps( $options["{$this->prefix}filename"] . "_$taxonomy",
933
- $this->build_sitemap( $this->get_term_priority_data( get_terms( $taxonomy, $this->get_tax_args() ), $comment ) ) );
934
  }
935
  }
936
  }
937
-
938
  $this->log_stats( 'indexed', $options["{$this->prefix}gzipped"], false );
939
  }
940
-
941
- /** Build a single, stand-alone sitemap without indexes. **/
942
- function do_simple_sitemap( $comment = '' ) {
943
  $home = Array(
944
  'loc' => get_home_url(),
945
  'priority' => $this->get_default_priority( 'homepage' ),
@@ -987,7 +1043,20 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
987
  $prio2 = $this->get_term_priority_data( $terms );
988
  $prio3 = $this->get_addl_pages_only();
989
  $prio = array_merge( $child, $prio, $prio2, $prio3 );
990
- return $this->build_sitemap( $prio, $comment );
 
 
 
 
 
 
 
 
 
 
 
 
 
991
  }
992
 
993
  /** Output the XML for a sitemap. **/
@@ -1000,10 +1069,13 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1000
  $plugin_url = parse_url( $plugin_path );
1001
  $current_host = $_SERVER['HTTP_HOST'];
1002
  if ( empty( $current_host ) ) $current_host = $_SERVER['SERVER_NAME'];
1003
- if ( !empty( $current_host ) && ( $current_host != $plugin_url['host'] ) ) {
 
1004
  $plugin_url['host'] = $current_host;
1005
- $plugin_path = $this->unparse_url( $plugin_url );
1006
- }
 
 
1007
  $xml_header = '<?xml-stylesheet type="text/xsl" href="' . $plugin_path . 'sitemap.xsl"?>' . "\r\n"
1008
  . '<urlset ';
1009
  $namespaces = apply_filters( $this->prefix . 'xml_namespace', Array( 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9' ) );
@@ -1101,15 +1173,18 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1101
  function get_term_priority_data( $terms ) {
1102
  $prio = Array();
1103
  if (is_array( $terms ) ) {
1104
- $f = $this->get_default_frequency( 'taxonomies' );
1105
- $p = $this->get_default_priority( 'taxonomies' );
1106
  foreach ($terms as $term) {
1107
- $url = $this->get_term_link( $term, $term->taxonomy );
1108
- $prio[] = Array(
1109
- 'loc' => $url,
1110
- 'changefreq' => $f,
1111
- 'priority' => $p
1112
- );
 
 
 
1113
  }
1114
  }
1115
  return $prio;
@@ -1171,6 +1246,7 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1171
  function unparse_url($parsed_url) {
1172
  $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
1173
  $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
 
1174
  $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
1175
  $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
1176
  $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
@@ -1393,6 +1469,12 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1393
  $pr_info[ 'priority' ] = $prio_override;
1394
  if ( $freq_override )
1395
  $pr_info[ 'changefreq' ] = $freq_override;
 
 
 
 
 
 
1396
  $pr_info['loc'] = $url;
1397
  $pr_info = apply_filters( $this->prefix . 'prio_item_filter', $pr_info, $post, $args );
1398
  if ( !empty( $pr_info ) )
@@ -1543,12 +1625,13 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1543
  if ( !is_array( $args['post_type'] ) || ( count( $args['post_type'] ) == 1 ) ) {
1544
  if ( is_array( $args['post_type'] ) )
1545
  $args['post_type'] = array_shift( $args['post_type'] );
1546
- $count = (Array)wp_count_posts( $args['post_type'] );
1547
  $post_counts = $count[$status];
1548
  } else
1549
  foreach( $args['post_type'] as $post_type ) {
1550
  if ( $post_type === 'all' ) continue;
1551
  $count = (Array)wp_count_posts( $post_type );
 
1552
  if ( empty( $count ) )
1553
  $post_counts[$post_type] = 0;
1554
  else {
@@ -1618,6 +1701,7 @@ if ( !class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
1618
  $ex_args['meta_value'] = 'on';
1619
  $ex_args['meta_compare'] = '=';
1620
  $ex_args['fields'] = 'ids';
 
1621
  $q = new WP_Query( $ex_args );
1622
  if ( !is_array( $args['exclude'] ) ) $args['exclude'] = explode( ',', $args['exclude'] );
1623
  if ( !empty( $q->posts ) ) $args['exclude'] = array_merge( $args['exclude'], $q->posts );
13
  var $start_memory_usage = 0;
14
  var $max_posts = 50000;
15
  var $paginate = false;
16
+ var $prio;
17
+ var $prio_sel;
18
+ var $freq;
19
+ var $freq_sel;
20
+ var $extra_sitemaps;
21
+
22
  function All_in_One_SEO_Pack_Sitemap( ) {
23
  if ( get_class( $this ) === 'All_in_One_SEO_Pack_Sitemap' ) { // Set this up only when instantiated as this class
24
  $this->name = __( 'XML Sitemap', 'all_in_one_seo_pack' ); // Human-readable name of the plugin
25
  $this->prefix = 'aiosp_sitemap_'; // option prefix
26
  $this->file = __FILE__; // the current file
27
+ $this->extra_sitemaps = Array();
28
+ $this->extra_sitemaps = apply_filters( $this->prefix . 'extra', $this->extra_sitemaps );
29
  }
30
  parent::__construct();
31
  $this->comment_string = __( "Sitemap %s generated by All in One SEO Pack %s by Michael Torbert of Semper Fi Web Design on %s", 'all_in_one_seo_pack' );
92
  )
93
  );
94
 
95
+ $prio = Array();
 
96
  for( $i = 0; $i <= 10; $i++ ) {
97
  $str = sprintf( "%0.1f", $i / 10.0 );
98
  $prio[ $str ] = $str;
99
  }
100
+ $arr_no = Array( 'no' => __( 'Do Not Override', 'all_in_one_seo_pack' ) );
101
+ $arr_sel = Array( 'sel' => __( 'Select Individual', 'all_in_one_seo_pack' ) );
102
+ $this->prio_sel = array_merge( $arr_no, $arr_sel, $prio );
103
+ $this->prio = array_merge( $arr_no, $prio );
104
 
105
+ $freq = Array();
 
106
  foreach ( Array( 'always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never' ) as $f ) $freq[ $f ] = $f;
107
+ $this->freq_sel = array_merge( $arr_no, $arr_sel, $freq );
108
+ $this->freq = array_merge( $arr_no, $freq );
109
 
110
  foreach( Array( 'prio' => __( 'priority', 'all_in_one_seo_pack' ), 'freq' => __( 'frequency', 'all_in_one_seo_pack' ) ) as $k => $v ) {
111
  $s = "{$k}_options";
116
  'archive' => __( 'archive pages', 'all_in_one_seo_pack' ),
117
  'author' => __( 'author pages', 'all_in_one_seo_pack' ) ) as $opt => $val ) {
118
  $arr = $$s;
119
+ if ( ( $opt == 'post' ) || ( $opt == 'taxonomies' ) ) {
120
+ $iopts = $this->{"{$k}_sel"};
121
+ } else {
122
+ $iopts = $this->$k;
123
+ }
124
+
125
+ $arr[ $k . '_' . $opt ] = Array( 'name' => $this->ucwords( $val ), 'help_text' => sprintf( __( "Manually set the %s of your %s.", 'all_in_one_seo_pack' ), $v, $val ), 'type' => 'select', 'initial_options' => $iopts, 'default' => 'no' );
126
  if ( ( $opt == 'archive' ) || ( $opt == 'author' ) ) $arr[ $k . '_' . $opt ][ 'condshow' ] = Array( $this->prefix . $opt => 'on' );
127
  $$s = $arr;
128
  }
185
  function load_sitemap_options() {
186
  // load initial options / set defaults
187
  $this->update_options( );
188
+ if ( !empty( $this->options["{$this->prefix}indexes"] ) && !empty( $this->options["{$this->prefix}paginate"] ) ) {
189
  $this->paginate = true;
190
  if ( ( $this->options["{$this->prefix}max_posts"] ) && ( $this->options["{$this->prefix}max_posts"] > 0 ) && ( $this->options["{$this->prefix}max_posts"] < 50000 ) )
191
  $this->max_posts = $this->options["{$this->prefix}max_posts"];
253
  /** Add post type details for settings once post types have been registered. **/
254
  function add_post_types() {
255
  $post_type_titles = $this->get_post_type_titles( Array( 'public' => true ) );
256
+ $taxonomy_titles = $this->get_taxonomy_titles( Array( 'public' => true ) );
257
  if ( isset( $post_type_titles['attachment'] ) ) $post_type_titles['attachment'] = __( "Media / Attachments", 'all_in_one_seo_pack' );
258
  $this->default_options['posttypes' ]['initial_options'] = array_merge( Array( 'all' => __( 'All Post Types', 'all_in_one_seo_pack' ) ), $post_type_titles );
259
+ $this->default_options['taxonomies']['initial_options'] = array_merge( Array( 'all' => __( 'All Taxonomies', 'all_in_one_seo_pack' ) ), $taxonomy_titles );
260
  $this->default_options['posttypes' ]['default'] = array_keys( $this->default_options['posttypes' ]['initial_options'] );
261
  $this->default_options['taxonomies']['default'] = array_keys( $this->default_options['taxonomies']['initial_options'] );
262
  $this->default_options['excl_categories']['initial_options'] = $this->get_category_titles();
263
+ $prio_help = __( "Manually set the priority for the ", 'all_in_one_seo_pack' );
264
+ $freq_help = __( "Manually set the frequency for the ", 'all_in_one_seo_pack' );
265
+ $post_name = __( " Post Type", 'all_in_one_seo_pack' );
266
+ $tax_name = __( " Taxonomy", 'all_in_one_seo_pack' );
267
+ foreach( $post_type_titles as $k => $v ) {
268
+ $key = 'prio_post_' . $k;
269
+ $this->default_options = aioseop_array_insert_after( $this->default_options, 'prio_post', Array( $key => Array( 'name' => $v . $post_name, 'help_text' => $prio_help . $v . $post_name, 'type' => 'select', 'initial_options' => $this->prio, 'default' => 'no', 'condshow' => Array( "{$this->prefix}prio_post" => 'sel' ) ) ) );
270
+ $this->layout['priorities']['options'][] = $key;
271
+ $key = 'freq_post_' . $k;
272
+ $this->default_options = aioseop_array_insert_after( $this->default_options, 'freq_post', Array( $key => Array( 'name' => $v . $post_name, 'help_text' => $freq_help . $v . $post_name, 'type' => 'select', 'initial_options' => $this->freq, 'default' => 'no', 'condshow' => Array( "{$this->prefix}freq_post" => 'sel' ) ) ) );
273
+ $this->layout['frequencies']['options'][] = $key;
274
+ }
275
+ foreach( $taxonomy_titles as $k => $v ) {
276
+ $key = 'prio_taxonomies_' . $k;
277
+ $this->default_options = aioseop_array_insert_after( $this->default_options, 'prio_taxonomies', Array( $key => Array( 'name' => $v . $tax_name, 'help_text' => $prio_help . $v . $tax_name, 'type' => 'select', 'initial_options' => $this->prio, 'default' => 'no', 'condshow' => Array( "{$this->prefix}prio_taxonomies" => 'sel' ) ) ) );
278
+ $this->layout['priorities']['options'][] = $key;
279
+ $key = 'freq_taxonomies_' . $k;
280
+ $this->default_options = aioseop_array_insert_after( $this->default_options, 'freq_taxonomies', Array( $key => Array( 'name' => $v . $tax_name, 'help_text' => $freq_help . $v . $tax_name, 'type' => 'select', 'initial_options' => $this->freq, 'default' => 'no', 'condshow' => Array( "{$this->prefix}freq_taxonomies" => 'sel' ) ) ) );
281
+ $this->layout['frequencies']['options'][] = $key;
282
+ }
283
  $this->update_options();
284
  }
285
 
430
  }
431
  }
432
  }
433
+ $siteurls = apply_filters( $this->prefix . 'sitemap_urls', $siteurls ); // legacy
434
+ return apply_filters( $this->prefix . 'child_urls', $siteurls );
435
  }
436
 
437
  /** Scan for sitemaps on filesystem. **/
695
  exit();
696
  }
697
  }
698
+
699
+ function get_sitemap_data( $sitemap_type, $page = 0 ) {
700
+ $sitemap_data = Array();
 
 
701
  if ( $this->options["{$this->prefix}indexes"] ) {
702
  $posttypes = $this->options["{$this->prefix}posttypes"];
703
  if ( empty( $posttypes ) ) $posttypes = Array();
704
  $taxonomies = $this->options["{$this->prefix}taxonomies"];
705
  if ( empty( $taxonomies ) ) $taxonomies = Array();
706
  if ( $sitemap_type === 'root' ) {
707
+ $sitemap_data = array_merge( $this->get_sitemap_index_filenames() );
708
  } elseif ( $sitemap_type === 'addl' ) {
709
+ $sitemap_data = $this->get_addl_pages();
710
  } elseif ( $sitemap_type === 'archive' && $this->option_isset( 'archive' ) ) {
711
+ $sitemap_data = $this->get_archive_prio_data();
712
  } elseif ( $sitemap_type === 'author' && $this->option_isset( 'author' ) ) {
713
+ $sitemap_data = $this->get_author_prio_data();
714
  } elseif ( in_array( $sitemap_type, $posttypes ) ) {
715
+ $sitemap_data = $this->get_all_post_priority_data( $sitemap_type, 'publish', $page );
716
  } elseif ( in_array( $sitemap_type, $taxonomies ) ) {
717
+ $sitemap_data = $this->get_term_priority_data( get_terms( $sitemap_type, $this->get_tax_args( $page ) ) );
718
+ } else {
719
+ if ( is_array( $this->extra_sitemaps ) && in_array( $sitemap_type, $this->extra_sitemaps ) )
720
+ $sitemap_data = apply_filters( $this->prefix . 'custom_' . $sitemap_type, $sitemap_data, $page, $this_options );
721
  }
722
+ } elseif ( $sitemap_type === 'root' ) $sitemap_data = $this->get_simple_sitemap();
723
+ return apply_filters( $this->prefix . 'data', $sitemap_data, $sitemap_type, $page, $this->options );
724
+ }
725
+
726
+ /** Output sitemaps dynamically based on rewrite rules. **/
727
+ function do_rewrite_sitemap( $sitemap_type, $page = 0 ) {
728
+ $this->add_post_types();
729
+ $comment = __( "dynamically", 'all_in_one_seo_pack' );
730
+ $this->output_sitemap( $this->get_sitemap_data( $sitemap_type, $page ), $comment );
731
  }
732
 
733
  /** Build a url to the sitemap. **/
770
 
771
  /** Build static sitemaps on submit if rewrite rules are not in use, do logging. **/
772
  function do_sitemaps() {
773
+ if ( !empty( $this->options["{$this->prefix}indexes"] ) && !empty( $this->options["{$this->prefix}paginate"] ) ) {
774
  $this->paginate = true;
775
  if ( ( $this->options["{$this->prefix}max_posts"] ) && ( $this->options["{$this->prefix}max_posts"] > 0 ) && ( $this->options["{$this->prefix}max_posts"] < 50000 ) )
776
  $this->max_posts = $this->options["{$this->prefix}max_posts"];
819
  return $this->save_file( $filename, $contents );
820
  }
821
 
822
+ /*** Helper function for handling default values ***/
823
+ function get_default_values( $defaults, $prefix, &$cache, $item, $nodefaults = false, $type = '' ) {
824
+ if ( !empty( $cache[ $item . $type ] ) ) return $cache[ $item . $type ];
 
 
825
  if ( !empty( $defaults[ $item ] ) ) {
826
+ $field = $this->prefix . $prefix . $item;
827
+ if ( $this->option_isset( $prefix . $item ) && $this->options[ $field ] != 'no' ) {
828
+ if ( ( $this->options[ $field ] == 'sel' ) && !empty( $type ) && ( isset( $this->options[ $this->prefix . $prefix . $item . '_' . $type ] ) ) ) {
829
+ $cache[ $item . $type ] = $this->options[ $this->prefix . $prefix . $item . '_' . $type ];
830
+ } else {
831
+ $cache[ $item . $type ] = $this->options[ $field ];
832
+ }
833
+ return $cache[ $item . $type ];
834
  }
835
  if ( $nodefaults ) return false;
836
  return $defaults[ $item ];
837
  }
838
  return false;
839
  }
840
+
841
+ /** Get priority settings for sitemap entries. **/
842
+ function get_default_priority( $item, $nodefaults = false, $type = '' ) {
843
+ $defaults = Array( 'homepage' => '1.0', 'blog' => '0.9', 'sitemap' => '0.8', 'post' => '0.7', 'archive' => '0.5', 'author' => '0.3', 'taxonomies' => '0.3' );
844
+ static $cache = Array();
845
+ return $this->get_default_values( $defaults, 'prio_', $cache, $item, $nodefaults, $type );
846
+ }
847
+
848
  /** Get frequency settings for sitemap entries. **/
849
+ function get_default_frequency( $item, $nodefaults = false, $type = '' ) {
850
  $defaults = Array( 'homepage' => 'always', 'blog' => 'daily', 'sitemap' => 'hourly', 'post' => 'weekly', 'archive' => 'monthly', 'author' => 'weekly', 'taxonomies' => 'monthly' );
851
  static $cache = Array();
852
+ return $this->get_default_values( $defaults, 'freq_', $cache, $item, $nodefaults, $type );
 
 
 
 
 
 
 
 
 
 
853
  }
854
+
855
  /** Build an index of sitemaps used. **/
856
  function get_sitemap_index_filenames() {
857
  $files = Array();
869
  $prio = $this->get_default_priority( 'post' );
870
  $freq = $this->get_default_frequency( 'post' );
871
  $post_counts = $this->get_all_post_counts( Array('post_type' => $options["{$this->prefix}posttypes"], 'post_status' => 'publish') );
872
+ if ( !is_array( $post_counts ) && is_array( $options["{$this->prefix}posttypes"] ) && count( $options["{$this->prefix}posttypes"] ) == 1 ) {
873
+ $post_counts = Array( $options["{$this->prefix}posttypes"][0] => $post_counts );
874
+ }
875
  foreach( $options["{$this->prefix}posttypes"] as $sm ) {
876
  if ( $post_counts[$sm] == 0 ) continue;
877
  if ( $this->paginate ) {
909
  $files[] = Array( 'loc' => $csm, 'priority' => $this->get_default_priority( 'sitemap' ), 'changefreq' => $this->get_default_frequency( 'sitemap' ) );
910
  return $files;
911
  }
912
+
913
+ function do_build_sitemap( $sitemap_type, $page = 0, $filename = '', $comment = '' ) {
914
+ if ( empty( $filename ) ) {
915
+ if ( $sitemap_type == 'root' ) {
916
+ $filename = $this->options["{$this->prefix}filename"];
917
+ } else {
918
+ $filename = $this->options["{$this->prefix}filename"] . '_' . $sitemap_type;
919
+ }
920
+ }
921
+ if ( empty( $comment ) )
922
+ $comment = __( "file '%s' statically", 'all_in_one_seo_pack' );
923
+ $sitemap_data = $this->get_sitemap_data( $sitemap_type, $page );
924
+ if ( $sitemap_type == 'root' ) {
925
+ return $this->build_sitemap_index( $sitemap_data, sprintf( $comment, $filename ) );
926
+ } else {
927
+ return $this->build_sitemap( $sitemap_data, sprintf( $comment, $filename ) );
928
+ }
929
+ }
930
+
931
+ function do_write_sitemap( $sitemap_type, $page = 0, $filename = '', $comment = '' ) {
932
+ if ( empty( $filename ) ) {
933
+ if ( $sitemap_type == 'root' ) {
934
+ $filename = $this->options["{$this->prefix}filename"];
935
+ } else {
936
+ $filename = $this->options["{$this->prefix}filename"] . '_' . $sitemap_type;
937
+ }
938
+ }
939
+ if ( empty( $comment ) )
940
+ $comment = __( "file '%s' statically", 'all_in_one_seo_pack' );
941
+ $this->write_sitemaps( $filename, $this->do_build_sitemap( $sitemap_type, $page, $filename, $comment ) );
942
+ }
943
 
944
  /** Build all the indexes. **/
945
  function do_indexed_sitemaps() {
946
  $this->start_memory_usage = memory_get_peak_usage();
947
  $options = $this->options;
948
+
949
+ $this->do_write_sitemap( 'root' );
950
+ $this->do_write_sitemap( 'addl' );
951
+
952
+ if ( $this->option_isset( 'archive' ) ) $this->do_write_sitemap( 'archive' );
953
+ if ( $this->option_isset( 'author' ) ) $this->do_write_sitemap( 'author' );
954
+
955
  if ( ( !isset( $options["{$this->prefix}posttypes"] ) ) || ( !is_array( $options["{$this->prefix}posttypes"] ) ) ) $options["{$this->prefix}posttypes"] = Array();
956
  if ( ( !isset( $options["{$this->prefix}taxonomies"] ) ) || ( !is_array( $options["{$this->prefix}taxonomies"] ) ) ) $options["{$this->prefix}taxonomies"] = Array();
957
  $options["{$this->prefix}posttypes"] = array_diff( $options["{$this->prefix}posttypes"], Array( 'all' ) );
958
  $options["{$this->prefix}taxonomies"] = array_diff( $options["{$this->prefix}taxonomies"], Array( 'all' ) );
959
+
960
  if ( !empty( $options["{$this->prefix}posttypes"] ) ) {
961
  $post_counts = $this->get_all_post_counts( Array('post_type' => $options["{$this->prefix}posttypes"], 'post_status' => 'publish') );
962
  foreach ( $options["{$this->prefix}posttypes"] as $posttype ) {
963
  if ( $post_counts[$posttype] === 0 ) continue;
964
  if ( $this->paginate && ( $post_counts[$posttype] > $this->max_posts ) ) {
965
  $count = 1;
966
+ for( $post_count = 0; $post_count < $post_counts[$posttype]; $post_count += $this->max_posts ) {
967
+ $this->do_write_sitemap( $posttype, $count - 1, $options["{$this->prefix}filename"] . "_{$posttype}_{$count}" );
 
 
968
  $count++;
969
  }
970
  } else {
971
+ $this->do_write_sitemap( $posttype );
 
 
972
  }
973
+ }
974
  }
975
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
976
  if ( !empty( $options["{$this->prefix}taxonomies"] ) )
977
  foreach( $options["{$this->prefix}taxonomies"] as $taxonomy ) {
978
  $term_count = wp_count_terms( $taxonomy, array('hide_empty' => true) );
980
  if ( $this->paginate ) {
981
  if ( $term_count > $this->max_posts ) {
982
  $count = 1;
983
+ for( $tc = 0; $tc < $term_count; $tc += $this->max_posts ) {
984
+ $this->do_write_sitemap( $taxonomy, $tc, $options["{$this->prefix}filename"] . "_{$taxonomy}_{$count}" );
 
 
985
  $count++;
986
  }
987
  } else {
988
+ $this->do_write_sitemap( $taxonomy );
 
 
989
  }
990
  } else {
991
+ $this->do_write_sitemap( $taxonomy );
 
 
992
  }
993
  }
994
  }
 
995
  $this->log_stats( 'indexed', $options["{$this->prefix}gzipped"], false );
996
  }
997
+
998
+ function get_simple_sitemap() {
 
999
  $home = Array(
1000
  'loc' => get_home_url(),
1001
  'priority' => $this->get_default_priority( 'homepage' ),
1043
  $prio2 = $this->get_term_priority_data( $terms );
1044
  $prio3 = $this->get_addl_pages_only();
1045
  $prio = array_merge( $child, $prio, $prio2, $prio3 );
1046
+ if ( is_array( $this->extra_sitemaps ) )
1047
+ foreach( $this->extra_sitemaps as $sitemap_type ) {
1048
+ $sitemap_data = Array();
1049
+ $sitemap_data = apply_filters( $this->prefix . 'custom_' . $sitemap_type, $sitemap_data, $page, $this_options );
1050
+ $prio = array_merge( $prio, $sitemap_data );
1051
+ }
1052
+ return $prio;
1053
+ }
1054
+
1055
+ /** Build a single, stand-alone sitemap without indexes. **/
1056
+ function do_simple_sitemap( $comment = '' ) {
1057
+ $sitemap_data = $this->get_simple_sitemap();
1058
+ $sitemap_data = apply_filters( $this->prefix . 'data', $sitemap_data, 'root', 0, $this->options );
1059
+ return $this->build_sitemap( $sitemap_data, $comment );
1060
  }
1061
 
1062
  /** Output the XML for a sitemap. **/
1069
  $plugin_url = parse_url( $plugin_path );
1070
  $current_host = $_SERVER['HTTP_HOST'];
1071
  if ( empty( $current_host ) ) $current_host = $_SERVER['SERVER_NAME'];
1072
+
1073
+ if ( !empty( $current_host ) && ( $current_host != $plugin_url['host'] ) )
1074
  $plugin_url['host'] = $current_host;
1075
+
1076
+ unset( $plugin_url['scheme'] );
1077
+ $plugin_path = $this->unparse_url( $plugin_url );
1078
+
1079
  $xml_header = '<?xml-stylesheet type="text/xsl" href="' . $plugin_path . 'sitemap.xsl"?>' . "\r\n"
1080
  . '<urlset ';
1081
  $namespaces = apply_filters( $this->prefix . 'xml_namespace', Array( 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9' ) );
1173
  function get_term_priority_data( $terms ) {
1174
  $prio = Array();
1175
  if (is_array( $terms ) ) {
1176
+ $def_prio = $this->get_default_priority( 'taxonomies' );
1177
+ $def_freq = $this->get_default_frequency( 'taxonomies' );
1178
  foreach ($terms as $term) {
1179
+ $pr_info = Array();
1180
+ $pr_info['loc'] = $this->get_term_link( $term, $term->taxonomy );
1181
+ if ( ( $this->options[ $this->prefix . 'prio_taxonomies' ] == 'sel' ) && ( isset( $this->options[ $this->prefix . 'prio_taxonomies_' . $term->taxonomy ] ) ) ) {
1182
+ $pr_info['priority'] = $this->options[ $this->prefix . 'prio_taxonomies_' . $term->taxonomy ];
1183
+ } else $pr_info['priority'] = $def_prio;
1184
+ if ( ( $this->options[ $this->prefix . 'freq_taxonomies' ] == 'sel' ) && ( isset( $this->options[ $this->prefix . 'freq_taxonomies_' . $term->taxonomy ] ) ) ) {
1185
+ $pr_info['changefreq'] = $this->options[ $this->prefix . 'freq_taxonomies_' . $term->taxonomy ];
1186
+ } else $pr_info['changefreq'] = $def_freq;
1187
+ $prio[] = $pr_info;
1188
  }
1189
  }
1190
  return $prio;
1246
  function unparse_url($parsed_url) {
1247
  $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
1248
  $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
1249
+ if ( !empty( $host ) && empty( $scheme ) ) $scheme = '//';
1250
  $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
1251
  $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
1252
  $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
1469
  $pr_info[ 'priority' ] = $prio_override;
1470
  if ( $freq_override )
1471
  $pr_info[ 'changefreq' ] = $freq_override;
1472
+ if ( ( $this->options[ $this->prefix . 'prio_post' ] == 'sel' ) && ( isset( $this->options[ $this->prefix . 'prio_post_' . $post->post_type ] ) ) ) {
1473
+ $pr_info[ 'priority' ] = $this->options[ $this->prefix . 'prio_post_' . $post->post_type ];
1474
+ }
1475
+ if ( ( $this->options[ $this->prefix . 'freq_post' ] == 'sel' ) && ( isset( $this->options[ $this->prefix . 'freq_post_' . $post->post_type ] ) ) ) {
1476
+ $pr_info[ 'changefreq' ] = $this->options[ $this->prefix . 'freq_post_' . $post->post_type ];
1477
+ }
1478
  $pr_info['loc'] = $url;
1479
  $pr_info = apply_filters( $this->prefix . 'prio_item_filter', $pr_info, $post, $args );
1480
  if ( !empty( $pr_info ) )
1625
  if ( !is_array( $args['post_type'] ) || ( count( $args['post_type'] ) == 1 ) ) {
1626
  if ( is_array( $args['post_type'] ) )
1627
  $args['post_type'] = array_shift( $args['post_type'] );
1628
+ $count = (Array)wp_count_posts( $args['post_type'] );
1629
  $post_counts = $count[$status];
1630
  } else
1631
  foreach( $args['post_type'] as $post_type ) {
1632
  if ( $post_type === 'all' ) continue;
1633
  $count = (Array)wp_count_posts( $post_type );
1634
+
1635
  if ( empty( $count ) )
1636
  $post_counts[$post_type] = 0;
1637
  else {
1701
  $ex_args['meta_value'] = 'on';
1702
  $ex_args['meta_compare'] = '=';
1703
  $ex_args['fields'] = 'ids';
1704
+ $ex_args['posts_per_page'] = -1;
1705
  $q = new WP_Query( $ex_args );
1706
  if ( !is_array( $args['exclude'] ) ) $args['exclude'] = explode( ',', $args['exclude'] );
1707
  if ( !empty( $q->posts ) ) $args['exclude'] = array_merge( $args['exclude'], $q->posts );
all_in_one_seo_pack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: All In One SEO Pack
4
  Plugin URI: http://semperfiwebdesign.com
5
  Description: Out-of-the-box SEO for your WordPress blog. <a href="admin.php?page=all-in-one-seo-pack/aioseop_class.php">Options configuration panel</a> | <a href="http://semperplugins.com/plugins/all-in-one-seo-pack-pro-version/?loc=plugins" target="_blank">Upgrade to Pro Version</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8">Donate</a> | <a href="http://semperplugins.com/support/" >Support</a> | <a href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web" target="_blank" title="Amazon Wish List">Amazon Wishlist</a>
6
- Version: 2.1.5.1
7
  Author: Michael Torbert
8
  Author URI: http://michaeltorbert.com
9
  */
@@ -30,11 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30
 
31
  /**
32
  * @package All-in-One-SEO-Pack
33
- * @version 2.1.5.1
34
  */
35
 
36
  if ( ! defined( 'AIOSEOP_VERSION' ) )
37
- define( 'AIOSEOP_VERSION', '2.1.5.1' );
38
 
39
  if ( ! defined( 'AIOSEOP_PLUGIN_DIR' ) ) {
40
  define( 'AIOSEOP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
3
  Plugin Name: All In One SEO Pack
4
  Plugin URI: http://semperfiwebdesign.com
5
  Description: Out-of-the-box SEO for your WordPress blog. <a href="admin.php?page=all-in-one-seo-pack/aioseop_class.php">Options configuration panel</a> | <a href="http://semperplugins.com/plugins/all-in-one-seo-pack-pro-version/?loc=plugins" target="_blank">Upgrade to Pro Version</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8">Donate</a> | <a href="http://semperplugins.com/support/" >Support</a> | <a href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web" target="_blank" title="Amazon Wish List">Amazon Wishlist</a>
6
+ Version: 2.1.7
7
  Author: Michael Torbert
8
  Author URI: http://michaeltorbert.com
9
  */
30
 
31
  /**
32
  * @package All-in-One-SEO-Pack
33
+ * @version 2.1.7
34
  */
35
 
36
  if ( ! defined( 'AIOSEOP_VERSION' ) )
37
+ define( 'AIOSEOP_VERSION', '2.1.7' );
38
 
39
  if ( ! defined( 'AIOSEOP_PLUGIN_DIR' ) ) {
40
  define( 'AIOSEOP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: hallsofmontezuma
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
4
  Tags: all in one, all in one seo, all in one seo pack, seo, search engine optimization, google
5
  Requires at least: 3.3
6
- Tested up to: 3.9
7
  Stable tag: trunk
8
 
9
  All in One SEO Pack is a WordPress SEO plugin to automatically optimize your WordPress blog for Search Engines such as Google.
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
4
  Tags: all in one, all in one seo, all in one seo pack, seo, search engine optimization, google
5
  Requires at least: 3.3
6
+ Tested up to: 3.9.1
7
  Stable tag: trunk
8
 
9
  All in One SEO Pack is a WordPress SEO plugin to automatically optimize your WordPress blog for Search Engines such as Google.