Version Description
Download this release
Release Info
Developer | hallsofmontezuma |
Plugin | All in One SEO Pack |
Version | 2.10 |
Comparing to | |
See all releases |
Code changes from version 2.9.1 to 2.10
- admin/aioseop_module_class.php +3 -3
- aioseop_class.php +188 -212
- all_in_one_seo_pack.php +3 -3
- bin/install-wp-tests.sh +118 -0
- inc/aiosp_common.php +12 -0
- js/count-chars.js +90 -0
- js/modules/aioseop_module.js +0 -56
- js/modules/aioseop_opengraph.js +21 -0
- modules/aioseop_opengraph.php +34 -32
- modules/aioseop_sitemap.php +665 -340
- readme.txt +2 -2
admin/aioseop_module_class.php
CHANGED
@@ -2328,10 +2328,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Module' ) ) {
|
|
2328 |
"<input class='aioseop_upload_image_button button-primary' type='button' value='";
|
2329 |
$buf .= __( 'Upload Image', 'all-in-one-seo-pack' );
|
2330 |
$buf .= "' style='float:left;' />" .
|
2331 |
-
"<input class='aioseop_upload_image_label' name='$name' type='text' $attr value='$value' size=57 style='float:left;clear:left;'>\n";
|
2332 |
break;
|
2333 |
case 'html':
|
2334 |
-
$buf .= $value;
|
2335 |
break;
|
2336 |
case 'esc_html':
|
2337 |
$buf .= '<pre>' . esc_html( $value ) . "</pre>\n";
|
@@ -2341,7 +2341,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Module' ) ) {
|
|
2341 |
wp_enqueue_script( 'jquery-ui-datepicker' );
|
2342 |
// fall through.
|
2343 |
default:
|
2344 |
-
$buf .= "<input name='$name' type='
|
2345 |
}
|
2346 |
if ( ! empty( $options['count'] ) ) {
|
2347 |
$size = 60;
|
2328 |
"<input class='aioseop_upload_image_button button-primary' type='button' value='";
|
2329 |
$buf .= __( 'Upload Image', 'all-in-one-seo-pack' );
|
2330 |
$buf .= "' style='float:left;' />" .
|
2331 |
+
"<input class='aioseop_upload_image_label' name='" . esc_attr( $name ) . "' type='text' " . esc_html( $attr ) . " value='" . esc_attr( $value ) . "' size=57 style='float:left;clear:left;'>\n";
|
2332 |
break;
|
2333 |
case 'html':
|
2334 |
+
$buf .= wp_kses( $value, wp_kses_allowed_html( 'post' ) );
|
2335 |
break;
|
2336 |
case 'esc_html':
|
2337 |
$buf .= '<pre>' . esc_html( $value ) . "</pre>\n";
|
2341 |
wp_enqueue_script( 'jquery-ui-datepicker' );
|
2342 |
// fall through.
|
2343 |
default:
|
2344 |
+
$buf .= "<input name='" . esc_attr( $name ) . "' type='" . esc_attr( $options['type'] ) . "' " . wp_kses( $attr, wp_kses_allowed_html( 'data' ) ) . " value='" . esc_attr( $value ) . "'>\n";
|
2345 |
}
|
2346 |
if ( ! empty( $options['count'] ) ) {
|
2347 |
$size = 60;
|
aioseop_class.php
CHANGED
@@ -104,7 +104,8 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
104 |
__( "%page_author_nicename% - This page's author' nicename", 'all-in-one-seo-pack' ) . '</li><li>' .
|
105 |
__( "%page_author_firstname% - This page's author' first name (capitalized)", 'all-in-one-seo-pack' ) . '</li><li>' .
|
106 |
__( "%page_author_lastname% - This page's author' last name (capitalized)", 'all-in-one-seo-pack' ) . '</li><li>' .
|
107 |
-
__( '%current_date% - The current date (localized)', 'all-in-one-seo-pack' ) . '</li
|
|
|
108 |
'page_title_format' =>
|
109 |
__( 'This controls the format of the title tag for Pages.<br />The following macros are supported:', 'all-in-one-seo-pack' )
|
110 |
. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' .
|
@@ -117,7 +118,8 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
117 |
__( '%current_date% - The current date (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
118 |
__( '%post_date% - The date the page was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
119 |
__( '%post_year% - The year the page was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
120 |
-
__( '%post_month% - The month the page was published (localized)', 'all-in-one-seo-pack' ) . '</li
|
|
|
121 |
'post_title_format' =>
|
122 |
__( 'This controls the format of the title tag for Posts.<br />The following macros are supported:', 'all-in-one-seo-pack' )
|
123 |
. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' .
|
@@ -132,7 +134,8 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
132 |
__( '%current_date% - The current date (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
133 |
__( '%post_date% - The date the post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
134 |
__( '%post_year% - The year the post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
135 |
-
__( '%post_month% - The month the post was published (localized)', 'all-in-one-seo-pack' ) . '</li
|
|
|
136 |
'category_title_format' =>
|
137 |
__( 'This controls the format of the title tag for Category Archives.<br />The following macros are supported:', 'all-in-one-seo-pack' ) .
|
138 |
'<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' .
|
@@ -176,7 +179,8 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
176 |
__( '%current_date% - The current date (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
177 |
__( '%post_date% - The date the page/post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
178 |
__( '%post_year% - The year the page/post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
179 |
-
__( '%post_month% - The month the page/post was published (localized)', 'all-in-one-seo-pack' ) . '</li
|
|
|
180 |
'404_title_format' => __( 'This controls the format of the title tag for the 404 page.<br />The following macros are supported:', 'all-in-one-seo-pack' ) .
|
181 |
'<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' .
|
182 |
__( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' .
|
@@ -186,13 +190,10 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
186 |
'paged_format' => __( 'This string gets appended/prepended to titles of paged index pages (like home or archive pages).', 'all-in-one-seo-pack' )
|
187 |
. __( 'The following macros are supported:', 'all-in-one-seo-pack' )
|
188 |
. '<ul><li>' . __( '%page% - The page number', 'all-in-one-seo-pack' ) . '</li></ul>',
|
189 |
-
'enablecpost' => __( 'Enable this if you want to use All in One SEO Pack with any Content Types on this site. Posts and Pages are enabled by default', 'all-in-one-seo-pack' ),
|
190 |
-
'cpostadvanced' => __( 'This will show or hide the advanced options for SEO for Custom Post Types.', 'all-in-one-seo-pack' ),
|
191 |
'cpostactive' => __( 'Use these checkboxes to select which Content Types you want to use All in One SEO Pack with.', 'all-in-one-seo-pack' ),
|
192 |
'taxactive' => __( 'Use these checkboxes to select which Taxonomies you want to use All in One SEO Pack with.', 'all-in-one-seo-pack' ),
|
193 |
-
'cposttitles' => __( 'This allows you to set the title tags for each Custom Post Type.', 'all-in-one-seo-pack' ),
|
194 |
'posttypecolumns' => __( 'This lets you select which screens display the SEO Title, SEO Keywords and SEO Description columns.', 'all-in-one-seo-pack' ),
|
195 |
-
'google_verify' => __( "Enter your verification code here to verify your site with Google
|
196 |
'bing_verify' => __( "Enter your verification code here to verify your site with Bing Webmaster Tools.<br /><a href='https://semperplugins.com/documentation/bing-webmaster-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all-in-one-seo-pack' ),
|
197 |
'pinterest_verify' => __( "Enter your verification code here to verify your site with Pinterest.<br /><a href='https://semperplugins.com/documentation/pinterest-site-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all-in-one-seo-pack' ),
|
198 |
'google_publisher' => __( 'Enter your Google+ Profile URL here to add the rel=“author” tag to your site for Google authorship. It is recommended that the URL you enter here should be your personal Google+ profile. Use the Advanced Authorship Options below if you want greater control over the use of authorship.', 'all-in-one-seo-pack' ),
|
@@ -271,11 +272,8 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
271 |
'description_format' => '#title-format-fields',
|
272 |
'404_title_format' => '#title-format-fields',
|
273 |
'paged_format' => '#title-format-fields',
|
274 |
-
'enablecpost' => '#seo-for-custom-post-types',
|
275 |
-
'cpostadvanced' => '#enable-advanced-options',
|
276 |
'cpostactive' => '#seo-on-only-these-post-types',
|
277 |
'taxactive' => '#seo-on-only-these-taxonomies',
|
278 |
-
'cposttitles' => '#custom-titles',
|
279 |
'posttypecolumns' => '#show-column-labels-for-custom-post-types',
|
280 |
'google_verify' => '',
|
281 |
'bing_verify' => '',
|
@@ -510,37 +508,15 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
510 |
'default' => ' - Part %page%',
|
511 |
'condshow' => array( 'aiosp_rewrite_titles' => 1 ),
|
512 |
),
|
513 |
-
'enablecpost' => array(
|
514 |
-
'name' => __( 'SEO for Content Types:', 'all-in-one-seo-pack' ),
|
515 |
-
'default' => 'on',
|
516 |
-
'type' => 'radio',
|
517 |
-
'initial_options' => array(
|
518 |
-
'on' => __( 'Enabled', 'all-in-one-seo-pack' ),
|
519 |
-
0 => __( 'Disabled', 'all-in-one-seo-pack' ),
|
520 |
-
),
|
521 |
-
),
|
522 |
'cpostactive' => array(
|
523 |
'name' => __( 'SEO on only these Content Types:', 'all-in-one-seo-pack' ),
|
524 |
'type' => 'multicheckbox',
|
525 |
'default' => array( 'post', 'page' ),
|
526 |
-
'condshow' => array( 'aiosp_enablecpost' => 'on' ),
|
527 |
),
|
528 |
'taxactive' => array(
|
529 |
'name' => __( 'SEO on only these taxonomies:', 'all-in-one-seo-pack' ),
|
530 |
'type' => 'multicheckbox',
|
531 |
'default' => array( 'category', 'post_tag' ),
|
532 |
-
'condshow' => array( 'aiosp_enablecpost' => 'on' ),
|
533 |
-
),
|
534 |
-
'cpostadvanced' => array(
|
535 |
-
'name' => __( 'Enable Advanced Options:', 'all-in-one-seo-pack' ),
|
536 |
-
'default' => 0,
|
537 |
-
'type' => 'radio',
|
538 |
-
'initial_options' => array(
|
539 |
-
'on' => __( 'Enabled', 'all-in-one-seo-pack' ),
|
540 |
-
0 => __( 'Disabled', 'all-in-one-seo-pack' ),
|
541 |
-
),
|
542 |
-
'label' => null,
|
543 |
-
'condshow' => array( 'aiosp_enablecpost' => 'on' ),
|
544 |
),
|
545 |
'cpostnoindex' => array(
|
546 |
'name' => __( 'Default to NOINDEX:', 'all-in-one-seo-pack' ),
|
@@ -552,29 +528,18 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
552 |
'type' => 'multicheckbox',
|
553 |
'default' => array(),
|
554 |
),
|
555 |
-
'cposttitles' => array(
|
556 |
-
'name' => __( 'Custom titles:', 'all-in-one-seo-pack' ),
|
557 |
-
'type' => 'checkbox',
|
558 |
-
'default' => 0,
|
559 |
-
'condshow' => array(
|
560 |
-
'aiosp_rewrite_titles' => 1,
|
561 |
-
'aiosp_enablecpost' => 'on',
|
562 |
-
'aiosp_cpostadvanced' => 'on',
|
563 |
-
),
|
564 |
-
),
|
565 |
'posttypecolumns' => array(
|
566 |
'name' => __( 'Show Column Labels for Custom Post Types:', 'all-in-one-seo-pack' ),
|
567 |
'type' => 'multicheckbox',
|
568 |
'default' => array( 'post', 'page' ),
|
569 |
-
'condshow' => array( 'aiosp_enablecpost' => 'on' ),
|
570 |
),
|
571 |
'google_verify' => array(
|
572 |
-
'name' => __( 'Google
|
573 |
'default' => '',
|
574 |
'type' => 'text',
|
575 |
),
|
576 |
'bing_verify' => array(
|
577 |
-
'name' => __( 'Bing Webmaster
|
578 |
'default' => '',
|
579 |
'type' => 'text',
|
580 |
),
|
@@ -811,7 +776,6 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
811 |
'name' => __( 'Use noindex for Taxonomy Archives:', 'all-in-one-seo-pack' ),
|
812 |
'type' => 'multicheckbox',
|
813 |
'default' => array(),
|
814 |
-
'condshow' => array( 'aiosp_enablecpost' => 'on', 'aiosp_cpostadvanced' => 'on' ),
|
815 |
),
|
816 |
'paginated_noindex' => array(
|
817 |
'name' => __( 'Use noindex for paginated pages/posts:', 'all-in-one-seo-pack' ),
|
@@ -945,18 +909,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
945 |
'name' => __( 'Preview Snippet', 'all-in-one-seo-pack' ),
|
946 |
'type' => 'custom',
|
947 |
'label' => 'top',
|
948 |
-
'default' => '
|
949 |
-
<script>
|
950 |
-
jQuery(document).ready(function() {
|
951 |
-
jQuery("#aiosp_title_wrapper").bind("input", function() {
|
952 |
-
jQuery("#aiosp_snippet_title").text(jQuery("#aiosp_title_wrapper input").val().replace(/<(?:.|\n)*?>/gm, ""));
|
953 |
-
});
|
954 |
-
jQuery("#aiosp_description_wrapper").bind("input", function() {
|
955 |
-
jQuery("#aioseop_snippet_description").text(jQuery("#aiosp_description_wrapper textarea").val().replace(/<(?:.|\n)*?>/gm, ""));
|
956 |
-
});
|
957 |
-
});
|
958 |
-
</script>
|
959 |
-
<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>',
|
960 |
),
|
961 |
'title' => array(
|
962 |
'name' => __( 'Title', 'all-in-one-seo-pack' ),
|
@@ -997,7 +950,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
997 |
),
|
998 |
),
|
999 |
// #1067: if SEO is disabled and an empty array is passed below, it will be overriden. So let's pass a post type that cannot possibly exist.
|
1000 |
-
'display' =>
|
1001 |
),
|
1002 |
);
|
1003 |
|
@@ -1041,7 +994,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
1041 |
'cpt' => array(
|
1042 |
'name' => __( 'Content Type Settings', 'all-in-one-seo-pack' ),
|
1043 |
'help_link' => 'https://semperplugins.com/documentation/custom-post-type-settings/',
|
1044 |
-
'options' => array( '
|
1045 |
),
|
1046 |
'display' => array(
|
1047 |
'name' => __( 'Display Settings', 'all-in-one-seo-pack' ),
|
@@ -1135,7 +1088,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
1135 |
}
|
1136 |
|
1137 |
if ( ! AIOSEOPPRO ) {
|
1138 |
-
unset( $this->layout['cpt']['options']['
|
1139 |
}
|
1140 |
|
1141 |
$other_options = array();
|
@@ -1207,95 +1160,118 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
1207 |
156
|
1208 |
) . '...';
|
1209 |
}
|
1210 |
-
$extra_title_len = 0;
|
1211 |
if ( empty( $title_format ) ) {
|
1212 |
$title = '<span id="' . $args['name'] . '_title">' . esc_attr( wp_strip_all_tags( html_entity_decode( $title ) ) ) . '</span>';
|
1213 |
} else {
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1221 |
}
|
1222 |
-
if ( strpos( $title_format, '%
|
1223 |
-
$title_format = str_replace( '%
|
1224 |
}
|
1225 |
-
if ( strpos( $title_format, '%
|
1226 |
-
$title_format = str_replace( '%
|
1227 |
}
|
1228 |
-
|
1229 |
-
if ( strpos( $title_format,
|
1230 |
-
$title_format = str_replace( '%
|
1231 |
}
|
1232 |
-
if ( strpos( $title_format, '%
|
1233 |
-
$title_format = str_replace( '%
|
1234 |
}
|
1235 |
-
if ( strpos( $title_format, '%
|
1236 |
-
$title_format = str_replace( '%
|
1237 |
}
|
1238 |
-
if (
|
1239 |
-
if (
|
1240 |
-
$
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
}
|
1249 |
-
}
|
1250 |
-
}
|
1251 |
-
if ( strpos( $title_format, '%category_title%' ) !== false ) {
|
1252 |
-
$title_format = str_replace( '%category_title%', $replace_title, $title_format );
|
1253 |
-
}
|
1254 |
-
if ( strpos( $title_format, '%taxonomy_title%' ) !== false ) {
|
1255 |
-
$title_format = str_replace( '%taxonomy_title%', $replace_title, $title_format );
|
1256 |
-
}
|
1257 |
-
} else {
|
1258 |
-
if ( strpos( $title_format, '%category%' ) !== false ) {
|
1259 |
-
$title_format = str_replace( '%category%', $category, $title_format );
|
1260 |
-
}
|
1261 |
-
if ( strpos( $title_format, '%category_title%' ) !== false ) {
|
1262 |
-
$title_format = str_replace( '%category_title%', $category, $title_format );
|
1263 |
-
}
|
1264 |
-
if ( strpos( $title_format, '%taxonomy_title%' ) !== false ) {
|
1265 |
-
$title_format = str_replace( '%taxonomy_title%', $category, $title_format );
|
1266 |
-
}
|
1267 |
-
if ( AIOSEOPPRO ) {
|
1268 |
-
if ( strpos( $title_format, '%tax_' ) && ! empty( $p ) ) {
|
1269 |
-
$taxes = get_object_taxonomies( $p, 'objects' );
|
1270 |
-
if ( ! empty( $taxes ) ) {
|
1271 |
-
foreach ( $taxes as $t ) {
|
1272 |
-
if ( strpos( $title_format, "%tax_{$t->name}%" ) ) {
|
1273 |
-
$terms = $this->get_all_terms( $p->ID, $t->name );
|
1274 |
-
$term = '';
|
1275 |
-
if ( count( $terms ) > 0 ) {
|
1276 |
-
$term = $terms[0];
|
1277 |
-
}
|
1278 |
-
$title_format = str_replace( "%tax_{$t->name}%", $term, $title_format );
|
1279 |
}
|
|
|
1280 |
}
|
1281 |
}
|
1282 |
}
|
1283 |
}
|
1284 |
}
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
$title_format = preg_replace( '/%([^%]*?)%/', '', $title_format );
|
1290 |
-
$title = $title_format;
|
1291 |
-
$extra_title_len = strlen( $this->html_entity_decode( str_replace( $replace_title, '', $title_format ) ) );
|
1292 |
}
|
1293 |
|
1294 |
-
$
|
1295 |
-
$args['value'] .= '<script>var aiosp_title_extra = ' . (int) $extra_title_len . ';</script>';
|
1296 |
-
$buf = $this->get_option_row( $args['name'], $args['options'], $args );
|
1297 |
|
1298 |
-
return $
|
1299 |
}
|
1300 |
|
1301 |
// good candidate for pro dir
|
@@ -2210,16 +2186,16 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
2210 |
if ( isset( $aioseop_options[ "aiosp_{$title_type}_title_format" ] ) ) {
|
2211 |
$title_format = $aioseop_options[ "aiosp_{$title_type}_title_format" ];
|
2212 |
}
|
2213 |
-
|
|
|
2214 |
$wp_post_types = $aioseop_options['aiosp_cpostactive'];
|
2215 |
-
if (
|
2216 |
-
|
2217 |
-
|
2218 |
-
)
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
}
|
2223 |
}
|
2224 |
}
|
2225 |
}
|
@@ -3151,18 +3127,9 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
3151 |
$pt = array_diff( $pt, $rempost );
|
3152 |
$post_types = array();
|
3153 |
|
3154 |
-
$aiosp_enablecpost = '';
|
3155 |
-
if ( isset( $_REQUEST['aiosp_enablecpost'] ) ) {
|
3156 |
-
$aiosp_enablecpost = $_REQUEST['aiosp_enablecpost'];
|
3157 |
-
}
|
3158 |
-
|
3159 |
foreach ( $pt as $p ) {
|
3160 |
if ( ! empty( $post_objs[ $p ]->label ) ) {
|
3161 |
-
|
3162 |
-
$post_types[ $p ] = $post_objs[ $p ]->label;
|
3163 |
-
} elseif ( ! empty( $aioseop_options['aiosp_enablecpost'] ) || $aiosp_enablecpost == 'on' ) {
|
3164 |
-
$post_types[ $p ] = $post_objs[ $p ]->label;
|
3165 |
-
}
|
3166 |
} else {
|
3167 |
$post_types[ $p ] = $p;
|
3168 |
}
|
@@ -3208,9 +3175,6 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
3208 |
'default' => '%post_title% | %blog_title%',
|
3209 |
'condshow' => array(
|
3210 |
'aiosp_rewrite_titles' => 1,
|
3211 |
-
'aiosp_enablecpost' => 'on',
|
3212 |
-
'aiosp_cpostadvanced' => 'on',
|
3213 |
-
'aiosp_cposttitles' => 'on',
|
3214 |
'aiosp_cpostactive\[\]' => $p,
|
3215 |
),
|
3216 |
);
|
@@ -3265,9 +3229,6 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
3265 |
'default' => '%taxonomy_title% | %blog_title%',
|
3266 |
'condshow' => array(
|
3267 |
'aiosp_rewrite_titles' => 1,
|
3268 |
-
'aiosp_enablecpost' => 'on',
|
3269 |
-
'aiosp_cpostadvanced' => 'on',
|
3270 |
-
'aiosp_cposttitles' => 'on',
|
3271 |
'aiosp_taxactive\[\]' => $p,
|
3272 |
),
|
3273 |
);
|
@@ -3335,6 +3296,36 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
3335 |
add_filter( "{$this->prefix}display_settings", array( $this, 'filter_settings' ), 10, 3 );
|
3336 |
add_filter( "{$this->prefix}display_options", array( $this, 'filter_options' ), 10, 2 );
|
3337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3338 |
parent::admin_enqueue_scripts( $hook_suffix );
|
3339 |
}
|
3340 |
|
@@ -3509,9 +3500,6 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
3509 |
if ( isset( $options[ "{$prefix}rewrite_titles" ] ) && ( ! empty( $options[ "{$prefix}rewrite_titles" ] ) ) ) {
|
3510 |
$options[ "{$prefix}rewrite_titles" ] = 1;
|
3511 |
}
|
3512 |
-
if ( isset( $options[ "{$prefix}enablecpost" ] ) && ( $options[ "{$prefix}enablecpost" ] === '' ) ) {
|
3513 |
-
$options[ "{$prefix}enablecpost" ] = 0;
|
3514 |
-
}
|
3515 |
if ( isset( $options[ "{$prefix}use_original_title" ] ) && ( $options[ "{$prefix}use_original_title" ] === '' ) ) {
|
3516 |
$options[ "{$prefix}use_original_title" ] = 0;
|
3517 |
}
|
@@ -3558,40 +3546,34 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
3558 |
if ( ! empty( $post ) && ! empty( $post->post_type ) ) {
|
3559 |
$post_type = $post->post_type;
|
3560 |
}
|
3561 |
-
|
3562 |
-
|
3563 |
-
|
3564 |
-
|
3565 |
-
|
3566 |
-
|
3567 |
-
|
3568 |
-
|
3569 |
-
$wp_post_types = array();
|
3570 |
-
}
|
3571 |
-
if ( AIOSEOPPRO ) {
|
3572 |
-
if ( is_tax() ) {
|
3573 |
-
if ( empty( $aioseop_options['aiosp_taxactive'] ) || ! is_tax( $aioseop_options['aiosp_taxactive'] ) ) {
|
3574 |
-
return false;
|
3575 |
-
}
|
3576 |
-
} elseif ( is_category() ) {
|
3577 |
-
if ( empty( $aioseop_options['aiosp_taxactive'] ) || ! in_array( 'category', $aioseop_options['aiosp_taxactive'] ) ) {
|
3578 |
-
return false;
|
3579 |
-
}
|
3580 |
-
} elseif ( is_tag() ) {
|
3581 |
-
if ( empty( $aioseop_options['aiosp_taxactive'] ) || ! in_array( 'post_tag', $aioseop_options['aiosp_taxactive'] ) ) {
|
3582 |
-
return false;
|
3583 |
-
}
|
3584 |
-
} elseif ( ! in_array( $post_type, $wp_post_types ) && ! is_front_page() && ! is_post_type_archive( $wp_post_types ) && ! is_404() ) {
|
3585 |
return false;
|
3586 |
}
|
3587 |
-
}
|
3588 |
-
|
3589 |
-
if ( is_singular() && ! in_array( $post_type, $wp_post_types ) && ! is_front_page() ) {
|
3590 |
return false;
|
3591 |
}
|
3592 |
-
|
|
|
3593 |
return false;
|
3594 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3595 |
}
|
3596 |
}
|
3597 |
|
@@ -3865,7 +3847,7 @@ class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
|
|
3865 |
*/
|
3866 |
private function is_seo_enabled_for_cpt() {
|
3867 |
global $aioseop_options;
|
3868 |
-
return
|
3869 |
}
|
3870 |
|
3871 |
/**
|
@@ -4937,32 +4919,26 @@ EOF;
|
|
4937 |
$this->filter_pointers();
|
4938 |
}
|
4939 |
|
4940 |
-
if (
|
4941 |
-
if (
|
4942 |
-
|
4943 |
-
|
4944 |
-
|
4945 |
-
|
4946 |
-
}
|
4947 |
|
4948 |
-
|
4949 |
-
|
4950 |
-
|
4951 |
-
|
4952 |
-
|
4953 |
-
}
|
4954 |
}
|
|
|
|
|
|
|
|
|
4955 |
} else {
|
4956 |
-
|
4957 |
-
$this->locations['aiosp']['display'] = $this->options['aiosp_cpostactive'];
|
4958 |
-
} else {
|
4959 |
-
$this->locations['aiosp']['display'] = array();
|
4960 |
-
}
|
4961 |
}
|
4962 |
-
} elseif ( empty( $this->locations['aiosp']['display'] ) ) {
|
4963 |
-
// #1067: if SEO was disabled, it was always displaying for post and page. Because we are now sending an invalid post type '___null___' when SEO is disabled,
|
4964 |
-
// this else will be unreachable. Still keeping it in case there is an undiscovered path that needs this condition.
|
4965 |
-
$this->locations['aiosp']['display'] = array( 'post', 'page' );
|
4966 |
}
|
4967 |
|
4968 |
add_menu_page(
|
104 |
__( "%page_author_nicename% - This page's author' nicename", 'all-in-one-seo-pack' ) . '</li><li>' .
|
105 |
__( "%page_author_firstname% - This page's author' first name (capitalized)", 'all-in-one-seo-pack' ) . '</li><li>' .
|
106 |
__( "%page_author_lastname% - This page's author' last name (capitalized)", 'all-in-one-seo-pack' ) . '</li><li>' .
|
107 |
+
__( '%current_date% - The current date (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
108 |
+
__( '%cf_fieldname% - Custom field name', 'all-in-one-seo-pack' ) . '</li></ul>',
|
109 |
'page_title_format' =>
|
110 |
__( 'This controls the format of the title tag for Pages.<br />The following macros are supported:', 'all-in-one-seo-pack' )
|
111 |
. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' .
|
118 |
__( '%current_date% - The current date (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
119 |
__( '%post_date% - The date the page was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
120 |
__( '%post_year% - The year the page was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
121 |
+
__( '%post_month% - The month the page was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
122 |
+
__( '%cf_fieldname% - Custom field name', 'all-in-one-seo-pack' ) . '</li></ul>',
|
123 |
'post_title_format' =>
|
124 |
__( 'This controls the format of the title tag for Posts.<br />The following macros are supported:', 'all-in-one-seo-pack' )
|
125 |
. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' .
|
134 |
__( '%current_date% - The current date (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
135 |
__( '%post_date% - The date the post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
136 |
__( '%post_year% - The year the post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
137 |
+
__( '%post_month% - The month the post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
138 |
+
__( '%cf_fieldname% - Custom field name', 'all-in-one-seo-pack' ) . '</li></ul>',
|
139 |
'category_title_format' =>
|
140 |
__( 'This controls the format of the title tag for Category Archives.<br />The following macros are supported:', 'all-in-one-seo-pack' ) .
|
141 |
'<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' .
|
179 |
__( '%current_date% - The current date (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
180 |
__( '%post_date% - The date the page/post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
181 |
__( '%post_year% - The year the page/post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
182 |
+
__( '%post_month% - The month the page/post was published (localized)', 'all-in-one-seo-pack' ) . '</li><li>' .
|
183 |
+
__( '%cf_fieldname% - Custom field name', 'all-in-one-seo-pack' ) . '</li></ul>',
|
184 |
'404_title_format' => __( 'This controls the format of the title tag for the 404 page.<br />The following macros are supported:', 'all-in-one-seo-pack' ) .
|
185 |
'<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' .
|
186 |
__( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' .
|
190 |
'paged_format' => __( 'This string gets appended/prepended to titles of paged index pages (like home or archive pages).', 'all-in-one-seo-pack' )
|
191 |
. __( 'The following macros are supported:', 'all-in-one-seo-pack' )
|
192 |
. '<ul><li>' . __( '%page% - The page number', 'all-in-one-seo-pack' ) . '</li></ul>',
|
|
|
|
|
193 |
'cpostactive' => __( 'Use these checkboxes to select which Content Types you want to use All in One SEO Pack with.', 'all-in-one-seo-pack' ),
|
194 |
'taxactive' => __( 'Use these checkboxes to select which Taxonomies you want to use All in One SEO Pack with.', 'all-in-one-seo-pack' ),
|
|
|
195 |
'posttypecolumns' => __( 'This lets you select which screens display the SEO Title, SEO Keywords and SEO Description columns.', 'all-in-one-seo-pack' ),
|
196 |
+
'google_verify' => __( "Enter your verification code here to verify your site with Google Search Console.<br /><a href='https://semperplugins.com/documentation/google-webmaster-tools-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all-in-one-seo-pack' ),
|
197 |
'bing_verify' => __( "Enter your verification code here to verify your site with Bing Webmaster Tools.<br /><a href='https://semperplugins.com/documentation/bing-webmaster-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all-in-one-seo-pack' ),
|
198 |
'pinterest_verify' => __( "Enter your verification code here to verify your site with Pinterest.<br /><a href='https://semperplugins.com/documentation/pinterest-site-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all-in-one-seo-pack' ),
|
199 |
'google_publisher' => __( 'Enter your Google+ Profile URL here to add the rel=“author” tag to your site for Google authorship. It is recommended that the URL you enter here should be your personal Google+ profile. Use the Advanced Authorship Options below if you want greater control over the use of authorship.', 'all-in-one-seo-pack' ),
|
272 |
'description_format' => '#title-format-fields',
|
273 |
'404_title_format' => '#title-format-fields',
|
274 |
'paged_format' => '#title-format-fields',
|
|
|
|
|
275 |
'cpostactive' => '#seo-on-only-these-post-types',
|
276 |
'taxactive' => '#seo-on-only-these-taxonomies',
|
|
|
277 |
'posttypecolumns' => '#show-column-labels-for-custom-post-types',
|
278 |
'google_verify' => '',
|
279 |
'bing_verify' => '',
|
508 |
'default' => ' - Part %page%',
|
509 |
'condshow' => array( 'aiosp_rewrite_titles' => 1 ),
|
510 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
511 |
'cpostactive' => array(
|
512 |
'name' => __( 'SEO on only these Content Types:', 'all-in-one-seo-pack' ),
|
513 |
'type' => 'multicheckbox',
|
514 |
'default' => array( 'post', 'page' ),
|
|
|
515 |
),
|
516 |
'taxactive' => array(
|
517 |
'name' => __( 'SEO on only these taxonomies:', 'all-in-one-seo-pack' ),
|
518 |
'type' => 'multicheckbox',
|
519 |
'default' => array( 'category', 'post_tag' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
),
|
521 |
'cpostnoindex' => array(
|
522 |
'name' => __( 'Default to NOINDEX:', 'all-in-one-seo-pack' ),
|
528 |
'type' => 'multicheckbox',
|
529 |
'default' => array(),
|
530 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
531 |
'posttypecolumns' => array(
|
532 |
'name' => __( 'Show Column Labels for Custom Post Types:', 'all-in-one-seo-pack' ),
|
533 |
'type' => 'multicheckbox',
|
534 |
'default' => array( 'post', 'page' ),
|
|
|
535 |
),
|
536 |
'google_verify' => array(
|
537 |
+
'name' => __( 'Google Search Console:', 'all-in-one-seo-pack' ),
|
538 |
'default' => '',
|
539 |
'type' => 'text',
|
540 |
),
|
541 |
'bing_verify' => array(
|
542 |
+
'name' => __( 'Bing Webmaster Tools:', 'all-in-one-seo-pack' ),
|
543 |
'default' => '',
|
544 |
'type' => 'text',
|
545 |
),
|
776 |
'name' => __( 'Use noindex for Taxonomy Archives:', 'all-in-one-seo-pack' ),
|
777 |
'type' => 'multicheckbox',
|
778 |
'default' => array(),
|
|
|
779 |
),
|
780 |
'paginated_noindex' => array(
|
781 |
'name' => __( 'Use noindex for paginated pages/posts:', 'all-in-one-seo-pack' ),
|
909 |
'name' => __( 'Preview Snippet', 'all-in-one-seo-pack' ),
|
910 |
'type' => 'custom',
|
911 |
'label' => 'top',
|
912 |
+
'default' => '<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>',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
913 |
),
|
914 |
'title' => array(
|
915 |
'name' => __( 'Title', 'all-in-one-seo-pack' ),
|
950 |
),
|
951 |
),
|
952 |
// #1067: if SEO is disabled and an empty array is passed below, it will be overriden. So let's pass a post type that cannot possibly exist.
|
953 |
+
'display' => $aioseop_options['aiosp_cpostactive'],
|
954 |
),
|
955 |
);
|
956 |
|
994 |
'cpt' => array(
|
995 |
'name' => __( 'Content Type Settings', 'all-in-one-seo-pack' ),
|
996 |
'help_link' => 'https://semperplugins.com/documentation/custom-post-type-settings/',
|
997 |
+
'options' => array( 'taxactive', 'cpostactive' ),
|
998 |
),
|
999 |
'display' => array(
|
1000 |
'name' => __( 'Display Settings', 'all-in-one-seo-pack' ),
|
1088 |
}
|
1089 |
|
1090 |
if ( ! AIOSEOPPRO ) {
|
1091 |
+
unset( $this->layout['cpt']['options']['0'] );
|
1092 |
}
|
1093 |
|
1094 |
$other_options = array();
|
1160 |
156
|
1161 |
) . '...';
|
1162 |
}
|
|
|
1163 |
if ( empty( $title_format ) ) {
|
1164 |
$title = '<span id="' . $args['name'] . '_title">' . esc_attr( wp_strip_all_tags( html_entity_decode( $title ) ) ) . '</span>';
|
1165 |
} else {
|
1166 |
+
$title_format = $this->get_title_format( $args );
|
1167 |
+
$title = $title_format;
|
1168 |
+
}
|
1169 |
+
|
1170 |
+
$args['value'] = sprintf( $args['value'], $title, esc_url( $url ), esc_attr( $description ) );
|
1171 |
+
$buf = $this->get_option_row( $args['name'], $args['options'], $args );
|
1172 |
+
|
1173 |
+
return $buf;
|
1174 |
+
}
|
1175 |
+
|
1176 |
+
/**
|
1177 |
+
* Get Title Format
|
1178 |
+
*
|
1179 |
+
* Get the title formatted according to AIOSEOP %shortcodes%.
|
1180 |
+
*
|
1181 |
+
* @since 2.4.9
|
1182 |
+
*
|
1183 |
+
* @param array $args
|
1184 |
+
* @return mixed
|
1185 |
+
*/
|
1186 |
+
public function get_title_format( $args ) {
|
1187 |
+
$info = $this->get_page_snippet_info();
|
1188 |
+
$title = $info['title'];
|
1189 |
+
$description = $info['description'];
|
1190 |
+
$keywords = $info['keywords'];
|
1191 |
+
$url = $info['url'];
|
1192 |
+
$title_format = $info['title_format'];
|
1193 |
+
$category = $info['category'];
|
1194 |
+
$w = $info['w'];
|
1195 |
+
$p = $info['p'];
|
1196 |
+
|
1197 |
+
if ( strpos( $title_format, '%blog_title%' ) !== false ) {
|
1198 |
+
$title_format = str_replace( '%blog_title%', get_bloginfo( 'name' ), $title_format );
|
1199 |
+
}
|
1200 |
+
$title_format = $this->apply_cf_fields( $title_format );
|
1201 |
+
$replace_title = '<span id="' . $args['name'] . '_title">' . esc_attr( wp_strip_all_tags( html_entity_decode( $title ) ) ) . '</span>';
|
1202 |
+
if ( strpos( $title_format, '%post_title%' ) !== false ) {
|
1203 |
+
$title_format = str_replace( '%post_title%', $replace_title, $title_format );
|
1204 |
+
}
|
1205 |
+
if ( strpos( $title_format, '%page_title%' ) !== false ) {
|
1206 |
+
$title_format = str_replace( '%page_title%', $replace_title, $title_format );
|
1207 |
+
}
|
1208 |
+
if ( strpos( $title_format, '%current_date%' ) !== false ) {
|
1209 |
+
$title_format = str_replace( '%current_date%', aioseop_formatted_date(), $title_format );
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
if ( strpos( $title_format, "%post_date%" ) !== false ){
|
1213 |
+
$title_format = str_replace( '%post_date%', aioseop_formatted_date( get_the_time( 'U' ) ), $title_format );
|
1214 |
+
}
|
1215 |
+
if ( strpos( $title_format, '%post_year%' ) !== false ) {
|
1216 |
+
$title_format = str_replace( '%post_year%', get_the_date( 'Y' ), $title_format );
|
1217 |
+
}
|
1218 |
+
if ( strpos( $title_format, '%post_month%' ) !== false ) {
|
1219 |
+
$title_format = str_replace( '%post_month%', get_the_date( 'F' ), $title_format );
|
1220 |
+
}
|
1221 |
+
if ( $w->is_category || $w->is_tag || $w->is_tax ) {
|
1222 |
+
if ( AIOSEOPPRO && ! empty( $_GET ) && ! empty( $_GET['taxonomy'] ) && ! empty( $_GET['tag_ID'] ) && function_exists( 'wp_get_split_terms' ) ) {
|
1223 |
+
$term_id = intval( $_GET['tag_ID'] );
|
1224 |
+
$was_split = get_term_meta( $term_id, '_aioseop_term_was_split', true );
|
1225 |
+
if ( ! $was_split ) {
|
1226 |
+
$split_terms = wp_get_split_terms( $term_id, $_GET['taxonomy'] );
|
1227 |
+
if ( ! empty( $split_terms ) ) {
|
1228 |
+
foreach ( $split_terms as $new_tax => $new_term ) {
|
1229 |
+
$this->split_shared_term( $term_id, $new_term );
|
1230 |
+
}
|
1231 |
+
}
|
1232 |
+
}
|
1233 |
}
|
1234 |
+
if ( strpos( $title_format, '%category_title%' ) !== false ) {
|
1235 |
+
$title_format = str_replace( '%category_title%', $replace_title, $title_format );
|
1236 |
}
|
1237 |
+
if ( strpos( $title_format, '%taxonomy_title%' ) !== false ) {
|
1238 |
+
$title_format = str_replace( '%taxonomy_title%', $replace_title, $title_format );
|
1239 |
}
|
1240 |
+
} else {
|
1241 |
+
if ( strpos( $title_format, '%category%' ) !== false ) {
|
1242 |
+
$title_format = str_replace( '%category%', $category, $title_format );
|
1243 |
}
|
1244 |
+
if ( strpos( $title_format, '%category_title%' ) !== false ) {
|
1245 |
+
$title_format = str_replace( '%category_title%', $category, $title_format );
|
1246 |
}
|
1247 |
+
if ( strpos( $title_format, '%taxonomy_title%' ) !== false ) {
|
1248 |
+
$title_format = str_replace( '%taxonomy_title%', $category, $title_format );
|
1249 |
}
|
1250 |
+
if ( AIOSEOPPRO ) {
|
1251 |
+
if ( strpos( $title_format, '%tax_' ) && ! empty( $p ) ) {
|
1252 |
+
$taxes = get_object_taxonomies( $p, 'objects' );
|
1253 |
+
if ( ! empty( $taxes ) ) {
|
1254 |
+
foreach ( $taxes as $t ) {
|
1255 |
+
if ( strpos( $title_format, "%tax_{$t->name}%" ) ) {
|
1256 |
+
$terms = $this->get_all_terms( $p->ID, $t->name );
|
1257 |
+
$term = '';
|
1258 |
+
if ( count( $terms ) > 0 ) {
|
1259 |
+
$term = $terms[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1260 |
}
|
1261 |
+
$title_format = str_replace( "%tax_{$t->name}%", $term, $title_format );
|
1262 |
}
|
1263 |
}
|
1264 |
}
|
1265 |
}
|
1266 |
}
|
1267 |
+
}
|
1268 |
+
if ( strpos( $title_format, '%taxonomy_description%' ) !== false ) {
|
1269 |
+
$title_format = str_replace( '%taxonomy_description%', $description, $title_format );
|
|
|
|
|
|
|
|
|
1270 |
}
|
1271 |
|
1272 |
+
$title_format = preg_replace( '/%([^%]*?)%/', '', $title_format );
|
|
|
|
|
1273 |
|
1274 |
+
return $title_format;
|
1275 |
}
|
1276 |
|
1277 |
// good candidate for pro dir
|
2186 |
if ( isset( $aioseop_options[ "aiosp_{$title_type}_title_format" ] ) ) {
|
2187 |
$title_format = $aioseop_options[ "aiosp_{$title_type}_title_format" ];
|
2188 |
}
|
2189 |
+
|
2190 |
+
if ( ! empty( $aioseop_options['aiosp_cpostactive'] ) ) {
|
2191 |
$wp_post_types = $aioseop_options['aiosp_cpostactive'];
|
2192 |
+
if ( ( ( $title_type == 'archive' ) && is_post_type_archive( $wp_post_types ) && $prefix = "aiosp_{$title_type}_" ) ||
|
2193 |
+
( ( $title_type == 'post' ) && $this->is_singular( $wp_post_types, $p ) && $prefix = 'aiosp_' )
|
2194 |
+
) {
|
2195 |
+
$post_type = get_post_type( $p );
|
2196 |
+
|
2197 |
+
if ( ! empty( $aioseop_options[ "{$prefix}{$post_type}_title_format" ] ) ) {
|
2198 |
+
$title_format = $aioseop_options[ "{$prefix}{$post_type}_title_format" ];
|
|
|
2199 |
}
|
2200 |
}
|
2201 |
}
|
3127 |
$pt = array_diff( $pt, $rempost );
|
3128 |
$post_types = array();
|
3129 |
|
|
|
|
|
|
|
|
|
|
|
3130 |
foreach ( $pt as $p ) {
|
3131 |
if ( ! empty( $post_objs[ $p ]->label ) ) {
|
3132 |
+
$post_types[ $p ] = $post_objs[ $p ]->label;
|
|
|
|
|
|
|
|
|
3133 |
} else {
|
3134 |
$post_types[ $p ] = $p;
|
3135 |
}
|
3175 |
'default' => '%post_title% | %blog_title%',
|
3176 |
'condshow' => array(
|
3177 |
'aiosp_rewrite_titles' => 1,
|
|
|
|
|
|
|
3178 |
'aiosp_cpostactive\[\]' => $p,
|
3179 |
),
|
3180 |
);
|
3229 |
'default' => '%taxonomy_title% | %blog_title%',
|
3230 |
'condshow' => array(
|
3231 |
'aiosp_rewrite_titles' => 1,
|
|
|
|
|
|
|
3232 |
'aiosp_taxactive\[\]' => $p,
|
3233 |
),
|
3234 |
);
|
3296 |
add_filter( "{$this->prefix}display_settings", array( $this, 'filter_settings' ), 10, 3 );
|
3297 |
add_filter( "{$this->prefix}display_options", array( $this, 'filter_options' ), 10, 2 );
|
3298 |
|
3299 |
+
// This ensures different JS files are enqueued only at the intended screens. Preventing unnecessary processes.
|
3300 |
+
$extra_title_len = 0;
|
3301 |
+
switch ( $hook_suffix ) {
|
3302 |
+
// Screens `post.php`, `post-new.php`, & `../aioseop_class.php` share the same `count-char.js`.
|
3303 |
+
case 'post.php' :
|
3304 |
+
case 'post-new.php' :
|
3305 |
+
$info = $this->get_page_snippet_info();
|
3306 |
+
$title = $info['title'];
|
3307 |
+
$title_format = $this->get_title_format( array( 'name' => 'aiosp_snippet' ) );
|
3308 |
+
|
3309 |
+
if ( ! empty( $title_format ) ) {
|
3310 |
+
$replace_title = '<span id="aiosp_snippet_title">' . esc_attr( wp_strip_all_tags( html_entity_decode( $title ) ) ) . '</span>';
|
3311 |
+
$extra_title_len = strlen( $this->html_entity_decode( str_replace( $replace_title, '', $title_format ) ) );
|
3312 |
+
}
|
3313 |
+
// Fall through.
|
3314 |
+
case 'toplevel_page_all-in-one-seo-pack/aioseop_class' :
|
3315 |
+
wp_enqueue_script(
|
3316 |
+
'aioseop-post-edit-script',
|
3317 |
+
AIOSEOP_PLUGIN_URL . 'js/count-chars.js',
|
3318 |
+
array(),
|
3319 |
+
AIOSEOP_VERSION
|
3320 |
+
);
|
3321 |
+
|
3322 |
+
$localize_post_edit = array(
|
3323 |
+
'aiosp_title_extra' => (int) $extra_title_len,
|
3324 |
+
);
|
3325 |
+
wp_localize_script( 'aioseop-post-edit-script', 'aioseop_count_chars', $localize_post_edit );
|
3326 |
+
break;
|
3327 |
+
}
|
3328 |
+
|
3329 |
parent::admin_enqueue_scripts( $hook_suffix );
|
3330 |
}
|
3331 |
|
3500 |
if ( isset( $options[ "{$prefix}rewrite_titles" ] ) && ( ! empty( $options[ "{$prefix}rewrite_titles" ] ) ) ) {
|
3501 |
$options[ "{$prefix}rewrite_titles" ] = 1;
|
3502 |
}
|
|
|
|
|
|
|
3503 |
if ( isset( $options[ "{$prefix}use_original_title" ] ) && ( $options[ "{$prefix}use_original_title" ] === '' ) ) {
|
3504 |
$options[ "{$prefix}use_original_title" ] = 0;
|
3505 |
}
|
3546 |
if ( ! empty( $post ) && ! empty( $post->post_type ) ) {
|
3547 |
$post_type = $post->post_type;
|
3548 |
}
|
3549 |
+
|
3550 |
+
$wp_post_types = $aioseop_options['aiosp_cpostactive'];
|
3551 |
+
if ( empty( $wp_post_types ) ) {
|
3552 |
+
$wp_post_types = array();
|
3553 |
+
}
|
3554 |
+
if ( AIOSEOPPRO ) {
|
3555 |
+
if ( is_tax() ) {
|
3556 |
+
if ( empty( $aioseop_options['aiosp_taxactive'] ) || ! is_tax( $aioseop_options['aiosp_taxactive'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3557 |
return false;
|
3558 |
}
|
3559 |
+
} elseif ( is_category() ) {
|
3560 |
+
if ( empty( $aioseop_options['aiosp_taxactive'] ) || ! in_array( 'category', $aioseop_options['aiosp_taxactive'] ) ) {
|
|
|
3561 |
return false;
|
3562 |
}
|
3563 |
+
} elseif ( is_tag() ) {
|
3564 |
+
if ( empty( $aioseop_options['aiosp_taxactive'] ) || ! in_array( 'post_tag', $aioseop_options['aiosp_taxactive'] ) ) {
|
3565 |
return false;
|
3566 |
}
|
3567 |
+
} elseif ( ! in_array( $post_type, $wp_post_types ) && ! is_front_page() && ! is_post_type_archive( $wp_post_types ) && ! is_404() ) {
|
3568 |
+
return false;
|
3569 |
+
}
|
3570 |
+
} else {
|
3571 |
+
|
3572 |
+
if ( is_singular() && ! in_array( $post_type, $wp_post_types ) && ! is_front_page() ) {
|
3573 |
+
return false;
|
3574 |
+
}
|
3575 |
+
if ( is_post_type_archive() && ! is_post_type_archive( $wp_post_types ) ) {
|
3576 |
+
return false;
|
3577 |
}
|
3578 |
}
|
3579 |
|
3847 |
*/
|
3848 |
private function is_seo_enabled_for_cpt() {
|
3849 |
global $aioseop_options;
|
3850 |
+
return empty( $post_type ) || in_array( get_post_type(), $aioseop_options['aiosp_cpostactive'], true );
|
3851 |
}
|
3852 |
|
3853 |
/**
|
4919 |
$this->filter_pointers();
|
4920 |
}
|
4921 |
|
4922 |
+
if ( AIOSEOPPRO ) {
|
4923 |
+
if ( is_array( $this->options['aiosp_cpostactive'] ) ) {
|
4924 |
+
$this->locations['aiosp']['display'] = $this->options['aiosp_cpostactive'];
|
4925 |
+
} else {
|
4926 |
+
$this->locations['aiosp']['display'][] = $this->options['aiosp_cpostactive']; // Store as an array in case there are taxonomies to add also.
|
4927 |
+
}
|
|
|
4928 |
|
4929 |
+
if ( ! empty( $this->options['aiosp_taxactive'] ) ) {
|
4930 |
+
foreach ( $this->options['aiosp_taxactive'] as $tax ) {
|
4931 |
+
$this->locations['aiosp']['display'][] = 'edit-' . $tax;
|
4932 |
+
add_action( "{$tax}_edit_form", array( $this, 'display_category_metaboxes' ) );
|
4933 |
+
add_action( "edited_{$tax}", array( $this, 'save_category_metaboxes' ) );
|
|
|
4934 |
}
|
4935 |
+
}
|
4936 |
+
} else {
|
4937 |
+
if ( ! empty( $this->options['aiosp_cpostactive'] ) ) {
|
4938 |
+
$this->locations['aiosp']['display'] = $this->options['aiosp_cpostactive'];
|
4939 |
} else {
|
4940 |
+
$this->locations['aiosp']['display'] = array();
|
|
|
|
|
|
|
|
|
4941 |
}
|
|
|
|
|
|
|
|
|
4942 |
}
|
4943 |
|
4944 |
add_menu_page(
|
all_in_one_seo_pack.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: All In One SEO Pack
|
5 |
Plugin URI: https://semperplugins.com/all-in-one-seo-pack-pro-version/
|
6 |
Description: Out-of-the-box SEO for your WordPress blog. Features like XML Sitemaps, SEO for custom post types, SEO for blogs or business sites, SEO for ecommerce sites, and much more. More than 50 million downloads since 2007.
|
7 |
-
Version: 2.
|
8 |
Author: Michael Torbert
|
9 |
Author URI: https://semperplugins.com/all-in-one-seo-pack-pro-version/
|
10 |
Text Domain: all-in-one-seo-pack
|
@@ -32,14 +32,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32 |
* The original WordPress SEO plugin.
|
33 |
*
|
34 |
* @package All-in-One-SEO-Pack
|
35 |
-
* @version 2.
|
36 |
*/
|
37 |
|
38 |
if ( ! defined( 'AIOSEOPPRO' ) ) {
|
39 |
define( 'AIOSEOPPRO', false );
|
40 |
}
|
41 |
if ( ! defined( 'AIOSEOP_VERSION' ) ) {
|
42 |
-
define( 'AIOSEOP_VERSION', '2.
|
43 |
}
|
44 |
global $aioseop_plugin_name;
|
45 |
$aioseop_plugin_name = 'All in One SEO Pack';
|
4 |
Plugin Name: All In One SEO Pack
|
5 |
Plugin URI: https://semperplugins.com/all-in-one-seo-pack-pro-version/
|
6 |
Description: Out-of-the-box SEO for your WordPress blog. Features like XML Sitemaps, SEO for custom post types, SEO for blogs or business sites, SEO for ecommerce sites, and much more. More than 50 million downloads since 2007.
|
7 |
+
Version: 2.10
|
8 |
Author: Michael Torbert
|
9 |
Author URI: https://semperplugins.com/all-in-one-seo-pack-pro-version/
|
10 |
Text Domain: all-in-one-seo-pack
|
32 |
* The original WordPress SEO plugin.
|
33 |
*
|
34 |
* @package All-in-One-SEO-Pack
|
35 |
+
* @version 2.10
|
36 |
*/
|
37 |
|
38 |
if ( ! defined( 'AIOSEOPPRO' ) ) {
|
39 |
define( 'AIOSEOPPRO', false );
|
40 |
}
|
41 |
if ( ! defined( 'AIOSEOP_VERSION' ) ) {
|
42 |
+
define( 'AIOSEOP_VERSION', '2.10' );
|
43 |
}
|
44 |
global $aioseop_plugin_name;
|
45 |
$aioseop_plugin_name = 'All in One SEO Pack';
|
bin/install-wp-tests.sh
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
if [ $# -lt 3 ]; then
|
4 |
+
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
|
5 |
+
exit 1
|
6 |
+
fi
|
7 |
+
|
8 |
+
DB_NAME=$1
|
9 |
+
DB_USER=$2
|
10 |
+
DB_PASS=$3
|
11 |
+
DB_HOST=${4-localhost}
|
12 |
+
WP_VERSION=${5-latest}
|
13 |
+
|
14 |
+
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
|
15 |
+
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
|
16 |
+
|
17 |
+
download() {
|
18 |
+
if [ `which curl` ]; then
|
19 |
+
curl -s "$1" > "$2";
|
20 |
+
elif [ `which wget` ]; then
|
21 |
+
wget -nv -O "$2" "$1"
|
22 |
+
fi
|
23 |
+
}
|
24 |
+
|
25 |
+
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
|
26 |
+
WP_TESTS_TAG="tags/$WP_VERSION"
|
27 |
+
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
28 |
+
WP_TESTS_TAG="trunk"
|
29 |
+
else
|
30 |
+
# http serves a single offer, whereas https serves multiple. we only want one
|
31 |
+
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
|
32 |
+
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
|
33 |
+
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
|
34 |
+
if [[ -z "$LATEST_VERSION" ]]; then
|
35 |
+
echo "Latest WordPress version could not be found"
|
36 |
+
exit 1
|
37 |
+
fi
|
38 |
+
WP_TESTS_TAG="tags/$LATEST_VERSION"
|
39 |
+
fi
|
40 |
+
|
41 |
+
set -ex
|
42 |
+
|
43 |
+
install_wp() {
|
44 |
+
|
45 |
+
if [ -d $WP_CORE_DIR ]; then
|
46 |
+
return;
|
47 |
+
fi
|
48 |
+
|
49 |
+
mkdir -p $WP_CORE_DIR
|
50 |
+
|
51 |
+
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
52 |
+
mkdir -p /tmp/wordpress-nightly
|
53 |
+
download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
|
54 |
+
unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
|
55 |
+
mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
|
56 |
+
else
|
57 |
+
if [ $WP_VERSION == 'latest' ]; then
|
58 |
+
local ARCHIVE_NAME='latest'
|
59 |
+
else
|
60 |
+
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
61 |
+
fi
|
62 |
+
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
|
63 |
+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
64 |
+
fi
|
65 |
+
|
66 |
+
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
|
67 |
+
}
|
68 |
+
|
69 |
+
install_test_suite() {
|
70 |
+
# portable in-place argument for both GNU sed and Mac OSX sed
|
71 |
+
if [[ $(uname -s) == 'Darwin' ]]; then
|
72 |
+
local ioption='-i .bak'
|
73 |
+
else
|
74 |
+
local ioption='-i'
|
75 |
+
fi
|
76 |
+
|
77 |
+
# set up testing suite if it doesn't yet exist
|
78 |
+
if [ ! -d $WP_TESTS_DIR ]; then
|
79 |
+
# set up testing suite
|
80 |
+
mkdir -p $WP_TESTS_DIR
|
81 |
+
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
|
82 |
+
fi
|
83 |
+
|
84 |
+
if [ ! -f wp-tests-config.php ]; then
|
85 |
+
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
|
86 |
+
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php
|
87 |
+
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
|
88 |
+
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
|
89 |
+
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
|
90 |
+
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
|
91 |
+
fi
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
install_db() {
|
96 |
+
# parse DB_HOST for port or socket references
|
97 |
+
local PARTS=(${DB_HOST//\:/ })
|
98 |
+
local DB_HOSTNAME=${PARTS[0]};
|
99 |
+
local DB_SOCK_OR_PORT=${PARTS[1]};
|
100 |
+
local EXTRA=""
|
101 |
+
|
102 |
+
if ! [ -z $DB_HOSTNAME ] ; then
|
103 |
+
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
|
104 |
+
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
|
105 |
+
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
|
106 |
+
EXTRA=" --socket=$DB_SOCK_OR_PORT"
|
107 |
+
elif ! [ -z $DB_HOSTNAME ] ; then
|
108 |
+
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
|
109 |
+
fi
|
110 |
+
fi
|
111 |
+
|
112 |
+
# create database
|
113 |
+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
|
114 |
+
}
|
115 |
+
|
116 |
+
install_wp
|
117 |
+
install_test_suite
|
118 |
+
install_db
|
inc/aiosp_common.php
CHANGED
@@ -170,4 +170,16 @@ class aiosp_common {
|
|
170 |
return filter_var( filter_var( $url, FILTER_SANITIZE_URL ), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED ) !== false;
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
}
|
170 |
return filter_var( filter_var( $url, FILTER_SANITIZE_URL ), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED ) !== false;
|
171 |
}
|
172 |
|
173 |
+
/**
|
174 |
+
* Renders the value XML safe.
|
175 |
+
*/
|
176 |
+
public static function make_xml_safe( $tag, $value ) {
|
177 |
+
if ( in_array( $tag, array( 'guid', 'link', 'loc', 'image:loc' ) ) ) {
|
178 |
+
$value = esc_url( $value );
|
179 |
+
} else if( ! is_array( $value ) ) {
|
180 |
+
$value = htmlspecialchars( $value, ENT_QUOTES );
|
181 |
+
}
|
182 |
+
return $value;
|
183 |
+
}
|
184 |
+
|
185 |
}
|
js/count-chars.js
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Script for Counting Characters
|
3 |
+
*
|
4 |
+
* @summary Binds input elements and counts characters for Title and Description on Post Edit, Post New,
|
5 |
+
* & AIOSEOP General Settings screens.
|
6 |
+
*
|
7 |
+
* @author Michael Torbert.
|
8 |
+
* @author Semper Fi Web Design.
|
9 |
+
* @copyright https://semperplugins.com
|
10 |
+
* @version 2.9.2
|
11 |
+
*/
|
12 |
+
|
13 |
+
var aiosp_title_extra = parseInt( aioseop_count_chars.aiosp_title_extra );
|
14 |
+
|
15 |
+
jQuery( document ).ready( function() {
|
16 |
+
aioseopInitCounting();
|
17 |
+
});
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Preview Snippet
|
21 |
+
*
|
22 |
+
* @since ?
|
23 |
+
* @since 2.9.2 Move from PHP value to JS file
|
24 |
+
*/
|
25 |
+
jQuery(document).ready( function() {
|
26 |
+
jQuery("#aiosp_title_wrapper").bind("input", function() {
|
27 |
+
jQuery("#aiosp_snippet_title").text(jQuery("#aiosp_title_wrapper input").val().replace(/<(?:.|\n)*?>/gm, ""));
|
28 |
+
});
|
29 |
+
jQuery("#aiosp_description_wrapper").bind("input", function() {
|
30 |
+
jQuery("#aioseop_snippet_description").text(jQuery("#aiosp_description_wrapper textarea").val().replace(/<(?:.|\n)*?>/gm, ""));
|
31 |
+
});
|
32 |
+
});
|
33 |
+
|
34 |
+
/**
|
35 |
+
* AIOSEOP Init Counting
|
36 |
+
*
|
37 |
+
* @since ?
|
38 |
+
*/
|
39 |
+
function aioseopInitCounting(){
|
40 |
+
/* count them characters */
|
41 |
+
jQuery( '.aioseop_count_chars' ).on('keyup keydown', function(){
|
42 |
+
aioseopCountChars( jQuery(this).eq(0), jQuery(this).parent().find('[name="' + jQuery(this).attr('data-length-field') + '"]').eq(0));
|
43 |
+
});
|
44 |
+
jQuery( '.aioseop_count_chars' ).each(function(){
|
45 |
+
aioseopCountChars( jQuery(this).eq(0), jQuery(this).parent().find('[name="' + jQuery(this).attr('data-length-field') + '"]').eq(0));
|
46 |
+
});
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @summary Counts characters.
|
51 |
+
*
|
52 |
+
* @since 1.0.0
|
53 |
+
* @since 2.9.1 Fix JS conflict with LearnDash and function name.
|
54 |
+
*
|
55 |
+
* @param Object $field.
|
56 |
+
* @param Object $cntfield.
|
57 |
+
* @return Mixed.
|
58 |
+
*/
|
59 |
+
function aioseopCountChars( field, cntfield ) {
|
60 |
+
var extra = 0;
|
61 |
+
var field_size;
|
62 |
+
if ( ( field.attr('name') == 'aiosp_title' ) && ( typeof aiosp_title_extra !== 'undefined' ) ) {
|
63 |
+
extra = aiosp_title_extra;
|
64 |
+
}
|
65 |
+
cntfield.val( field.val().length + extra );
|
66 |
+
if ( typeof field.attr('size') != 'undefined' ) {
|
67 |
+
field_size = field.attr('size');
|
68 |
+
} else {
|
69 |
+
field_size = field.attr('rows') * field.attr('cols');
|
70 |
+
}
|
71 |
+
field_size = parseInt(field_size, 10);
|
72 |
+
if ( field_size < 10 ) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
if ( cntfield.val() > field_size ) {
|
76 |
+
cntfield.removeClass().addClass('aioseop_count_ugly');
|
77 |
+
} else if ( ( 'aiosp_title' === field.attr('name' ) ) || ( 'aiosp_home_title' === field.attr('name') ) ) {
|
78 |
+
if ( cntfield.val() > ( field_size - 6 ) ) {
|
79 |
+
cntfield.removeClass().addClass('aioseop_count_bad');
|
80 |
+
} else {
|
81 |
+
cntfield.removeClass().addClass('aioseop_count_good');
|
82 |
+
}
|
83 |
+
} else {
|
84 |
+
if ( cntfield.val() > ( field_size - 10 ) ) {
|
85 |
+
cntfield.removeClass().addClass('aioseop_count_bad');
|
86 |
+
} else {
|
87 |
+
cntfield.removeClass().addClass('aioseop_count_good');
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
js/modules/aioseop_module.js
CHANGED
@@ -48,50 +48,6 @@ function toggleVisibility( id ) {
|
|
48 |
}
|
49 |
}
|
50 |
|
51 |
-
/**
|
52 |
-
* @summary Counts characters.
|
53 |
-
*
|
54 |
-
* @since 1.0.0
|
55 |
-
* @since 2.9.1 Fix JS conflict with LearnDash and function name.
|
56 |
-
*
|
57 |
-
* @param Object $field.
|
58 |
-
* @param Object $cntfield.
|
59 |
-
* @return Mixed.
|
60 |
-
*/
|
61 |
-
function aioseopCountChars( field, cntfield ) {
|
62 |
-
var extra = 0;
|
63 |
-
var field_size;
|
64 |
-
if ( ( field.attr('name') == 'aiosp_title' )
|
65 |
-
&& ( typeof aiosp_title_extra !== 'undefined' ) ) {
|
66 |
-
extra = aiosp_title_extra;
|
67 |
-
}
|
68 |
-
cntfield.val(field.val().length + extra);
|
69 |
-
if ( typeof field.attr('size') != 'undefined' ) {
|
70 |
-
field_size = field.attr('size');
|
71 |
-
} else {
|
72 |
-
field_size = field.attr('rows') * field.attr('cols');
|
73 |
-
}
|
74 |
-
field_size = parseInt(field_size, 10);
|
75 |
-
if ( field_size < 10 ) {
|
76 |
-
return;
|
77 |
-
}
|
78 |
-
if ( cntfield.val() > field_size ) {
|
79 |
-
cntfield.removeClass().addClass('aioseop_count_ugly');
|
80 |
-
} else if ( ( 'aiosp_title' === field.attr('name' ) ) || ( 'aiosp_home_title' === field.attr('name') ) ) {
|
81 |
-
if ( cntfield.val() > ( field_size - 6 ) ) {
|
82 |
-
cntfield.removeClass().addClass('aioseop_count_bad');
|
83 |
-
} else {
|
84 |
-
cntfield.removeClass().addClass('aioseop_count_good');
|
85 |
-
}
|
86 |
-
} else {
|
87 |
-
if ( cntfield.val() > ( field_size - 10 ) ) {
|
88 |
-
cntfield.removeClass().addClass('aioseop_count_bad');
|
89 |
-
} else {
|
90 |
-
cntfield.removeClass().addClass('aioseop_count_good');
|
91 |
-
}
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
/**
|
96 |
* @summary Returns the fields value.
|
97 |
*
|
@@ -842,7 +798,6 @@ function aioseop_overflow_border( el ) {
|
|
842 |
function aiospinitAll(){
|
843 |
aiospinitSocialMetaInPosts(jQuery);
|
844 |
aiospinitCalendar();
|
845 |
-
aiospinitCounting();
|
846 |
}
|
847 |
|
848 |
function aiospinitCalendar(){
|
@@ -861,14 +816,3 @@ function aiospinitSocialMetaInPosts($) {
|
|
861 |
$('input[name="aioseop_opengraph_settings_image"]').attr('checked', false);
|
862 |
});
|
863 |
}
|
864 |
-
|
865 |
-
|
866 |
-
function aiospinitCounting(){
|
867 |
-
/* count them characters */
|
868 |
-
jQuery( '.aioseop_count_chars' ).on('keyup keydown', function(){
|
869 |
-
aioseopCountChars( jQuery(this).eq(0), jQuery(this).parent().find('[name="' + jQuery(this).attr('data-length-field') + '"]').eq(0));
|
870 |
-
});
|
871 |
-
jQuery( '.aioseop_count_chars' ).each(function(){
|
872 |
-
aioseopCountChars( jQuery(this).eq(0), jQuery(this).parent().find('[name="' + jQuery(this).attr('data-length-field') + '"]').eq(0));
|
873 |
-
});
|
874 |
-
}
|
48 |
}
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
/**
|
52 |
* @summary Returns the fields value.
|
53 |
*
|
798 |
function aiospinitAll(){
|
799 |
aiospinitSocialMetaInPosts(jQuery);
|
800 |
aiospinitCalendar();
|
|
|
801 |
}
|
802 |
|
803 |
function aiospinitCalendar(){
|
816 |
$('input[name="aioseop_opengraph_settings_image"]').attr('checked', false);
|
817 |
});
|
818 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/modules/aioseop_opengraph.js
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Script for AIOSEOP OpenGraph
|
3 |
+
*
|
4 |
+
* @summary For AIOSEOP OpenGraph settings on AIOSEOP screens & edit post screen (possibly more others).
|
5 |
+
*
|
6 |
+
* @author Michael Torbert.
|
7 |
+
* @author Semper Fi Web Design.
|
8 |
+
* @copyright https://semperplugins.com
|
9 |
+
* @version 2.9.2
|
10 |
+
*/
|
11 |
+
|
12 |
+
jQuery(document).ready(function () {
|
13 |
+
var snippet = jQuery("#aioseop_snippet_link");
|
14 |
+
if (snippet.length === 0) {
|
15 |
+
jQuery("#aioseop_opengraph_settings_facebook_debug_wrapper").hide();
|
16 |
+
} else {
|
17 |
+
snippet = snippet.html();
|
18 |
+
jQuery("#aioseop_opengraph_settings_facebook_debug")
|
19 |
+
.attr("href", "https://developers.facebook.com/tools/debug/sharing/?q=" + snippet);
|
20 |
+
}
|
21 |
+
});
|
modules/aioseop_opengraph.php
CHANGED
@@ -454,7 +454,12 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Opengraph' ) ) {
|
|
454 |
'name' => __( 'Facebook Debug', 'all-in-one-seo-pack' ),
|
455 |
'type' => 'html',
|
456 |
'save' => false,
|
457 |
-
'default' =>
|
|
|
|
|
|
|
|
|
|
|
458 |
),
|
459 |
'section' => array(
|
460 |
'name' => __( 'Article Section', 'all-in-one-seo-pack' ),
|
@@ -1641,6 +1646,34 @@ END;
|
|
1641 |
|
1642 |
}
|
1643 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1644 |
/**
|
1645 |
* Enqueue our file upload scripts and styles.
|
1646 |
* @param $hook
|
@@ -1718,36 +1751,5 @@ END;
|
|
1718 |
}
|
1719 |
return $options;
|
1720 |
}
|
1721 |
-
|
1722 |
-
/**
|
1723 |
-
* Returns facebook debug script and link.
|
1724 |
-
* @since 2.4.14
|
1725 |
-
*
|
1726 |
-
* @return string
|
1727 |
-
*/
|
1728 |
-
private function get_facebook_debug() {
|
1729 |
-
ob_start();
|
1730 |
-
?>
|
1731 |
-
<script>
|
1732 |
-
jQuery(document).ready(function () {
|
1733 |
-
var snippet = jQuery("#aioseop_snippet_link");
|
1734 |
-
if (snippet.length === 0) {
|
1735 |
-
jQuery("#aioseop_opengraph_settings_facebook_debug_wrapper").hide();
|
1736 |
-
} else {
|
1737 |
-
snippet = snippet.html();
|
1738 |
-
jQuery("#aioseop_opengraph_settings_facebook_debug")
|
1739 |
-
.attr("href", "https://developers.facebook.com/tools/debug/sharing/?q=" + snippet);
|
1740 |
-
}
|
1741 |
-
});
|
1742 |
-
</script>
|
1743 |
-
<a name="aioseop_opengraph_settings_facebook_debug"
|
1744 |
-
id="aioseop_opengraph_settings_facebook_debug"
|
1745 |
-
class="button-primary"
|
1746 |
-
href=""
|
1747 |
-
target="_blank"
|
1748 |
-
><?php echo __( 'Debug This Post', 'all-in-one-seo-pack' ); ?></a>
|
1749 |
-
<?php
|
1750 |
-
return ob_get_clean();
|
1751 |
-
}
|
1752 |
}
|
1753 |
}
|
454 |
'name' => __( 'Facebook Debug', 'all-in-one-seo-pack' ),
|
455 |
'type' => 'html',
|
456 |
'save' => false,
|
457 |
+
'default' => '<a
|
458 |
+
name="aioseop_opengraph_settings_facebook_debug"
|
459 |
+
id="aioseop_opengraph_settings_facebook_debug"
|
460 |
+
class="button-primary"
|
461 |
+
href=""
|
462 |
+
target="_blank">' . __( 'Debug This Post', 'all-in-one-seo-pack' ) . '</a>',
|
463 |
),
|
464 |
'section' => array(
|
465 |
'name' => __( 'Article Section', 'all-in-one-seo-pack' ),
|
1646 |
|
1647 |
}
|
1648 |
|
1649 |
+
/**
|
1650 |
+
* Admin Enqueue Scripts
|
1651 |
+
*
|
1652 |
+
* Add hook in \All_in_One_SEO_Pack_Module::enqueue_metabox_scripts - Bails adding hook if not on target valid screen.
|
1653 |
+
* Add hook in \All_in_One_SEO_Pack_Module::add_page_hooks - Function itself is hooked based on the screen_id/page.
|
1654 |
+
*
|
1655 |
+
* @since 2.9.2
|
1656 |
+
*
|
1657 |
+
* @see 'admin_enqueue_scripts' hook
|
1658 |
+
* @link https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/
|
1659 |
+
*
|
1660 |
+
* @param string $hook_suffix
|
1661 |
+
*/
|
1662 |
+
public function admin_enqueue_scripts( $hook_suffix ) {
|
1663 |
+
wp_enqueue_script(
|
1664 |
+
'aioseop-opengraph-script',
|
1665 |
+
AIOSEOP_PLUGIN_URL . 'js/modules/aioseop_opengraph.js',
|
1666 |
+
array(),
|
1667 |
+
AIOSEOP_VERSION
|
1668 |
+
);
|
1669 |
+
|
1670 |
+
// Dev note: If certain JS files need to be restricted to select screens, then follow concept
|
1671 |
+
// used in `All_in_One_SEO_Pack::admin_enqueue_scripts()` (v2.9.1); which uses the `$hook_suffix`
|
1672 |
+
// and a switch-case. This also helps prevent unnessecarily processing localized data when it isn't needed.
|
1673 |
+
|
1674 |
+
parent::admin_enqueue_scripts( $hook_suffix );
|
1675 |
+
}
|
1676 |
+
|
1677 |
/**
|
1678 |
* Enqueue our file upload scripts and styles.
|
1679 |
* @param $hook
|
1751 |
}
|
1752 |
return $options;
|
1753 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1754 |
}
|
1755 |
}
|
modules/aioseop_sitemap.php
CHANGED
@@ -15,24 +15,126 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
15 |
* @since 2.4 Include images in sitemap.
|
16 |
*/
|
17 |
class All_in_One_SEO_Pack_Sitemap extends All_in_One_SEO_Pack_Module {
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
* The allowed image extensions.
|
32 |
*
|
33 |
-
* @var
|
34 |
*/
|
35 |
-
private static $image_extensions
|
36 |
'jpg',
|
37 |
'jpeg',
|
38 |
'png',
|
@@ -42,7 +144,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
42 |
/**
|
43 |
* All_in_One_SEO_Pack_Sitemap constructor.
|
44 |
*/
|
45 |
-
function __construct() {
|
46 |
if ( get_class( $this ) === 'All_in_One_SEO_Pack_Sitemap' ) { // Set this up only when instantiated as this class.
|
47 |
$this->name = __( 'XML Sitemap', 'all-in-one-seo-pack' ); // Human-readable name of the plugin.
|
48 |
$this->prefix = 'aiosp_sitemap_'; // Option prefix.
|
@@ -51,9 +153,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
51 |
$this->extra_sitemaps = apply_filters( $this->prefix . 'extra', $this->extra_sitemaps );
|
52 |
}
|
53 |
parent::__construct();
|
|
|
54 |
$this->comment_string = 'Sitemap %s generated by All in One SEO Pack %s by Michael Torbert of Semper Fi Web Design on %s';
|
55 |
|
56 |
$this->help_text = array(
|
|
|
57 |
'daily_cron' => __( 'Notify search engines based on the selected schedule, and also update static sitemap daily if in use. (this uses WP-Cron, so make sure this is working properly on your server as well)', 'all-in-one-seo-pack' ),
|
58 |
'indexes' => __( 'Organize sitemap entries into distinct files in your sitemap. Enable this only if your sitemap contains over 50,000 URLs or the file is over 5MB in size.', 'all-in-one-seo-pack' ),
|
59 |
'max_posts' => __( 'Allows you to specify the maximum number of posts in a sitemap (up to 50,000).', 'all-in-one-seo-pack' ),
|
@@ -74,6 +178,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
74 |
);
|
75 |
|
76 |
$this->help_anchors = array(
|
|
|
77 |
'daily_cron' => '#schedule-updates',
|
78 |
'indexes' => '#enable-sitemap-indexes',
|
79 |
'max_posts' => '#enable-sitemap-indexes',
|
@@ -94,7 +199,8 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
94 |
);
|
95 |
|
96 |
$this->default_options = array(
|
97 |
-
'
|
|
|
98 |
'name' => __( 'Schedule Updates', 'all-in-one-seo-pack' ),
|
99 |
'type' => 'select',
|
100 |
'initial_options' => array(
|
@@ -105,42 +211,50 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
105 |
),
|
106 |
'default' => 0,
|
107 |
),
|
108 |
-
'indexes'
|
109 |
-
'max_posts'
|
110 |
'name' => __( 'Maximum Posts Per Sitemap Page', 'all-in-one-seo-pack' ),
|
111 |
'type' => 'text',
|
112 |
'default' => 50000,
|
113 |
-
'condshow' => array(
|
|
|
|
|
|
|
114 |
),
|
115 |
-
'posttypes'
|
116 |
'name' => __( 'Post Types', 'all-in-one-seo-pack' ),
|
117 |
'type' => 'multicheckbox',
|
118 |
'default' => 'all',
|
119 |
),
|
120 |
-
'taxonomies'
|
121 |
'name' => __( 'Taxonomies', 'all-in-one-seo-pack' ),
|
122 |
'type' => 'multicheckbox',
|
123 |
'default' => 'all',
|
124 |
),
|
125 |
-
'archive'
|
126 |
-
'author'
|
127 |
-
'images'
|
128 |
-
'gzipped'
|
129 |
'name' => __( 'Create Compressed Sitemap', 'all-in-one-seo-pack' ),
|
130 |
'default' => 'On',
|
131 |
),
|
132 |
-
'robots'
|
133 |
'name' => __( 'Link From Virtual Robots.txt', 'all-in-one-seo-pack' ),
|
134 |
'default' => 'On',
|
135 |
),
|
136 |
-
'rewrite'
|
137 |
'name' => __( 'Dynamically Generate Sitemap', 'all-in-one-seo-pack' ),
|
138 |
'default' => 'On',
|
139 |
),
|
140 |
);
|
141 |
|
142 |
$status_options = array(
|
143 |
-
'link'
|
|
|
|
|
|
|
|
|
|
|
144 |
);
|
145 |
|
146 |
$this->layout = array(
|
@@ -199,6 +313,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
199 |
|
200 |
$arr[ $k . '_' . $opt ] = array(
|
201 |
'name' => $this->ucwords( $val ),
|
|
|
202 |
'help_text' => sprintf( __( 'Manually set the %1$s of your %2$s.', 'all-in-one-seo-pack' ), $v, $val ),
|
203 |
'type' => 'select',
|
204 |
'initial_options' => $iopts,
|
@@ -267,7 +382,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
267 |
'type' => 'multicheckbox',
|
268 |
'initial_options' => '',
|
269 |
),
|
270 |
-
'excl_pages' => array(
|
|
|
|
|
|
|
271 |
);
|
272 |
|
273 |
$this->layout['addl_pages'] = array(
|
@@ -285,12 +403,14 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
285 |
$this->layout['priorities'] = array(
|
286 |
'name' => __( 'Priorities', 'all-in-one-seo-pack' ),
|
287 |
'help_link' => 'https://semperplugins.com/documentation/xml-sitemaps-module/#priorities-and-frequencies',
|
|
|
288 |
'options' => array_keys( $prio_options ),
|
289 |
);
|
290 |
|
291 |
$this->layout['frequencies'] = array(
|
292 |
'name' => __( 'Frequencies', 'all-in-one-seo-pack' ),
|
293 |
'help_link' => 'https://semperplugins.com/documentation/xml-sitemaps-module/#priorities-and-frequencies',
|
|
|
294 |
'options' => array_keys( $freq_options ),
|
295 |
);
|
296 |
|
@@ -299,7 +419,8 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
299 |
$this->add_help_text_links();
|
300 |
|
301 |
add_action(
|
302 |
-
'after_doing_aioseop_updates',
|
|
|
303 |
$this,
|
304 |
'do_sitemaps',
|
305 |
)
|
@@ -322,7 +443,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
322 |
*
|
323 |
* @since 2.4.1
|
324 |
*/
|
325 |
-
function sitemap_notices() {
|
326 |
|
327 |
$sitemap_max_url_notice_dismissed = get_user_meta( get_current_user_id(), 'aioseop_sitemap_max_url_notice_dismissed', true );
|
328 |
if ( ! empty( $sitemap_max_url_notice_dismissed ) ) {
|
@@ -333,10 +454,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
333 |
|
334 |
$options = $this->options;
|
335 |
|
336 |
-
if (
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
340 |
|
341 |
$post_counts = $this->get_total_post_count(
|
342 |
array(
|
@@ -350,6 +472,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
350 |
$num_terms = array_sum( $term_counts );
|
351 |
}
|
352 |
|
|
|
353 |
$sitemap_urls = $post_counts + $num_terms;
|
354 |
|
355 |
if ( 1001 > $sitemap_urls ) {
|
@@ -359,15 +482,24 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
359 |
$aioseop_plugin_dirname = AIOSEOP_PLUGIN_DIRNAME;
|
360 |
|
361 |
printf(
|
362 |
-
'
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
__( 'Notice: To avoid problems with your XML Sitemap, we strongly recommend you enable Sitemap Indexes and set the Maximum Posts per Sitemap Page to 1000.', 'all-in-one-seo-pack' ),
|
370 |
-
sprintf(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
);
|
372 |
}
|
373 |
}
|
@@ -379,7 +511,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
379 |
* @param $old_status
|
380 |
* @param $post
|
381 |
*/
|
382 |
-
function update_sitemap_from_posts( $new_status, $old_status, $post ) {
|
383 |
|
384 |
if ( $this->option_isset( 'rewrite' ) ) {
|
385 |
// TODO if dynamic, delete transient (we currently don't do transients).
|
@@ -402,12 +534,12 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
402 |
|
403 |
if ( defined( 'AIOSEOP_UNIT_TESTING' ) ) {
|
404 |
$this->do_sitemaps();
|
405 |
-
} elseif ( ! has_action( 'shutdown',
|
406 |
/**
|
407 |
* Defer do_sitemaps until after everything is done.
|
408 |
* And run it only once regardless of posts updated.
|
409 |
*/
|
410 |
-
add_action( 'shutdown', $
|
411 |
}
|
412 |
}
|
413 |
|
@@ -422,7 +554,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
422 |
*
|
423 |
* @return mixed
|
424 |
*/
|
425 |
-
function add_cron_schedules( $schedules ) {
|
426 |
$schedules['weekly'] = array(
|
427 |
'interval' => 604800, // 1 week in seconds.
|
428 |
'display' => __( 'Once Weekly', 'all-in-one-seo-pack' ),
|
@@ -438,7 +570,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
438 |
/**
|
439 |
* Cron update.
|
440 |
*/
|
441 |
-
function cron_update() {
|
442 |
add_filter( 'cron_schedules', array( $this, 'add_cron_schedules' ) );
|
443 |
if ( ! wp_next_scheduled( $this->prefix . 'daily_update_cron' ) ) {
|
444 |
wp_schedule_event( time(), $this->options[ $this->prefix . 'daily_cron' ], $this->prefix . 'daily_update_cron' );
|
@@ -448,7 +580,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
448 |
/**
|
449 |
* Daily update.
|
450 |
*/
|
451 |
-
function daily_update() {
|
452 |
$last_run = get_option( $this->prefix . 'cron_last_run' );
|
453 |
if ( empty( $last_run ) || ( time() - $last_run > 23.5 * 60 * 60 ) ) {
|
454 |
// Sanity check.
|
@@ -461,7 +593,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
461 |
/**
|
462 |
* Initialize options, after constructor.
|
463 |
*/
|
464 |
-
function load_sitemap_options() {
|
465 |
// Load initial options / set defaults.
|
466 |
$this->update_options();
|
467 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
@@ -485,7 +617,8 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
485 |
if ( isset( $this->options[ $this->prefix . 'daily_cron' ] ) && $this->options[ $this->prefix . 'daily_cron' ] ) {
|
486 |
add_action( 'wp', array( $this, 'cron_update' ) );
|
487 |
} else {
|
488 |
-
|
|
|
489 |
wp_unschedule_event( $time, $this->prefix . 'daily_update_cron' );
|
490 |
}
|
491 |
}
|
@@ -501,7 +634,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
501 |
*
|
502 |
* @return string
|
503 |
*/
|
504 |
-
function display_custom_options( $buf, $args ) {
|
505 |
if ( "{$this->prefix}addl_pages" === $args['name'] ) {
|
506 |
$buf .= "<div id='{$this->prefix}addl_pages'>";
|
507 |
if ( ! empty( $args['value'] ) ) {
|
@@ -533,7 +666,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
533 |
/**
|
534 |
* Add post type details for settings once post types have been registered.
|
535 |
*/
|
536 |
-
function add_post_types() {
|
537 |
$post_type_titles = $this->get_post_type_titles( array( 'public' => true ) );
|
538 |
$taxonomy_titles = $this->get_taxonomy_titles( array( 'public' => true ) );
|
539 |
if ( isset( $post_type_titles['attachment'] ) ) {
|
@@ -544,14 +677,18 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
544 |
$this->default_options['posttypes']['default'] = array_keys( $this->default_options['posttypes']['initial_options'] );
|
545 |
$this->default_options['taxonomies']['default'] = array_keys( $this->default_options['taxonomies']['initial_options'] );
|
546 |
$this->default_options['excl_categories']['initial_options'] = $this->get_category_titles();
|
547 |
-
|
548 |
-
$
|
549 |
-
$
|
550 |
-
$
|
|
|
|
|
551 |
foreach ( $post_type_titles as $k => $v ) {
|
552 |
$key = 'prio_post_' . $k;
|
553 |
$this->default_options = aioseop_array_insert_after(
|
554 |
-
$this->default_options,
|
|
|
|
|
555 |
$key => array(
|
556 |
'name' => $v . $post_name,
|
557 |
'help_text' => $prio_help . $v . $post_name,
|
@@ -565,7 +702,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
565 |
$this->layout['priorities']['options'][] = $key;
|
566 |
$key = 'freq_post_' . $k;
|
567 |
$this->default_options = aioseop_array_insert_after(
|
568 |
-
$this->default_options,
|
|
|
|
|
569 |
$key => array(
|
570 |
'name' => $v . $post_name,
|
571 |
'help_text' => $freq_help . $v . $post_name,
|
@@ -581,7 +720,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
581 |
foreach ( $taxonomy_titles as $k => $v ) {
|
582 |
$key = 'prio_taxonomies_' . $k;
|
583 |
$this->default_options = aioseop_array_insert_after(
|
584 |
-
$this->default_options,
|
|
|
|
|
585 |
$key => array(
|
586 |
'name' => $v . $tax_name,
|
587 |
'help_text' => $prio_help . $v . $tax_name,
|
@@ -595,7 +736,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
595 |
$this->layout['priorities']['options'][] = $key;
|
596 |
$key = 'freq_taxonomies_' . $k;
|
597 |
$this->default_options = aioseop_array_insert_after(
|
598 |
-
$this->default_options,
|
|
|
|
|
599 |
$key => array(
|
600 |
'name' => $v . $tax_name,
|
601 |
'help_text' => $freq_help . $v . $tax_name,
|
@@ -614,7 +757,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
614 |
/**
|
615 |
* Set up settings, checking for sitemap conflicts, on settings page.
|
616 |
*/
|
617 |
-
function add_page_hooks() {
|
618 |
$this->flush_rules_hook();
|
619 |
$this->add_post_types();
|
620 |
parent::add_page_hooks();
|
@@ -631,7 +774,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
631 |
*
|
632 |
* @return mixed
|
633 |
*/
|
634 |
-
function filter_submit( $submit ) {
|
635 |
$submit['Submit']['value'] = __( 'Update Sitemap', 'all-in-one-seo-pack' ) . ' »';
|
636 |
|
637 |
return $submit;
|
@@ -646,7 +789,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
646 |
*
|
647 |
* @return mixed
|
648 |
*/
|
649 |
-
function update_post_data( $options ) {
|
650 |
if ( is_multisite() ) {
|
651 |
$options[ $this->prefix . 'rewrite' ]['disabled'] = 'disabled';
|
652 |
}
|
@@ -659,8 +802,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
659 |
*
|
660 |
* @return bool
|
661 |
*/
|
662 |
-
function get_rewrite_url( $url ) {
|
663 |
global $wp_rewrite;
|
|
|
664 |
$url = parse_url( esc_url( $url ), PHP_URL_PATH );
|
665 |
$url = ltrim( $url, '/' );
|
666 |
if ( ! empty( $wp_rewrite ) ) {
|
@@ -684,16 +828,16 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
684 |
*/
|
685 |
private function get_filename() {
|
686 |
$filename = 'sitemap';
|
687 |
-
if ( ! empty( $this->options["{$this->prefix}filename"] ) ) {
|
688 |
-
$filename = $this->options["{$this->prefix}filename"];
|
689 |
$filename = str_replace( '/', '', $filename );
|
690 |
-
}
|
691 |
-
$filename
|
692 |
}
|
693 |
/**
|
694 |
* Filters the filename: aiosp_sitemap_filename OR aiosp_video_sitemap_filename.
|
695 |
*
|
696 |
-
* @param string
|
697 |
*/
|
698 |
return apply_filters( "{$this->prefix}filename", $filename );
|
699 |
}
|
@@ -710,7 +854,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
710 |
*
|
711 |
* @return mixed
|
712 |
*/
|
713 |
-
function filter_display_options( $options ) {
|
714 |
if ( is_multisite() ) {
|
715 |
$options[ $this->prefix . 'rewrite' ] = 'On';
|
716 |
}
|
@@ -718,11 +862,17 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
718 |
$options[ $this->prefix . 'max_posts' ] = 50000;
|
719 |
}
|
720 |
$url = aioseop_home_url( '/' . $this->get_filename() . '.xml' );
|
721 |
-
$url_rss = aioseop_home_url( '/' . $this->get_filename() . '.rss' );
|
722 |
|
723 |
-
|
|
|
724 |
$options[ $this->prefix . 'link' ] .= __( ' Your sitemap has been created with content and images.', 'all-in-one-seo-pack' );
|
725 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
726 |
if ( '0' !== get_option( 'blog_public' ) ) {
|
727 |
$options[ $this->prefix . 'link' ] .= ' ' . __( 'Changes are automatically submitted to search engines.', 'all-in-one-seo-pack' );
|
728 |
}
|
@@ -730,6 +880,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
730 |
if ( $this->option_isset( 'rewrite' ) ) {
|
731 |
$rule = $this->get_rewrite_url( $url );
|
732 |
$rules = $this->get_rewrite_rules();
|
|
|
733 |
if ( ! in_array( $rule, $rules ) ) {
|
734 |
$options[ $this->prefix . 'link' ] .= '<p>' . __( 'Dynamic sitemap generation does not appear to be using the correct rewrite rules; please disable any other sitemap plugins or functionality on your site and reset your permalinks.', 'all-in-one-seo-pack' ) . '</p>';
|
735 |
}
|
@@ -741,6 +892,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
741 |
} else {
|
742 |
$privacy_link = '<a href="options-privacy.php">' . __( 'Privacy Settings', 'all-in-one-seo-pack' ) . '</a>';
|
743 |
}
|
|
|
744 |
$options[ $this->prefix . 'link' ] .= '<p class="aioseop_error_notice">' . sprintf( __( 'Warning: your privacy settings are configured to ask search engines to not index your site; you can change this under %s for your blog.', 'all-in-one-seo-pack' ), $privacy_link );
|
745 |
}
|
746 |
return $options;
|
@@ -751,17 +903,21 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
751 |
*
|
752 |
* Handle 'all' option for post types / taxonomies, further sanitization of filename, rewrites on for multisite, setting up addl pages option.
|
753 |
*
|
|
|
|
|
754 |
* @param $options
|
755 |
*
|
756 |
* @return mixed
|
757 |
*/
|
758 |
-
function filter_options( $options ) {
|
759 |
if ( ! isset( $this->default_options['posttypes']['initial_options'] ) ) {
|
760 |
$this->add_post_types();
|
761 |
}
|
|
|
762 |
if ( is_array( $options[ "{$this->prefix}posttypes" ] ) && in_array( 'all', $options[ "{$this->prefix}posttypes" ] ) && is_array( $this->default_options['posttypes']['initial_options'] ) ) {
|
763 |
$options[ "{$this->prefix}posttypes" ] = array_keys( $this->default_options['posttypes']['initial_options'] );
|
764 |
}
|
|
|
765 |
if ( is_array( $options[ "{$this->prefix}taxonomies" ] ) && in_array( 'all', $options[ "{$this->prefix}taxonomies" ] ) && is_array( $this->default_options['taxonomies']['initial_options'] ) ) {
|
766 |
$options[ "{$this->prefix}taxonomies" ] = array_keys( $this->default_options['taxonomies']['initial_options'] );
|
767 |
}
|
@@ -797,8 +953,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
797 |
if ( ! empty( $_POST[ $this->prefix . 'addl_url' ] ) ) {
|
798 |
foreach ( array( 'addl_url', 'addl_prio', 'addl_freq', 'addl_mod' ) as $field ) {
|
799 |
if ( ! empty( $_POST[ $this->prefix . $field ] ) ) {
|
|
|
800 |
$_POST[ $this->prefix . $field ] = esc_attr( wp_kses_post( $_POST[ $this->prefix . $field ] ) );
|
801 |
} else {
|
|
|
802 |
$_POST[ $this->prefix . $field ] = '';
|
803 |
}
|
804 |
}
|
@@ -808,6 +966,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
808 |
|
809 |
if ( aiosp_common::is_url_valid( $_POST[ $this->prefix . 'addl_url' ] ) ) {
|
810 |
$options[ $this->prefix . 'addl_pages' ][ $_POST[ $this->prefix . 'addl_url' ] ] = array(
|
|
|
811 |
'prio' => $_POST[ $this->prefix . 'addl_prio' ],
|
812 |
'freq' => $_POST[ $this->prefix . 'addl_freq' ],
|
813 |
'mod' => $_POST[ $this->prefix . 'addl_mod' ],
|
@@ -821,9 +980,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
821 |
/**
|
822 |
* Get sitemap urls of child blogs, if any.
|
823 |
*
|
824 |
-
* @return
|
825 |
*/
|
826 |
-
function get_child_sitemap_urls() {
|
827 |
$siteurls = array();
|
828 |
$blogs = $this->get_child_blogs();
|
829 |
if ( ! empty( $blogs ) ) {
|
@@ -831,9 +990,12 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
831 |
foreach ( $blogs as $blog_id ) {
|
832 |
if ( $this->is_aioseop_active_on_blog( $blog_id ) ) {
|
833 |
$options = get_blog_option( $blog_id, $this->parent_option );
|
834 |
-
if (
|
835 |
-
|
836 |
-
|
|
|
|
|
|
|
837 |
) {
|
838 |
global $wpdb;
|
839 |
$sitemap_options = $options['modules'][ $option_name ];
|
@@ -843,10 +1005,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
843 |
$domain = $wpdb->get_var( "SELECT domain FROM {$wpdb->dmtable} WHERE blog_id = '$blog_id' AND active = 1 LIMIT 1" );
|
844 |
// @codingStandardsIgnoreEnd
|
845 |
if ( $domain ) {
|
846 |
-
if (
|
847 |
$_SERVER['HTTPS'] = 'Off';
|
848 |
}
|
849 |
-
$protocol = ( 'on'
|
850 |
$siteurl = untrailingslashit( $protocol . $domain );
|
851 |
}
|
852 |
}
|
@@ -876,7 +1038,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
876 |
*
|
877 |
* @return mixed|string
|
878 |
*/
|
879 |
-
function get_home_path() {
|
880 |
|
881 |
if ( function_exists( 'get_home_path' ) ) {
|
882 |
return get_home_path();
|
@@ -907,7 +1069,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
907 |
*
|
908 |
* @return string
|
909 |
*/
|
910 |
-
function whitelist_static_sitemaps( $file ) {
|
911 |
|
912 |
$whitelist = array( 'sitemap_news.xml', 'sitemap-news.xml' );
|
913 |
|
@@ -923,15 +1085,15 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
923 |
*
|
924 |
* @return array
|
925 |
*/
|
926 |
-
function scan_match_files() {
|
927 |
-
$scan1 =
|
|
|
928 |
$files = array();
|
929 |
|
930 |
-
|
931 |
$filename = $this->get_filename();
|
932 |
if ( ! empty( $filename ) ) {
|
933 |
$scan1 = get_home_path() . $filename . '*.xml';
|
934 |
-
if ( ! empty( $this->options["{$this->prefix}gzipped"] ) ) {
|
935 |
$scan2 .= get_home_path() . $filename . '*.xml.gz';
|
936 |
}
|
937 |
|
@@ -962,15 +1124,19 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
962 |
* Scan for sitemaps.
|
963 |
*
|
964 |
* Handle deleting / renaming of conflicting sitemap files.
|
|
|
|
|
965 |
*/
|
966 |
-
function do_sitemap_scan() {
|
967 |
$msg = '';
|
968 |
if ( ! empty( $this->options[ "{$this->prefix}rewrite" ] ) && ( get_option( 'permalink_structure' ) === '' ) ) {
|
969 |
$msg = '<p>' . __( 'Warning: dynamic sitemap generation must have permalinks enabled.', 'all-in-one-seo-pack' ) . '</p>';
|
970 |
}
|
971 |
if ( ! empty( $_POST['aioseop_sitemap_rename_files'] ) || ! empty( $_POST['aioseop_sitemap_delete_files'] ) ) {
|
|
|
972 |
$nonce = $_POST['nonce-aioseop'];
|
973 |
if ( ! wp_verify_nonce( $nonce, 'aioseop-nonce' ) ) {
|
|
|
974 |
die( __( 'Security Check - If you receive this in error, log out and back in to WordPress', 'all-in-one-seo-pack' ) );
|
975 |
}
|
976 |
if ( ! empty( $_POST['aioseop_sitemap_conflict'] ) ) {
|
@@ -980,9 +1146,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
980 |
}
|
981 |
foreach ( $_POST['aioseop_sitemap_conflict'] as $ren_file ) {
|
982 |
$ren_file = realpath( get_home_path() . $ren_file );
|
|
|
983 |
if ( in_array( $ren_file, $files ) ) {
|
984 |
if ( ! empty( $_POST['aioseop_sitemap_delete_files'] ) ) {
|
985 |
if ( $this->delete_file( $ren_file ) ) {
|
|
|
986 |
$msg .= '<p>' . sprintf( __( 'Deleted %s.', 'all-in-one-seo-pack' ), $ren_file ) . '</p>';
|
987 |
}
|
988 |
continue;
|
@@ -993,14 +1161,17 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
993 |
$count ++;
|
994 |
} while ( $this->file_exists( $ren_to ) && ( $count < 1000 ) );
|
995 |
if ( $count >= 1000 ) {
|
|
|
996 |
$msg .= '<p>' . sprintf( __( "Couldn't rename file %s!", 'all-in-one-seo-pack' ), $ren_file ) . '</p>';
|
997 |
} else {
|
998 |
$ren = $this->rename_file( $ren_file, $ren_to );
|
999 |
if ( $ren ) {
|
|
|
1000 |
$msg .= '<p>' . sprintf( __( 'Renamed %1$s to %2$s.', 'all-in-one-seo-pack' ), $ren_file, $ren_to ) . '</p>';
|
1001 |
}
|
1002 |
}
|
1003 |
} else {
|
|
|
1004 |
$msg .= '<p>' . sprintf( __( "Couldn't find file %s!", 'all-in-one-seo-pack' ), $ren_file ) . '</p>';
|
1005 |
}
|
1006 |
}
|
@@ -1019,7 +1190,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1019 |
*
|
1020 |
* @return string
|
1021 |
*/
|
1022 |
-
function scan_sitemaps() {
|
1023 |
$msg = '';
|
1024 |
$files = $this->scan_match_files();
|
1025 |
if ( ! empty( $files ) ) {
|
@@ -1041,7 +1212,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1041 |
*
|
1042 |
* @return array
|
1043 |
*/
|
1044 |
-
function get_problem_files( $files, &$msg ) {
|
1045 |
$problem_files = array();
|
1046 |
$use_wpfs = true;
|
1047 |
$wpfs = $this->get_filesystem_object();
|
@@ -1072,9 +1243,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1072 |
} else {
|
1073 |
if ( $compressed ) {
|
1074 |
$file_resource = gzopen( $fn, 'rb' );
|
1075 |
-
$file
|
1076 |
gzclose( $file_resource );
|
1077 |
} else {
|
|
|
1078 |
$file = file_get_contents( $fn, false, null, 0, 4096 );
|
1079 |
}
|
1080 |
}
|
@@ -1082,21 +1254,29 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1082 |
$matches = array();
|
1083 |
if ( preg_match(
|
1084 |
'/<!-- ' . sprintf( $this->comment_string, '(.*)', '(.*)', '(.*)' ) . ' -->/',
|
1085 |
-
$file,
|
|
|
1086 |
) ) {
|
1087 |
if ( ! empty( $this->options[ "{$this->prefix}rewrite" ] ) ) {
|
1088 |
$msg .= '<p>' . sprintf(
|
1089 |
__( "Warning: a static sitemap '%1\$s' generated by All in One SEO Pack %2\$s on %3\$s already exists that may conflict with dynamic sitemap generation.", 'all-in-one-seo-pack' ),
|
1090 |
-
$f,
|
|
|
|
|
1091 |
) . "</p>\n";
|
|
|
1092 |
$problem_files[] = $f;
|
1093 |
}
|
1094 |
} else {
|
|
|
1095 |
$msg .= '<p>' . sprintf( __( 'Potential conflict with unknown file %s.', 'all-in-one-seo-pack' ), $f ) . "</p>\n";
|
|
|
1096 |
$problem_files[] = $f;
|
1097 |
}
|
1098 |
} else {
|
|
|
1099 |
$msg .= '<p>' . sprintf( __( 'Removed empty file %s.', 'all-in-one-seo-pack' ), $f ) . "</p>\n";
|
|
|
1100 |
$problem_files[] = $f;
|
1101 |
|
1102 |
// This is causing all problem_files to be deleted automatically; which may be the intent.
|
@@ -1122,7 +1302,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1122 |
*
|
1123 |
* @return string
|
1124 |
*/
|
1125 |
-
function sitemap_warning( $files ) {
|
1126 |
$msg = '';
|
1127 |
$conflict = false;
|
1128 |
$problem_files = $this->get_problem_files( $files, $msg );
|
@@ -1136,6 +1316,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1136 |
$msg .= "<input type='hidden' name='nonce-aioseop' value='" . wp_create_nonce( 'aioseop-nonce' ) . "'>\n";
|
1137 |
$msg .= "<input type='submit' name='aioseop_sitemap_rename_files' value='" . __( 'Rename Conflicting Files', 'all-in-one-seo-pack' ) . "'> ";
|
1138 |
$msg .= "<input type='submit' name='aioseop_sitemap_delete_files' value='" . __( 'Delete Conflicting Files', 'all-in-one-seo-pack' ) . "'>";
|
|
|
1139 |
$msg = '<form action="" method="post">' . $msg . '</form>';
|
1140 |
}
|
1141 |
|
@@ -1149,14 +1330,14 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1149 |
*
|
1150 |
* @param $msg
|
1151 |
*/
|
1152 |
-
function debug_message( $msg ) {
|
1153 |
aiosp_log( $msg );
|
1154 |
}
|
1155 |
|
1156 |
/**
|
1157 |
* Set up hooks for rewrite rules for dynamic sitemap generation.
|
1158 |
*/
|
1159 |
-
function setup_rewrites() {
|
1160 |
add_filter( 'rewrite_rules_array', array( $this, 'rewrite_hook' ) );
|
1161 |
add_filter( 'query_vars', array( $this, 'query_var_hook' ) );
|
1162 |
add_action( 'parse_query', array( $this, 'sitemap_output_hook' ) );
|
@@ -1168,22 +1349,33 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1168 |
/**
|
1169 |
* Build and return our rewrite rules.
|
1170 |
*
|
|
|
|
|
1171 |
* @return array
|
1172 |
*/
|
1173 |
-
function get_rewrite_rules() {
|
1174 |
-
$
|
1175 |
-
$sitemap_rules_normal
|
1176 |
-
|
1177 |
-
$this->get_filename() . '.xml' => "index.php?{$this->prefix}path=root",
|
1178 |
$this->get_filename() . '_(.+)_(\d+).xml' => 'index.php?' . $this->prefix . 'path=$matches[1]&' . $this->prefix . 'page=$matches[2]',
|
1179 |
$this->get_filename() . '_(.+).xml' => 'index.php?' . $this->prefix . 'path=$matches[1]',
|
1180 |
-
$this->get_filename() . '.rss' => 'index.php?' . $this->prefix . 'path=rss',
|
1181 |
-
$this->get_filename() . 'latest.rss' => 'index.php?' . $this->prefix . 'path=rss_latest',
|
1182 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1183 |
if ( $this->options[ "{$this->prefix}gzipped" ] ) {
|
1184 |
$sitemap_rules_gzipped = array(
|
1185 |
-
|
1186 |
-
$this->get_filename() . '.xml.gz' => "index.php?{$this->prefix}gzipped=1&{$this->prefix}path=root.gz",
|
1187 |
$this->get_filename() . '_(.+)_(\d+).xml.gz' => 'index.php?' . $this->prefix . 'path=$matches[1].gz&' . $this->prefix . 'page=$matches[2]',
|
1188 |
$this->get_filename() . '_(.+).xml.gz' => 'index.php?' . $this->prefix . 'path=$matches[1].gz',
|
1189 |
);
|
@@ -1200,7 +1392,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1200 |
*
|
1201 |
* @return array
|
1202 |
*/
|
1203 |
-
function rewrite_hook( $rules ) {
|
1204 |
$sitemap_rules = $this->get_rewrite_rules();
|
1205 |
if ( ! empty( $sitemap_rules ) ) {
|
1206 |
$rules = $sitemap_rules + $rules;
|
@@ -1212,11 +1404,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1212 |
/**
|
1213 |
* Flush rewrite rules when necessary.
|
1214 |
*/
|
1215 |
-
function flush_rules_hook() {
|
1216 |
global $wp_rewrite;
|
1217 |
-
$sitemap_rules = $this->get_rewrite_rules(
|
1218 |
if ( ! empty( $sitemap_rules ) ) {
|
1219 |
-
$rules
|
1220 |
$new_rules = array_keys( $sitemap_rules );
|
1221 |
foreach ( $new_rules as $rule ) {
|
1222 |
if ( ! isset( $rules[ $rule ] ) || ( $rules[ $rule ] !== $sitemap_rules[ $rule ] ) ) {
|
@@ -1234,7 +1426,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1234 |
*
|
1235 |
* @return array
|
1236 |
*/
|
1237 |
-
function query_var_hook( $vars ) {
|
1238 |
$vars[] = "{$this->prefix}path";
|
1239 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
1240 |
$vars[] = "{$this->prefix}page";
|
@@ -1246,7 +1438,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1246 |
/**
|
1247 |
* Start timing and get initial memory usage for debug info.
|
1248 |
*/
|
1249 |
-
function log_start() {
|
1250 |
$this->start_memory_usage = memory_get_peak_usage();
|
1251 |
timer_start();
|
1252 |
}
|
@@ -1259,7 +1451,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1259 |
* @param bool $compressed
|
1260 |
* @param bool $dynamic
|
1261 |
*/
|
1262 |
-
function log_stats( $sitemap_type = 'static', $compressed = false, $dynamic = true ) {
|
1263 |
$time = timer_stop();
|
1264 |
$end_memory_usage = memory_get_peak_usage();
|
1265 |
$sitemap_memory_usage = $end_memory_usage - $this->start_memory_usage;
|
@@ -1280,7 +1472,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1280 |
*
|
1281 |
* @param $query
|
1282 |
*/
|
1283 |
-
function sitemap_output_hook( $query ) {
|
1284 |
$page = 0;
|
1285 |
if ( $this->options[ "{$this->prefix}rewrite" ] && ! empty( $query->query_vars[ "{$this->prefix}path" ] ) ) {
|
1286 |
|
@@ -1313,6 +1505,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1313 |
}
|
1314 |
$this->do_rewrite_sitemap( $sitemap_type, $page );
|
1315 |
if ( $gzipped ) {
|
|
|
1316 |
echo gzencode( ob_get_clean() );
|
1317 |
}
|
1318 |
$this->log_stats( $sitemap_type, $gzipped );
|
@@ -1324,12 +1517,12 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1324 |
/**
|
1325 |
* Make dynamic xsl.
|
1326 |
*/
|
1327 |
-
function make_dynamic_xsl() {
|
1328 |
// Make dynamic xsl file.
|
1329 |
if ( preg_match( '#(/sitemap\.xsl)$#i', $_SERVER['REQUEST_URI'] ) ) {
|
1330 |
$blog_charset = get_option( 'blog_charset' );
|
1331 |
header( "Content-Type: text/xml; charset=$blog_charset", true );
|
1332 |
-
include_once
|
1333 |
exit();
|
1334 |
}
|
1335 |
}
|
@@ -1340,15 +1533,15 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1340 |
* @param $sitemap_type
|
1341 |
* @param int $page
|
1342 |
*
|
1343 |
-
* @return
|
1344 |
*/
|
1345 |
-
function get_sitemap_data( $sitemap_type, $page = 0 ) {
|
1346 |
$sitemap_data = array();
|
1347 |
|
1348 |
if ( 0 === strpos( $sitemap_type, 'rss' ) ) {
|
1349 |
$sitemap_data = $this->get_simple_sitemap();
|
1350 |
} elseif ( $this->options[ "{$this->prefix}indexes" ] ) {
|
1351 |
-
$posttypes = $this->options["{$this->prefix}posttypes"];
|
1352 |
if ( empty( $posttypes ) ) {
|
1353 |
$posttypes = array();
|
1354 |
}
|
@@ -1365,10 +1558,13 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1365 |
} elseif ( 'author' === $sitemap_type && $this->option_isset( 'author' ) ) {
|
1366 |
$sitemap_data = $this->get_author_prio_data();
|
1367 |
} elseif ( in_array( $sitemap_type, $posttypes ) ) {
|
|
|
1368 |
$sitemap_data = $this->get_all_post_priority_data( $sitemap_type, 'publish', $page );
|
1369 |
} elseif ( in_array( $sitemap_type, $taxonomies ) ) {
|
|
|
1370 |
$sitemap_data = $this->get_term_priority_data( get_terms( $sitemap_type, $this->get_tax_args( $page ) ) );
|
1371 |
} else {
|
|
|
1372 |
if ( is_array( $this->extra_sitemaps ) && in_array( $sitemap_type, $this->extra_sitemaps ) ) {
|
1373 |
$sitemap_data = apply_filters( $this->prefix . 'custom_' . $sitemap_type, $sitemap_data, $page, $this_options );
|
1374 |
}
|
@@ -1388,9 +1584,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1388 |
* @param $sitemap_type
|
1389 |
* @param int $page
|
1390 |
*/
|
1391 |
-
function do_rewrite_sitemap( $sitemap_type, $page = 0 ) {
|
1392 |
$this->add_post_types();
|
1393 |
$comment = 'dynamically';
|
|
|
1394 |
echo $this->do_build_sitemap( $sitemap_type, $page, '', $comment );
|
1395 |
}
|
1396 |
|
@@ -1402,7 +1599,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1402 |
*
|
1403 |
* @return string
|
1404 |
*/
|
1405 |
-
function get_sitemap_url() {
|
1406 |
|
1407 |
$gz = '';
|
1408 |
if ( $this->options[ "{$this->prefix}gzipped" ] ) {
|
@@ -1417,7 +1614,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1417 |
/**
|
1418 |
* Notify search engines, do logging.
|
1419 |
*/
|
1420 |
-
function do_notify() {
|
1421 |
|
1422 |
if ( '0' === get_option( 'blog_public' ) ) {
|
1423 |
// Don't ping search engines if blog is set to not public.
|
@@ -1430,8 +1627,8 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1430 |
}
|
1431 |
|
1432 |
$notify_url = array(
|
1433 |
-
'google' => 'https://www.google.com/
|
1434 |
-
'bing' => 'https://www.bing.com/
|
1435 |
);
|
1436 |
|
1437 |
$notify_url = apply_filters( 'aioseo_sitemap_ping_urls', $notify_url );
|
@@ -1439,12 +1636,17 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1439 |
$url = $this->get_sitemap_url();
|
1440 |
if ( ! empty( $url ) ) {
|
1441 |
foreach ( $notify_url as $k => $v ) {
|
|
|
|
|
|
|
1442 |
$response = wp_remote_get( $notify_url[ $k ] . urlencode( $url ) );
|
1443 |
if ( is_array( $response ) && ! empty( $response['response'] ) && ! empty( $response['response']['code'] ) ) {
|
1444 |
-
if ( 200
|
|
|
1445 |
$this->debug_message( sprintf( __( 'Failed to notify %1$s about changes to your sitemap at %2$s, error code %3$s.', 'all-in-one-seo-pack' ), $k, $url, $response['response']['code'] ) );
|
1446 |
}
|
1447 |
} else {
|
|
|
1448 |
$this->debug_message( sprintf( __( 'Failed to notify %1$s about changes to your sitemap at %2$s, unable to access via wp_remote_get().', 'all-in-one-seo-pack' ), $k, $url ) );
|
1449 |
}
|
1450 |
}
|
@@ -1454,8 +1656,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1454 |
/**
|
1455 |
* Add Sitemap parameter to virtual robots.txt file.
|
1456 |
*/
|
1457 |
-
function do_robots() {
|
1458 |
$url = $this->get_sitemap_url();
|
|
|
1459 |
echo "\nSitemap: $url\n";
|
1460 |
}
|
1461 |
|
@@ -1466,10 +1669,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1466 |
*
|
1467 |
* @param string $message
|
1468 |
*/
|
1469 |
-
function do_sitemaps( $message = '' ) {
|
1470 |
if ( defined( 'AIOSEOP_UNIT_TESTING' ) ) {
|
1471 |
$aioseop_options = aioseop_get_options();
|
1472 |
-
$this->options
|
1473 |
}
|
1474 |
|
1475 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
@@ -1489,10 +1692,13 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1489 |
|
1490 |
$comment = sprintf( "file '%s' statically", $this->get_filename() );
|
1491 |
$sitemap = $this->do_simple_sitemap( $comment );
|
1492 |
-
|
1493 |
$this->write_sitemaps( $this->get_filename(), $sitemap );
|
1494 |
-
|
1495 |
-
$this->
|
|
|
|
|
|
|
|
|
1496 |
$this->log_stats( 'root', $this->options[ "{$this->prefix}gzipped" ], false );
|
1497 |
}
|
1498 |
} else {
|
@@ -1511,7 +1717,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1511 |
*
|
1512 |
* @return mixed
|
1513 |
*/
|
1514 |
-
function add_xml_mime_type( $mime ) {
|
1515 |
if ( ! empty( $mime ) ) {
|
1516 |
$mime['xml'] = 'text/xml';
|
1517 |
}
|
@@ -1527,9 +1733,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1527 |
* @param $filename
|
1528 |
* @param $contents
|
1529 |
*/
|
1530 |
-
function write_sitemaps( $filename, $contents, $extn = '.xml' ) {
|
1531 |
$this->write_sitemap( $filename . $extn, $contents );
|
1532 |
-
if ( $this->options["{$this->prefix}gzipped"] ) {
|
1533 |
$this->write_sitemap( $filename . $extn . '.gz', $contents, true );
|
1534 |
}
|
1535 |
}
|
@@ -1545,7 +1751,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1545 |
*
|
1546 |
* @return bool
|
1547 |
*/
|
1548 |
-
function write_sitemap( $filename, $contents, $gzip = false ) {
|
1549 |
if ( $gzip ) {
|
1550 |
$contents = gzencode( $contents );
|
1551 |
}
|
@@ -1570,15 +1776,15 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1570 |
*
|
1571 |
* @return bool
|
1572 |
*/
|
1573 |
-
function get_default_values( $defaults, $prefix, &$cache, $item, $nodefaults = false, $type = '' ) {
|
1574 |
if ( ! empty( $cache[ $item . $type ] ) ) {
|
1575 |
return $cache[ $item . $type ];
|
1576 |
}
|
1577 |
if ( ! empty( $defaults[ $item ] ) ) {
|
1578 |
$field = $this->prefix . $prefix . $item;
|
1579 |
-
if ( $this->option_isset( $prefix . $item ) && 'no'
|
1580 |
if ( ( 'sel' === $this->options[ $field ] ) && ! empty( $type ) && isset( $this->options[ $this->prefix . $prefix . $item . '_' . $type ] ) ) {
|
1581 |
-
if ( 'no'
|
1582 |
return false;
|
1583 |
}
|
1584 |
if ( 'sel' === $this->options[ $this->prefix . $prefix . $item . '_' . $type ] ) {
|
@@ -1586,7 +1792,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1586 |
}
|
1587 |
$cache[ $item . $type ] = $this->options[ $this->prefix . $prefix . $item . '_' . $type ];
|
1588 |
} else {
|
1589 |
-
if ( 'no'
|
1590 |
return false;
|
1591 |
}
|
1592 |
if ( 'sel' === $this->options[ $field ] ) {
|
@@ -1616,7 +1822,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1616 |
*
|
1617 |
* @return bool
|
1618 |
*/
|
1619 |
-
function get_default_priority( $item, $nodefaults = false, $type = '' ) {
|
1620 |
$defaults = array(
|
1621 |
'homepage' => '1.0',
|
1622 |
'blog' => '0.9',
|
@@ -1626,6 +1832,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1626 |
'author' => '0.3',
|
1627 |
'taxonomies' => '0.3',
|
1628 |
);
|
|
|
1629 |
static $cache = array();
|
1630 |
|
1631 |
return $this->get_default_values( $defaults, 'prio_', $cache, $item, $nodefaults, $type );
|
@@ -1640,7 +1847,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1640 |
*
|
1641 |
* @return bool
|
1642 |
*/
|
1643 |
-
function get_default_frequency( $item, $nodefaults = false, $type = '' ) {
|
1644 |
$defaults = array(
|
1645 |
'homepage' => 'always',
|
1646 |
'blog' => 'daily',
|
@@ -1650,6 +1857,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1650 |
'author' => 'weekly',
|
1651 |
'taxonomies' => 'monthly',
|
1652 |
);
|
|
|
1653 |
static $cache = array();
|
1654 |
|
1655 |
return $this->get_default_values( $defaults, 'freq_', $cache, $item, $nodefaults, $type );
|
@@ -1663,12 +1871,12 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1663 |
*
|
1664 |
* @return array
|
1665 |
*/
|
1666 |
-
function get_sitemap_index_filenames() {
|
1667 |
$files = array();
|
1668 |
$options = $this->options;
|
1669 |
-
|
1670 |
$prefix = $this->get_filename();
|
1671 |
$suffix = '.xml';
|
|
|
1672 |
if ( $options[ "{$this->prefix}gzipped" ] ) {
|
1673 |
$suffix .= '.gz';
|
1674 |
}
|
@@ -1694,7 +1902,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1694 |
);
|
1695 |
|
1696 |
foreach ( $options[ "{$this->prefix}posttypes" ] as $sm ) {
|
1697 |
-
if ( 0
|
1698 |
continue;
|
1699 |
}
|
1700 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
@@ -1702,21 +1910,21 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1702 |
$count = 1;
|
1703 |
for ( $post_count = 0; $post_count < $post_counts[ $sm ]; $post_count += $this->max_posts ) {
|
1704 |
$files[] = array(
|
1705 |
-
'loc' => aioseop_home_url
|
1706 |
'changefreq' => $freq,
|
1707 |
'priority' => $prio,
|
1708 |
);
|
1709 |
}
|
1710 |
} else {
|
1711 |
$files[] = array(
|
1712 |
-
'loc' => aioseop_home_url
|
1713 |
'changefreq' => $freq,
|
1714 |
'priority' => $prio,
|
1715 |
);
|
1716 |
}
|
1717 |
} else {
|
1718 |
$files[] = array(
|
1719 |
-
'loc' => aioseop_home_url
|
1720 |
'changefreq' => $freq,
|
1721 |
'priority' => $prio,
|
1722 |
);
|
@@ -1725,14 +1933,14 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1725 |
}
|
1726 |
if ( $this->option_isset( 'archive' ) ) {
|
1727 |
$files[] = array(
|
1728 |
-
'loc' => aioseop_home_url
|
1729 |
'changefreq' => $this->get_default_frequency( 'archive' ),
|
1730 |
'priority' => $this->get_default_priority( 'archive' ),
|
1731 |
);
|
1732 |
}
|
1733 |
if ( $this->option_isset( 'author' ) ) {
|
1734 |
$files[] = array(
|
1735 |
-
'loc' => aioseop_home_url
|
1736 |
'changefreq' => $this->get_default_frequency( 'author' ),
|
1737 |
'priority' => $this->get_default_priority( 'author' ),
|
1738 |
);
|
@@ -1747,21 +1955,21 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1747 |
$count = 1;
|
1748 |
for ( $tc = 0; $tc < $term_count; $tc += $this->max_posts ) {
|
1749 |
$files[] = array(
|
1750 |
-
'loc' => aioseop_home_url
|
1751 |
'changefreq' => $this->get_default_frequency( 'taxonomies' ),
|
1752 |
'priority' => $this->get_default_priority( 'taxonomies' ),
|
1753 |
);
|
1754 |
}
|
1755 |
} else {
|
1756 |
$files[] = array(
|
1757 |
-
'loc' => aioseop_home_url
|
1758 |
'changefreq' => $this->get_default_frequency( 'taxonomies' ),
|
1759 |
'priority' => $this->get_default_priority( 'taxonomies' ),
|
1760 |
);
|
1761 |
}
|
1762 |
} else {
|
1763 |
$files[] = array(
|
1764 |
-
'loc' => aioseop_home_url
|
1765 |
'changefreq' => $this->get_default_frequency( 'taxonomies' ),
|
1766 |
'priority' => $this->get_default_priority( 'taxonomies' ),
|
1767 |
);
|
@@ -1777,7 +1985,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1777 |
);
|
1778 |
}
|
1779 |
|
1780 |
-
$files
|
1781 |
|
1782 |
return $files;
|
1783 |
}
|
@@ -1792,7 +2000,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1792 |
*
|
1793 |
* @return string
|
1794 |
*/
|
1795 |
-
function do_build_sitemap( $sitemap_type, $page = 0, $filename = '', $comment = '' ) {
|
1796 |
if ( empty( $filename ) ) {
|
1797 |
switch ( $sitemap_type ) {
|
1798 |
case 'root':
|
@@ -1826,7 +2034,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1826 |
* @param string $filename
|
1827 |
* @param string $comment
|
1828 |
*/
|
1829 |
-
function do_write_sitemap( $sitemap_type, $page = 0, $filename = '', $comment = '' ) {
|
1830 |
if ( empty( $filename ) ) {
|
1831 |
if ( 'root' === $sitemap_type ) {
|
1832 |
$filename = $this->get_filename();
|
@@ -1843,7 +2051,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1843 |
/**
|
1844 |
* Build all the indexes.
|
1845 |
*/
|
1846 |
-
function do_indexed_sitemaps() {
|
1847 |
$this->start_memory_usage = memory_get_peak_usage();
|
1848 |
$options = $this->options;
|
1849 |
|
@@ -1912,11 +2120,13 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1912 |
$this->log_stats( 'indexed', $options[ "{$this->prefix}gzipped" ], false );
|
1913 |
}
|
1914 |
|
1915 |
-
function remove_posts_page( $postspageid ) {
|
|
|
1916 |
if ( in_array( $postspageid, $this->excludes ) ) {
|
1917 |
return true;
|
1918 |
}
|
1919 |
|
|
|
1920 |
if ( in_array( get_post_field( 'post_name', $postspageid ), $this->excludes ) ) {
|
1921 |
return true;
|
1922 |
}
|
@@ -1924,11 +2134,13 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1924 |
return false;
|
1925 |
}
|
1926 |
|
1927 |
-
function remove_homepage( $homepage_id ) {
|
|
|
1928 |
if ( in_array( $homepage_id, $this->excludes ) ) {
|
1929 |
-
|
1930 |
return true;
|
1931 |
}
|
|
|
|
|
1932 |
if ( in_array( get_post_field( 'post_name', $homepage_id ), $this->excludes ) ) {
|
1933 |
return true;
|
1934 |
}
|
@@ -1944,7 +2156,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1944 |
*
|
1945 |
* @return array
|
1946 |
*/
|
1947 |
-
function get_simple_sitemap() {
|
1948 |
$child = $this->get_child_sitemap_urls();
|
1949 |
$options = $this->options;
|
1950 |
if ( is_array( $options[ "{$this->prefix}posttypes" ] ) ) {
|
@@ -1955,7 +2167,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1955 |
}
|
1956 |
$prio = $this->get_all_post_priority_data( $options[ "{$this->prefix}posttypes" ] );
|
1957 |
|
1958 |
-
|
|
|
|
|
1959 |
|
1960 |
$home = array(
|
1961 |
'loc' => aioseop_home_url(),
|
@@ -1966,7 +2180,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1966 |
|
1967 |
if ( $posts ) {
|
1968 |
$posts = $this->get_permalink( $posts );
|
1969 |
-
if ( $posts
|
1970 |
$posts = null;
|
1971 |
} else {
|
1972 |
$posts = array(
|
@@ -1990,7 +2204,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
1990 |
break;
|
1991 |
}
|
1992 |
}
|
1993 |
-
if ( ( null
|
1994 |
foreach ( $prio as $k => $p ) {
|
1995 |
if ( $p['loc'] === $posts['loc'] ) {
|
1996 |
$prio[ $k ]['changefreq'] = $this->get_default_frequency( 'blog' );
|
@@ -2029,7 +2243,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2029 |
*
|
2030 |
* @return string
|
2031 |
*/
|
2032 |
-
function do_simple_sitemap( $comment = '' ) {
|
2033 |
$sitemap_data = $this->get_simple_sitemap();
|
2034 |
$sitemap_data = apply_filters( $this->prefix . 'data', $sitemap_data, 'root', 0, $this->options );
|
2035 |
|
@@ -2043,7 +2257,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2043 |
*
|
2044 |
* @return string
|
2045 |
*/
|
2046 |
-
function do_simple_sitemap_rss( $comment = '' ) {
|
2047 |
$sitemap_data = $this->get_simple_sitemap();
|
2048 |
$sitemap_data = apply_filters( $this->prefix . 'data', $sitemap_data, 'rss', 0, $this->options );
|
2049 |
|
@@ -2061,7 +2275,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2061 |
* @since 2.3.6
|
2062 |
* @since 2.3.12.3 Refactored to use aioseop_home_url() for compatibility purposes.
|
2063 |
*/
|
2064 |
-
function get_sitemap_xsl() {
|
2065 |
|
2066 |
return esc_url( apply_filters( 'aioseop_sitemap_xsl_url', aioseop_home_url( '/sitemap.xsl' ) ) );
|
2067 |
}
|
@@ -2075,17 +2289,22 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2075 |
*/
|
2076 |
private function output_rss( $urls, $sitemap_type, $comment ) {
|
2077 |
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n\r\n";
|
|
|
2078 |
echo '<!-- ' . sprintf( $this->comment_string, $comment, AIOSEOP_VERSION, date( 'D, d M Y H:i:s e' ) ) . " -->\r\n";
|
2079 |
|
2080 |
echo '<rss version="2.0"><channel>';
|
2081 |
if ( is_multisite() ) {
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
|
|
|
|
2085 |
} else {
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
|
|
|
|
2089 |
}
|
2090 |
|
2091 |
// remove urls that do not have the rss element.
|
@@ -2098,20 +2317,27 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2098 |
}
|
2099 |
|
2100 |
foreach ( $urls as $url ) {
|
|
|
2101 |
echo
|
2102 |
-
'<item>
|
2103 |
-
<guid>' .
|
2104 |
-
<title>' .
|
2105 |
-
<link>' .
|
2106 |
-
|
2107 |
-
<
|
2108 |
-
|
|
|
2109 |
}
|
2110 |
echo '</channel></rss>';
|
2111 |
}
|
2112 |
|
2113 |
/**
|
2114 |
* Remove elements not containing the rss element.
|
|
|
|
|
|
|
|
|
|
|
2115 |
*/
|
2116 |
public function include_in_rss( $array ) {
|
2117 |
return isset( $array['rss'] );
|
@@ -2148,8 +2374,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2148 |
return null;
|
2149 |
}
|
2150 |
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n\r\n";
|
|
|
2151 |
echo '<!-- ' . sprintf( $this->comment_string, $comment, AIOSEOP_VERSION, date( 'D, d M Y H:i:s e' ) ) . " -->\r\n";
|
2152 |
$plugin_path = $this->plugin_path['url'];
|
|
|
2153 |
$plugin_url = parse_url( $plugin_path );
|
2154 |
$current_host = $_SERVER['HTTP_HOST'];
|
2155 |
if ( empty( $current_host ) ) {
|
@@ -2160,16 +2388,16 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2160 |
$plugin_url['host'] = $current_host;
|
2161 |
}
|
2162 |
|
2163 |
-
// Code unset( $plugin_url['scheme'] )
|
2164 |
$plugin_path = $this->unparse_url( $plugin_url );
|
2165 |
|
2166 |
// Using the filter you need the full path to the custom xsl file.
|
2167 |
$xsl_url = $this->get_sitemap_xsl();
|
2168 |
|
2169 |
-
$xml_header = '<?xml-stylesheet type="text/xsl" href="' . $xsl_url . '"?>' . "\r\n"
|
2170 |
-
. '<urlset ';
|
2171 |
$namespaces = apply_filters(
|
2172 |
-
$this->prefix . 'xml_namespace',
|
|
|
2173 |
'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
|
2174 |
'xmlns:image' => 'http://www.google.com/schemas/sitemap-image/1.1',
|
2175 |
)
|
@@ -2177,11 +2405,12 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2177 |
if ( ! empty( $namespaces ) ) {
|
2178 |
$ns = array();
|
2179 |
foreach ( $namespaces as $k => $v ) {
|
2180 |
-
$ns[] = esc_attr( $k ) . '=
|
2181 |
}
|
2182 |
$xml_header .= join( "\r\n\t", $ns );
|
2183 |
}
|
2184 |
$xml_header .= '>' . "\r\n";
|
|
|
2185 |
echo $xml_header;
|
2186 |
$count = 0;
|
2187 |
foreach ( $urls as $url ) {
|
@@ -2192,41 +2421,53 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2192 |
}
|
2193 |
foreach ( $url as $k => $v ) {
|
2194 |
if ( ! empty( $v ) ) {
|
2195 |
-
|
2196 |
-
$v = esc_url( $v );
|
2197 |
-
}
|
2198 |
if ( is_array( $v ) ) {
|
2199 |
$buf = "\t\t\t<$k>\r\n";
|
2200 |
foreach ( $v as $ext => $attr ) {
|
2201 |
if ( is_array( $attr ) ) {
|
2202 |
$buf = '';
|
|
|
2203 |
echo "\t\t<$k>\r\n";
|
2204 |
foreach ( $attr as $a => $nested ) {
|
2205 |
if ( is_array( $nested ) ) {
|
|
|
2206 |
echo "\t\t\t<$a>\r\n";
|
2207 |
foreach ( $nested as $next => $nattr ) {
|
2208 |
-
|
|
|
|
|
2209 |
}
|
|
|
2210 |
echo "\t\t\t</$a>\r\n";
|
2211 |
} else {
|
2212 |
-
|
|
|
|
|
2213 |
}
|
2214 |
}
|
|
|
2215 |
echo "\t\t</$k>\r\n";
|
2216 |
} else {
|
2217 |
-
$
|
|
|
2218 |
}
|
2219 |
}
|
2220 |
if ( ! empty( $buf ) ) {
|
|
|
2221 |
echo $buf . "\t\t</$k>\r\n";
|
2222 |
}
|
2223 |
} else {
|
2224 |
-
|
|
|
|
|
2225 |
}
|
2226 |
}
|
2227 |
}
|
2228 |
} else {
|
2229 |
-
|
|
|
|
|
2230 |
}
|
2231 |
echo "\t</url>\r\n";
|
2232 |
if ( $count >= $max_items ) {
|
@@ -2244,14 +2485,16 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2244 |
*
|
2245 |
* @return null
|
2246 |
*/
|
2247 |
-
function output_sitemap_index( $urls, $comment = '' ) {
|
2248 |
$max_items = 50000;
|
2249 |
if ( ! is_array( $urls ) ) {
|
2250 |
return null;
|
2251 |
}
|
2252 |
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n\r\n";
|
|
|
2253 |
echo '<!-- ' . sprintf( $this->comment_string, $comment, AIOSEOP_VERSION, date( 'D, d M Y H:i:s e' ) ) . " -->\r\n";
|
2254 |
$xsl_url = $this->get_sitemap_xsl();
|
|
|
2255 |
echo '<?xml-stylesheet type="text/xsl" href="' . $xsl_url . '"?>' . "\r\n";
|
2256 |
echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\r\n";
|
2257 |
$count = 0;
|
@@ -2259,14 +2502,18 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2259 |
echo "\t<sitemap>\r\n";
|
2260 |
if ( is_array( $url ) ) {
|
2261 |
foreach ( $url as $k => $v ) {
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
echo "\t\t<$k>$v</$k>\r\n";
|
2266 |
}
|
|
|
|
|
|
|
2267 |
}
|
2268 |
} else {
|
2269 |
-
|
|
|
|
|
2270 |
}
|
2271 |
echo "\t</sitemap>\r\n";
|
2272 |
$count ++;
|
@@ -2285,7 +2532,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2285 |
*
|
2286 |
* @return string
|
2287 |
*/
|
2288 |
-
function build_sitemap_index( $urls, $comment = '' ) {
|
2289 |
ob_start();
|
2290 |
$this->output_sitemap_index( $urls, $comment );
|
2291 |
|
@@ -2301,7 +2548,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2301 |
*
|
2302 |
* @return string
|
2303 |
*/
|
2304 |
-
function build_sitemap( $urls, $sitemap_type, $comment = '' ) {
|
2305 |
ob_start();
|
2306 |
$this->output_sitemap( $urls, $sitemap_type, $comment );
|
2307 |
|
@@ -2315,7 +2562,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2315 |
*
|
2316 |
* @return array
|
2317 |
*/
|
2318 |
-
function get_term_priority_data( $terms ) {
|
2319 |
$prio = array();
|
2320 |
if ( is_array( $terms ) ) {
|
2321 |
$def_prio = $this->get_default_priority( 'taxonomies' );
|
@@ -2323,24 +2570,34 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2323 |
foreach ( $terms as $term ) {
|
2324 |
$pr_info = array();
|
2325 |
$pr_info['loc'] = $this->get_term_link( $term, $term->taxonomy );
|
2326 |
-
if (
|
|
|
|
|
|
|
|
|
2327 |
$pr_info['changefreq'] = $this->options[ $this->prefix . 'freq_taxonomies_' . $term->taxonomy ];
|
2328 |
} else {
|
2329 |
$pr_info['changefreq'] = $def_freq;
|
2330 |
}
|
2331 |
-
if (
|
|
|
|
|
|
|
|
|
2332 |
$pr_info['priority'] = $this->options[ $this->prefix . 'prio_taxonomies_' . $term->taxonomy ];
|
2333 |
} else {
|
2334 |
$pr_info['priority'] = $def_prio;
|
2335 |
}
|
2336 |
|
2337 |
$pr_info['image:image'] = $this->get_images_from_term( $term );
|
|
|
2338 |
$pr_info['rss'] = array(
|
2339 |
-
'title'
|
2340 |
'description' => $term->description,
|
2341 |
-
'pubDate'
|
2342 |
);
|
2343 |
-
|
|
|
2344 |
}
|
2345 |
}
|
2346 |
|
@@ -2355,24 +2612,26 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2355 |
* @return string
|
2356 |
*/
|
2357 |
private function get_date_for_term( $term ) {
|
2358 |
-
$date
|
2359 |
-
$query = new WP_Query(
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
array(
|
2367 |
-
|
2368 |
-
|
|
|
|
|
2369 |
),
|
2370 |
-
)
|
2371 |
-
)
|
2372 |
|
2373 |
if ( $query->have_posts() ) {
|
2374 |
$timestamp = mysql2date( 'U', $query->post->post_modified_gmt );
|
2375 |
-
$date
|
2376 |
}
|
2377 |
|
2378 |
return $date;
|
@@ -2385,7 +2644,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2385 |
*
|
2386 |
* @return array
|
2387 |
*/
|
2388 |
-
function get_term_permalinks( $terms ) {
|
2389 |
$links = array();
|
2390 |
if ( is_array( $terms ) ) {
|
2391 |
foreach ( $terms as $term ) {
|
@@ -2404,7 +2663,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2404 |
*
|
2405 |
* @return array
|
2406 |
*/
|
2407 |
-
function get_archive_permalinks( $posts ) {
|
2408 |
$links = array();
|
2409 |
$archives = array();
|
2410 |
if ( is_array( $posts ) ) {
|
@@ -2430,7 +2689,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2430 |
*
|
2431 |
* @return array
|
2432 |
*/
|
2433 |
-
function get_author_permalinks( $posts ) {
|
2434 |
$links = array();
|
2435 |
$authors = array();
|
2436 |
if ( is_array( $posts ) ) {
|
@@ -2453,7 +2712,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2453 |
*
|
2454 |
* @return array
|
2455 |
*/
|
2456 |
-
function get_post_permalinks( $posts ) {
|
2457 |
$links = array();
|
2458 |
if ( is_array( $posts ) ) {
|
2459 |
foreach ( $posts as $post ) {
|
@@ -2477,7 +2736,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2477 |
*
|
2478 |
* @return string
|
2479 |
*/
|
2480 |
-
function unparse_url( $parsed_url ) {
|
2481 |
$scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
|
2482 |
$host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
|
2483 |
if ( ! empty( $host ) && empty( $scheme ) ) {
|
@@ -2501,14 +2760,16 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2501 |
* @since 2.3.6
|
2502 |
* @since 2.3.12.3 Refactored to use aioseop_home_url() for compatibility purposes.
|
2503 |
*
|
2504 |
-
* @return array
|
2505 |
*/
|
2506 |
-
function get_addl_pages_only() {
|
2507 |
$pages = array();
|
2508 |
if ( ! empty( $this->options[ $this->prefix . 'addl_pages' ] ) ) {
|
|
|
2509 |
$siteurl = parse_url( aioseop_home_url() );
|
2510 |
foreach ( $this->options[ $this->prefix . 'addl_pages' ] as $k => $v ) {
|
2511 |
-
$k
|
|
|
2512 |
$url = parse_url( $k );
|
2513 |
if ( empty( $url['host'] ) ) {
|
2514 |
$url['host'] = $siteurl['host'];
|
@@ -2516,7 +2777,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2516 |
if ( ! empty( $url['path'] ) && substr( $url['path'], 0, 1 ) !== '/' ) {
|
2517 |
$url['path'] = '/' . $url['path'];
|
2518 |
}
|
2519 |
-
$freq =
|
|
|
|
|
2520 |
if ( ! empty( $v['mod'] ) ) {
|
2521 |
$mod = $v['mod'];
|
2522 |
}
|
@@ -2526,10 +2789,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2526 |
if ( ! empty( $v['prio'] ) ) {
|
2527 |
$prio = $v['prio'];
|
2528 |
}
|
2529 |
-
if ( 'no'
|
2530 |
$freq = '';
|
2531 |
}
|
2532 |
-
if ( 'no'
|
2533 |
$prio = '';
|
2534 |
}
|
2535 |
$mod = date( 'Y-m-d\TH:i:s\Z', mysql2date( 'U', $mod ) );
|
@@ -2552,11 +2815,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2552 |
* @since 2.3.6
|
2553 |
* @since 2.3.12.3 Refactored to use aioseop_home_url() for compatibility purposes.
|
2554 |
*
|
2555 |
-
* @return array
|
2556 |
*/
|
2557 |
-
function get_addl_pages() {
|
2558 |
-
$home
|
2559 |
-
$home
|
2560 |
'loc' => aioseop_home_url(),
|
2561 |
'changefreq' => $this->get_default_frequency( 'homepage' ),
|
2562 |
'priority' => $this->get_default_priority( 'homepage' ),
|
@@ -2566,7 +2829,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2566 |
$posts = (int) get_option( 'page_for_posts' );
|
2567 |
if ( $posts ) {
|
2568 |
$posts = $this->get_permalink( $posts );
|
2569 |
-
if ( $posts
|
2570 |
$posts = array();
|
2571 |
} else {
|
2572 |
$posts = array(
|
@@ -2595,7 +2858,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2595 |
*
|
2596 |
* @return array
|
2597 |
*/
|
2598 |
-
function get_addl_page_links() {
|
2599 |
if ( ! empty( $this->options[ $this->prefix . 'addl_pages' ] ) ) {
|
2600 |
return array_keys( $this->options[ $this->prefix . 'addl_pages' ] );
|
2601 |
}
|
@@ -2611,7 +2874,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2611 |
*
|
2612 |
* @return array
|
2613 |
*/
|
2614 |
-
function get_prio_calc( $date, $stats ) {
|
2615 |
static $cur_time = null;
|
2616 |
if ( null === $cur_time ) {
|
2617 |
$cur_time = time();
|
@@ -2662,7 +2925,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2662 |
$prev_days = $max_days;
|
2663 |
}
|
2664 |
|
2665 |
-
return array(
|
|
|
|
|
|
|
|
|
2666 |
}
|
2667 |
|
2668 |
/**
|
@@ -2672,7 +2939,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2672 |
*
|
2673 |
* @return array
|
2674 |
*/
|
2675 |
-
function get_date_archive_prio_from_posts( $posts ) {
|
2676 |
$archives = array();
|
2677 |
if ( is_array( $posts ) ) {
|
2678 |
foreach ( $posts as $p ) {
|
@@ -2692,7 +2959,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2692 |
}
|
2693 |
|
2694 |
if ( ! empty( $archives ) ) {
|
2695 |
-
return $this->get_prio_from_posts(
|
|
|
|
|
|
|
2696 |
array(
|
2697 |
$this,
|
2698 |
'get_date_archive_link_from_post',
|
@@ -2713,12 +2983,18 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2713 |
*/
|
2714 |
private function get_archive_prio_from_posts( $posts ) {
|
2715 |
$posttypes = array();
|
2716 |
-
if ( ! empty( $this->options["{$this->prefix}posttypes"] ) ) {
|
2717 |
-
$posttypes = $this->options["{$this->prefix}posttypes"];
|
2718 |
}
|
2719 |
|
2720 |
-
$types_supporting_archives
|
2721 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2722 |
foreach ( $posts as $p ) {
|
2723 |
if ( array_key_exists( $p->post_type, $types ) ) {
|
2724 |
continue;
|
@@ -2726,17 +3002,21 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2726 |
$types[ $p->post_type ] = $p;
|
2727 |
}
|
2728 |
|
2729 |
-
$archives
|
2730 |
-
$types
|
2731 |
if ( $types ) {
|
2732 |
foreach ( $types as $post_type => $p ) {
|
|
|
2733 |
if ( ! ( in_array( $post_type, $posttypes ) && in_array( $post_type, $types_supporting_archives ) ) ) {
|
2734 |
continue;
|
2735 |
}
|
2736 |
-
$archives
|
2737 |
$archives,
|
2738 |
$this->get_prio_from_posts(
|
2739 |
-
array( $p ),
|
|
|
|
|
|
|
2740 |
$this,
|
2741 |
'get_archive_link_from_post',
|
2742 |
)
|
@@ -2754,7 +3034,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2754 |
*
|
2755 |
* @return bool|string
|
2756 |
*/
|
2757 |
-
function get_archive_link_from_post( $post ) {
|
2758 |
return get_post_type_archive_link( $post->post_type );
|
2759 |
}
|
2760 |
|
@@ -2765,7 +3045,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2765 |
*
|
2766 |
* @return bool|string
|
2767 |
*/
|
2768 |
-
function get_date_archive_link_from_post( $post ) {
|
2769 |
$extra = array();
|
2770 |
if ( 'post' !== $post->post_type ) {
|
2771 |
return false;
|
@@ -2782,7 +3062,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2782 |
*
|
2783 |
* @return array
|
2784 |
*/
|
2785 |
-
function get_author_prio_from_posts( $posts ) {
|
2786 |
$authors = array();
|
2787 |
if ( is_array( $posts ) ) {
|
2788 |
foreach ( $posts as $p ) {
|
@@ -2799,7 +3079,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2799 |
}
|
2800 |
}
|
2801 |
|
2802 |
-
return $this->get_prio_from_posts(
|
|
|
|
|
|
|
2803 |
array(
|
2804 |
$this,
|
2805 |
'get_author_link_from_post',
|
@@ -2815,7 +3098,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2815 |
*
|
2816 |
* @return string
|
2817 |
*/
|
2818 |
-
function get_author_link_from_post( $post ) {
|
2819 |
return get_author_posts_url( $post->post_author );
|
2820 |
}
|
2821 |
|
@@ -2826,7 +3109,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2826 |
*
|
2827 |
* @return array|int
|
2828 |
*/
|
2829 |
-
function get_comment_count_stats( $posts ) {
|
2830 |
$count = 0;
|
2831 |
$total = 0.0;
|
2832 |
$min = null;
|
@@ -2850,7 +3133,12 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2850 |
}
|
2851 |
}
|
2852 |
if ( $count ) {
|
2853 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
2854 |
} else {
|
2855 |
return 0;
|
2856 |
}
|
@@ -2867,7 +3155,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2867 |
*
|
2868 |
* @return array
|
2869 |
*/
|
2870 |
-
function get_prio_from_posts( $posts, $prio_override = false, $freq_override = false, $linkfunc = 'get_permalink', $type = 'post' ) {
|
2871 |
$prio = array();
|
2872 |
$args = array(
|
2873 |
'prio_override' => $prio_override,
|
@@ -2882,13 +3170,13 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2882 |
if ( is_array( $posts ) ) {
|
2883 |
foreach ( $posts as $key => $post ) {
|
2884 |
// Determine if we check the post for images.
|
2885 |
-
$is_single
|
2886 |
$post->filter = 'sample';
|
2887 |
-
$timestamp
|
2888 |
if ( 'get_permalink' === $linkfunc ) {
|
2889 |
$url = $this->get_permalink( $post );
|
2890 |
} else {
|
2891 |
-
$url
|
2892 |
$is_single = false;
|
2893 |
}
|
2894 |
|
@@ -2903,12 +3191,16 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2903 |
}
|
2904 |
if ( '0000-00-00 00:00:00' !== $date ) {
|
2905 |
$timestamp = $date;
|
2906 |
-
$date
|
2907 |
} else {
|
2908 |
$date = 0;
|
2909 |
}
|
2910 |
if ( $prio_override && $freq_override ) {
|
2911 |
-
$pr_info = array(
|
|
|
|
|
|
|
|
|
2912 |
} else {
|
2913 |
if ( empty( $post->comment_count ) ) {
|
2914 |
$stat = 0;
|
@@ -2927,12 +3219,18 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2927 |
$pr_info['priority'] = $prio_override;
|
2928 |
}
|
2929 |
if ( ( 'sel' === $this->options[ $this->prefix . 'prio_post' ] ) && isset( $this->options[ $this->prefix . 'prio_post_' . $post->post_type ] ) ) {
|
2930 |
-
if (
|
|
|
|
|
|
|
2931 |
$pr_info['priority'] = $this->options[ $this->prefix . 'prio_post_' . $post->post_type ];
|
2932 |
}
|
2933 |
}
|
2934 |
if ( ( 'sel' === $this->options[ $this->prefix . 'freq_post' ] ) && isset( $this->options[ $this->prefix . 'freq_post_' . $post->post_type ] ) ) {
|
2935 |
-
if (
|
|
|
|
|
|
|
2936 |
$pr_info['changefreq'] = $this->options[ $this->prefix . 'freq_post_' . $post->post_type ];
|
2937 |
}
|
2938 |
}
|
@@ -2956,18 +3254,18 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2956 |
}
|
2957 |
|
2958 |
// RSS expects the GMT date.
|
2959 |
-
$timestamp
|
2960 |
$pr_info['rss'] = array(
|
2961 |
-
'title'
|
2962 |
'description' => $this->get_the_excerpt( $post ),
|
2963 |
-
'pubDate'
|
2964 |
-
'timestamp' => $timestamp,
|
2965 |
-
'post_type'
|
2966 |
);
|
2967 |
}
|
2968 |
|
2969 |
-
|
2970 |
$pr_info['image:image'] = $is_single ? $this->get_images_from_post( $post ) : null;
|
|
|
2971 |
$pr_info = apply_filters( $this->prefix . 'prio_item_filter', $pr_info, $post, $args );
|
2972 |
if ( ! empty( $pr_info ) ) {
|
2973 |
$prio[] = $pr_info;
|
@@ -2995,8 +3293,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
2995 |
$text = strip_shortcodes( $post->post_content );
|
2996 |
$text = apply_filters( 'the_content', $text );
|
2997 |
$text = str_replace( ']]>', ']]>', $text );
|
|
|
2998 |
$excerpt_length = apply_filters( 'excerpt_length', 55 );
|
2999 |
-
$excerpt_more
|
3000 |
return wp_trim_words( $text, $excerpt_length, $excerpt_more );
|
3001 |
}
|
3002 |
return '';
|
@@ -3018,7 +3317,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3018 |
return array();
|
3019 |
}
|
3020 |
|
3021 |
-
$images
|
3022 |
// the table term meta table is not defined for lower versions.
|
3023 |
if ( version_compare( $wp_version, '4.4.0', '>=' ) ) {
|
3024 |
$thumbnail_id = get_term_meta( $term->term_id, 'thumbnail_id', true );
|
@@ -3040,15 +3339,13 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3040 |
/**
|
3041 |
* Return the images from the post.
|
3042 |
*
|
3043 |
-
* @param WP_Post $post the post object.
|
3044 |
*
|
3045 |
* @since 2.4
|
3046 |
*
|
3047 |
* @return array
|
3048 |
*/
|
3049 |
private function get_images_from_post( $post ) {
|
3050 |
-
global $wp_version;
|
3051 |
-
|
3052 |
if ( ! aiosp_include_images() ) {
|
3053 |
return array();
|
3054 |
}
|
@@ -3106,7 +3403,6 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3106 |
}
|
3107 |
}
|
3108 |
|
3109 |
-
$content = '';
|
3110 |
$content = $post->post_content;
|
3111 |
|
3112 |
$this->get_gallery_images( $post, $images );
|
@@ -3120,16 +3416,19 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3120 |
// Filter out duplicates.
|
3121 |
$tmp = array_unique( $images );
|
3122 |
}
|
|
|
3123 |
// remove any invalid/empty images.
|
3124 |
$tmp = array_filter( $images, array( $this, 'is_image_valid' ) );
|
|
|
3125 |
$images = array();
|
3126 |
foreach ( $tmp as $image ) {
|
3127 |
-
$image_attributes
|
|
|
3128 |
$images[] = array_merge(
|
3129 |
-
|
3130 |
-
|
3131 |
-
|
3132 |
-
|
3133 |
);
|
3134 |
}
|
3135 |
}
|
@@ -3141,15 +3440,17 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3141 |
* Fetch image attributes such as title and caption given the image URL.
|
3142 |
*
|
3143 |
* @param string $url The image URL.
|
|
|
3144 |
*/
|
3145 |
private function get_image_attributes( $url ) {
|
3146 |
-
$attributes = array();
|
3147 |
global $wpdb;
|
3148 |
-
$
|
|
|
|
|
3149 |
if ( $attachment && is_array( $attachment ) && is_numeric( $attachment[0] ) ) {
|
3150 |
-
$attributes
|
3151 |
'image:caption' => wp_get_attachment_caption( $attachment[0] ),
|
3152 |
-
'image:title'
|
3153 |
);
|
3154 |
}
|
3155 |
return $attributes;
|
@@ -3158,8 +3459,8 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3158 |
/**
|
3159 |
* Fetch images from WP, Jetpack and WooCommerce galleries.
|
3160 |
*
|
3161 |
-
* @param
|
3162 |
-
* @param array
|
3163 |
*
|
3164 |
* @since 2.4.2
|
3165 |
*/
|
@@ -3172,10 +3473,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3172 |
if ( has_shortcode( $post->post_content, 'gallery' ) ) {
|
3173 |
// Get the jetpack gallery images.
|
3174 |
if ( class_exists( 'Jetpack_PostImages' ) ) {
|
3175 |
-
$jetpack
|
3176 |
if ( $jetpack ) {
|
3177 |
foreach ( $jetpack as $jetpack_image ) {
|
3178 |
-
$images[]
|
3179 |
}
|
3180 |
}
|
3181 |
}
|
@@ -3217,16 +3518,17 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3217 |
*/
|
3218 |
private function get_content_from_galleries( $content ) {
|
3219 |
// Support for NextGen Gallery.
|
3220 |
-
static $gallery_types
|
3221 |
-
$types = apply_filters( 'aioseop_gallery_shortcodes', $gallery_types );
|
3222 |
|
3223 |
-
$
|
|
|
|
|
3224 |
|
3225 |
if ( ! $types ) {
|
3226 |
return $gallery_content;
|
3227 |
}
|
3228 |
|
3229 |
-
$found
|
3230 |
if ( $types ) {
|
3231 |
foreach ( $types as $type ) {
|
3232 |
if ( has_shortcode( $content, $type ) ) {
|
@@ -3265,11 +3567,13 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3265 |
// Recreate the shortcodes and then render them to get the HTML content.
|
3266 |
if ( $galleries ) {
|
3267 |
foreach ( $galleries as $shortcode => $attributes ) {
|
3268 |
-
$code
|
|
|
3269 |
foreach ( $attributes as $key => $value ) {
|
3270 |
-
$code
|
3271 |
}
|
3272 |
$code .= ']';
|
|
|
3273 |
$gallery_content .= do_shortcode( $code );
|
3274 |
}
|
3275 |
}
|
@@ -3286,13 +3590,13 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3286 |
*
|
3287 |
* @return string
|
3288 |
*/
|
3289 |
-
function clean_url( $url ) {
|
3290 |
// remove the query string.
|
3291 |
-
$url
|
3292 |
// make the url XML-safe.
|
3293 |
-
$url
|
3294 |
// Make the url absolute, if its relative.
|
3295 |
-
$url
|
3296 |
return apply_filters( 'aioseop_clean_url', $url );
|
3297 |
}
|
3298 |
|
@@ -3308,7 +3612,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3308 |
*
|
3309 |
* @return bool
|
3310 |
*/
|
3311 |
-
function is_image_valid( $image ) {
|
3312 |
global $wp_version;
|
3313 |
|
3314 |
// Bail if empty image.
|
@@ -3318,36 +3622,38 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3318 |
|
3319 |
global $wp_version;
|
3320 |
if ( version_compare( $wp_version, '4.4', '<' ) ) {
|
|
|
3321 |
$p_url = parse_url( $image );
|
3322 |
-
$url
|
3323 |
} elseif ( version_compare( $wp_version, '4.7', '<' ) ) {
|
3324 |
// Compatability for older WP version that don't have 4.7 changes.
|
3325 |
// @link https://core.trac.wordpress.org/changeset/38726
|
3326 |
$p_url = wp_parse_url( $image );
|
3327 |
-
$url
|
3328 |
} else {
|
3329 |
$component = PHP_URL_PATH;
|
3330 |
-
$url
|
3331 |
}
|
3332 |
|
3333 |
// make the url absolute, if its relative.
|
3334 |
-
$image
|
3335 |
-
|
3336 |
-
$extn
|
3337 |
-
$allowed
|
3338 |
// Bail if image does not refer to an image file otherwise google webmaster tools might reject the sitemap.
|
3339 |
if ( ! in_array( $extn, $allowed, true ) ) {
|
3340 |
return false;
|
3341 |
}
|
3342 |
|
|
|
3343 |
$image_host = parse_url( $image, PHP_URL_HOST );
|
3344 |
$host = parse_url( home_url(), PHP_URL_HOST );
|
3345 |
|
3346 |
if ( $image_host !== $host ) {
|
3347 |
// Allowed hosts will be provided in a wildcard format i.e. img.yahoo.* or *.akamai.*.
|
3348 |
// And we will convert that into a regular expression for matching.
|
3349 |
-
$whitelist
|
3350 |
-
$allowed
|
3351 |
if ( $whitelist ) {
|
3352 |
foreach ( $whitelist as $pattern ) {
|
3353 |
if ( preg_match( '/' . str_replace( '*', '.*', $pattern ) . '/', $image_host ) === 1 ) {
|
@@ -3368,9 +3674,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3368 |
* @param string $content the post content.
|
3369 |
* @param array $images the array of images.
|
3370 |
*/
|
3371 |
-
function parse_content_for_images( $content, &$images ) {
|
3372 |
// These tags should be WITHOUT trailing space because some plugins such as the nextgen gallery put newlines immediately after <img.
|
3373 |
-
$total
|
3374 |
// no images found.
|
3375 |
if ( 0 === $total ) {
|
3376 |
return;
|
@@ -3378,11 +3684,14 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3378 |
|
3379 |
if ( class_exists( 'DOMDocument' ) ) {
|
3380 |
$dom = new domDocument();
|
|
|
3381 |
// Non-compliant HTML might give errors, so ignore them.
|
3382 |
libxml_use_internal_errors( true );
|
3383 |
$dom->loadHTML( $content );
|
3384 |
libxml_clear_errors();
|
|
|
3385 |
$dom->preserveWhiteSpace = false;
|
|
|
3386 |
$matches = $dom->getElementsByTagName( 'img' );
|
3387 |
foreach ( $matches as $match ) {
|
3388 |
$images[] = $match->getAttribute( 'src' );
|
@@ -3409,7 +3718,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3409 |
*
|
3410 |
* @return array
|
3411 |
*/
|
3412 |
-
function get_tax_args( $page = 0 ) {
|
3413 |
$args = array();
|
3414 |
if ( $this->option_isset( 'excl_categories' ) ) {
|
3415 |
$args['exclude'] = $this->options[ $this->prefix . 'excl_categories' ];
|
@@ -3431,7 +3740,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3431 |
*
|
3432 |
* @return mixed
|
3433 |
*/
|
3434 |
-
function set_post_args( $args ) {
|
3435 |
if ( $this->option_isset( 'excl_categories' ) ) {
|
3436 |
$cats = array();
|
3437 |
foreach ( $this->options[ $this->prefix . 'excl_categories' ] as $c ) {
|
@@ -3451,10 +3760,10 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3451 |
*
|
3452 |
* @return array
|
3453 |
*/
|
3454 |
-
function get_date_archive_prio_data() {
|
3455 |
$args = array(
|
3456 |
'numberposts' => 50000,
|
3457 |
-
'post_type'
|
3458 |
);
|
3459 |
$args = $this->set_post_args( $args );
|
3460 |
$posts = $this->get_all_post_type_data( $args );
|
@@ -3467,8 +3776,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3467 |
*
|
3468 |
* @return array
|
3469 |
*/
|
3470 |
-
function get_author_prio_data() {
|
3471 |
-
$args = array(
|
|
|
|
|
|
|
3472 |
$args = $this->set_post_args( $args );
|
3473 |
$posts = $this->get_all_post_type_data( $args );
|
3474 |
|
@@ -3484,27 +3796,35 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3484 |
*
|
3485 |
* @return array
|
3486 |
*/
|
3487 |
-
function get_all_post_priority_data( $include = 'any', $status = 'publish', $page = 0 ) {
|
3488 |
-
$posts
|
|
|
3489 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
3490 |
$page_query = array( 'offset' => $page * $this->max_posts );
|
3491 |
}
|
3492 |
if ( ( 'publish' === $status ) && ( 'attachment' === $include ) ) {
|
3493 |
$status = 'inherit';
|
3494 |
}
|
|
|
3495 |
if ( is_array( $include ) && ( ( $pos = array_search( 'attachment', $include ) ) !== false ) ) {
|
3496 |
unset( $include[ $pos ] );
|
3497 |
-
$att_args = array(
|
|
|
|
|
|
|
3498 |
$att_args = array_merge( $att_args, $page_query );
|
3499 |
$posts = $this->get_all_post_type_data( $att_args );
|
3500 |
}
|
3501 |
-
$args = array(
|
|
|
|
|
|
|
3502 |
$args = array_merge( $args, $page_query );
|
3503 |
$args = $this->set_post_args( $args );
|
3504 |
$posts = array_merge( $this->get_all_post_type_data( $args ), $posts );
|
3505 |
|
3506 |
-
$links
|
3507 |
-
$links
|
3508 |
return $links;
|
3509 |
}
|
3510 |
|
@@ -3516,8 +3836,11 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3516 |
*
|
3517 |
* @return array
|
3518 |
*/
|
3519 |
-
function get_all_permalinks( $include = 'any', $status = 'publish' ) {
|
3520 |
-
$args = array(
|
|
|
|
|
|
|
3521 |
$args = $this->set_post_args( $args );
|
3522 |
$posts = $this->get_all_post_type_data( $args );
|
3523 |
$links = $this->get_post_permalinks( $posts );
|
@@ -3538,7 +3861,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3538 |
*
|
3539 |
* @return null
|
3540 |
*/
|
3541 |
-
function cache_structure( $pre ) {
|
3542 |
return $this->cache_struct;
|
3543 |
}
|
3544 |
|
@@ -3549,14 +3872,14 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3549 |
*
|
3550 |
* @return null
|
3551 |
*/
|
3552 |
-
function cache_home( $pre ) {
|
3553 |
return $this->cache_home;
|
3554 |
}
|
3555 |
|
3556 |
/**
|
3557 |
* Cache permalink_structure and home for repeated sitemap queries.
|
3558 |
*/
|
3559 |
-
function cache_options() {
|
3560 |
static $start = true;
|
3561 |
if ( $start ) {
|
3562 |
$this->cache_struct = get_option( 'permalink_structure' );
|
@@ -3579,7 +3902,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3579 |
*
|
3580 |
* @return string|WP_Error
|
3581 |
*/
|
3582 |
-
function get_term_link( $term, $taxonomy = '' ) {
|
3583 |
static $start = true;
|
3584 |
if ( $start ) {
|
3585 |
$this->cache_options();
|
@@ -3596,7 +3919,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3596 |
*
|
3597 |
* @return false|string
|
3598 |
*/
|
3599 |
-
function get_permalink( $post ) {
|
3600 |
static $start = true;
|
3601 |
if ( $start ) {
|
3602 |
$this->cache_options();
|
@@ -3611,11 +3934,12 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3611 |
*
|
3612 |
* @param $args
|
3613 |
*
|
3614 |
-
* @return array|int|mixed|null|
|
3615 |
*/
|
3616 |
-
function get_all_term_counts( $args ) {
|
3617 |
$term_counts = null;
|
3618 |
if ( ! empty( $args ) && ! empty( $args['taxonomy'] ) ) {
|
|
|
3619 |
if ( ! is_array( $args['taxonomy'] ) || ( count( $args['taxonomy'] ) == 1 ) ) {
|
3620 |
if ( is_array( $args['taxonomy'] ) ) {
|
3621 |
$args['taxonomy'] = array_shift( $args['taxonomy'] );
|
@@ -3643,7 +3967,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3643 |
*
|
3644 |
* @return array
|
3645 |
*/
|
3646 |
-
function get_all_post_counts( $args ) {
|
3647 |
$post_counts = array();
|
3648 |
$status = 'inherit';
|
3649 |
if ( ! empty( $args['post_status'] ) ) {
|
@@ -3660,7 +3984,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3660 |
$count_args['post_status'] = 'inherit';
|
3661 |
}
|
3662 |
|
3663 |
-
$count_args['post_type']
|
3664 |
$post_counts[ $post_type ] = $this->get_post_count( $count_args );
|
3665 |
}
|
3666 |
}
|
@@ -3674,7 +3998,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3674 |
*
|
3675 |
* @param $args
|
3676 |
*/
|
3677 |
-
function modify_post_params_for_external_plugins( &$args ) {
|
3678 |
// if WPML is being used, do not suppress filters.
|
3679 |
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
3680 |
$args['suppress_filters'] = false;
|
@@ -3690,7 +4014,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3690 |
*
|
3691 |
* @return int
|
3692 |
*/
|
3693 |
-
function get_post_count( $args ) {
|
3694 |
$this->modify_post_params_for_external_plugins( $args );
|
3695 |
|
3696 |
// we will use WP_Query instead of get_posts here as that is more efficient.
|
@@ -3713,7 +4037,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3713 |
*
|
3714 |
* @return int
|
3715 |
*/
|
3716 |
-
function get_total_post_count( $args ) {
|
3717 |
$total = 0;
|
3718 |
$counts = $this->get_all_post_counts( $args );
|
3719 |
if ( ! empty( $counts ) ) {
|
@@ -3730,9 +4054,9 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3730 |
*
|
3731 |
* @param $args
|
3732 |
*
|
3733 |
-
* @return array|mixed
|
3734 |
*/
|
3735 |
-
function get_all_post_type_data( $args ) {
|
3736 |
$defaults = array(
|
3737 |
'numberposts' => $this->max_posts,
|
3738 |
'offset' => 0,
|
@@ -3770,7 +4094,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3770 |
$exclude = preg_split( '/[\s,]+/', trim( $args['exclude'] ) );
|
3771 |
if ( ! empty( $exclude ) ) {
|
3772 |
foreach ( $exclude as $k => $v ) {
|
3773 |
-
if ( ! is_numeric( $v )
|
3774 |
$exclude_slugs[] = $v;
|
3775 |
unset( $exclude[ $k ] );
|
3776 |
}
|
@@ -3800,6 +4124,7 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3800 |
$posts = get_posts( apply_filters( $this->prefix . 'post_query', $args ) );
|
3801 |
if ( ! empty( $exclude_slugs ) ) {
|
3802 |
foreach ( $posts as $k => $v ) {
|
|
|
3803 |
if ( in_array( $v->post_name, $exclude_slugs ) ) {
|
3804 |
unset( $posts[ $k ] );
|
3805 |
}
|
@@ -3810,4 +4135,4 @@ if ( ! class_exists( 'All_in_One_SEO_Pack_Sitemap' ) ) {
|
|
3810 |
return $posts;
|
3811 |
}
|
3812 |
}
|
3813 |
-
}
|
15 |
* @since 2.4 Include images in sitemap.
|
16 |
*/
|
17 |
class All_in_One_SEO_Pack_Sitemap extends All_in_One_SEO_Pack_Module {
|
18 |
+
/**
|
19 |
+
* Cache Struct (Strict|Structure)
|
20 |
+
*
|
21 |
+
* Is set by `get_option( 'permalink_structure' )`.
|
22 |
+
*
|
23 |
+
* @since ?
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
public $cache_struct = null;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Is set by `get_option( 'home' )`. Seems the equivalent of `home_url()`.
|
30 |
+
*
|
31 |
+
* @since ?
|
32 |
+
* @var string?
|
33 |
+
*/
|
34 |
+
public $cache_home = null;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* (Plugin) Comment String
|
38 |
+
*
|
39 |
+
* A Label String to add to the sitemap to indicate AIOSEOP generated the sitemap.
|
40 |
+
*
|
41 |
+
* @todo Set value could be moved from the constructor to the variable's default/initial value;
|
42 |
+
*
|
43 |
+
* @since ?
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
public $comment_string;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Start Memory Usage
|
50 |
+
*
|
51 |
+
* Is set by PHP's `memory_get_peak_usage()`.
|
52 |
+
*
|
53 |
+
* @since ?
|
54 |
+
* @var int
|
55 |
+
*/
|
56 |
+
public $start_memory_usage = 0;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Max Posts
|
60 |
+
*
|
61 |
+
* For Sitemap setting "Maximum Posts per Sitemap Page" when "Enable Sitemap Indexes" is checked/enabled.
|
62 |
+
*
|
63 |
+
* @since ?
|
64 |
+
* @var int
|
65 |
+
*/
|
66 |
+
public $max_posts = 50000;
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Priority
|
70 |
+
*
|
71 |
+
* @todo Needs more detail.
|
72 |
+
*
|
73 |
+
* @since ?
|
74 |
+
* @var array
|
75 |
+
*/
|
76 |
+
public $prio;
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Priority Selected
|
80 |
+
*
|
81 |
+
* @todo Needs more detail.
|
82 |
+
*
|
83 |
+
* @since ?
|
84 |
+
* @var array
|
85 |
+
*/
|
86 |
+
public $prio_sel;
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Frequency
|
90 |
+
*
|
91 |
+
* @todo Needs more detail.
|
92 |
+
*
|
93 |
+
* @since ?
|
94 |
+
* @var array
|
95 |
+
*/
|
96 |
+
public $freq;
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Frequency Selected
|
100 |
+
*
|
101 |
+
* @todo Needs more detail.
|
102 |
+
*
|
103 |
+
* @since ?
|
104 |
+
* @var array
|
105 |
+
*/
|
106 |
+
public $freq_sel;
|
107 |
|
108 |
/**
|
109 |
+
* Extra Sitemaps
|
110 |
+
*
|
111 |
+
* @todo Needs more detail.
|
112 |
+
*
|
113 |
+
* @since ?
|
114 |
+
* @var mixed|void
|
115 |
+
*/
|
116 |
+
public $extra_sitemaps;
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Excludes
|
120 |
+
*
|
121 |
+
* Excludes slugs and IDs.
|
122 |
+
*
|
123 |
+
* @todo Needs more detail. Does this include all Categories and Pages/Posts? ...and what about Tags?
|
124 |
+
*
|
125 |
+
* @since ?
|
126 |
+
* @var array
|
127 |
+
*/
|
128 |
+
public $excludes = array();
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Image Extensions.
|
132 |
+
*
|
133 |
* The allowed image extensions.
|
134 |
*
|
135 |
+
* @var array $image_extensions The allowed image extensions.
|
136 |
*/
|
137 |
+
private static $image_extensions = array(
|
138 |
'jpg',
|
139 |
'jpeg',
|
140 |
'png',
|
144 |
/**
|
145 |
* All_in_One_SEO_Pack_Sitemap constructor.
|
146 |
*/
|
147 |
+
public function __construct() {
|
148 |
if ( get_class( $this ) === 'All_in_One_SEO_Pack_Sitemap' ) { // Set this up only when instantiated as this class.
|
149 |
$this->name = __( 'XML Sitemap', 'all-in-one-seo-pack' ); // Human-readable name of the plugin.
|
150 |
$this->prefix = 'aiosp_sitemap_'; // Option prefix.
|
153 |
$this->extra_sitemaps = apply_filters( $this->prefix . 'extra', $this->extra_sitemaps );
|
154 |
}
|
155 |
parent::__construct();
|
156 |
+
// TODO This could be move up to the class field default/initial values.
|
157 |
$this->comment_string = 'Sitemap %s generated by All in One SEO Pack %s by Michael Torbert of Semper Fi Web Design on %s';
|
158 |
|
159 |
$this->help_text = array(
|
160 |
+
'rss_sitemap' => __( 'Create RSS Sitemap as well.', 'all-in-one-seo-pack' ),
|
161 |
'daily_cron' => __( 'Notify search engines based on the selected schedule, and also update static sitemap daily if in use. (this uses WP-Cron, so make sure this is working properly on your server as well)', 'all-in-one-seo-pack' ),
|
162 |
'indexes' => __( 'Organize sitemap entries into distinct files in your sitemap. Enable this only if your sitemap contains over 50,000 URLs or the file is over 5MB in size.', 'all-in-one-seo-pack' ),
|
163 |
'max_posts' => __( 'Allows you to specify the maximum number of posts in a sitemap (up to 50,000).', 'all-in-one-seo-pack' ),
|
178 |
);
|
179 |
|
180 |
$this->help_anchors = array(
|
181 |
+
'rss_sitemap' => '#create-rss_sitemap',
|
182 |
'daily_cron' => '#schedule-updates',
|
183 |
'indexes' => '#enable-sitemap-indexes',
|
184 |
'max_posts' => '#enable-sitemap-indexes',
|
199 |
);
|
200 |
|
201 |
$this->default_options = array(
|
202 |
+
'rss_sitemap' => array( 'name' => __( 'Create RSS Sitemap', 'all-in-one-seo-pack' ) ),
|
203 |
+
'daily_cron' => array(
|
204 |
'name' => __( 'Schedule Updates', 'all-in-one-seo-pack' ),
|
205 |
'type' => 'select',
|
206 |
'initial_options' => array(
|
211 |
),
|
212 |
'default' => 0,
|
213 |
),
|
214 |
+
'indexes' => array( 'name' => __( 'Enable Sitemap Indexes', 'all-in-one-seo-pack' ) ),
|
215 |
+
'max_posts' => array(
|
216 |
'name' => __( 'Maximum Posts Per Sitemap Page', 'all-in-one-seo-pack' ),
|
217 |
'type' => 'text',
|
218 |
'default' => 50000,
|
219 |
+
'condshow' => array(
|
220 |
+
"{$this->prefix}indexes" => 'on',
|
221 |
+
"{$this->prefix}indexes" => 'on',
|
222 |
+
),
|
223 |
),
|
224 |
+
'posttypes' => array(
|
225 |
'name' => __( 'Post Types', 'all-in-one-seo-pack' ),
|
226 |
'type' => 'multicheckbox',
|
227 |
'default' => 'all',
|
228 |
),
|
229 |
+
'taxonomies' => array(
|
230 |
'name' => __( 'Taxonomies', 'all-in-one-seo-pack' ),
|
231 |
'type' => 'multicheckbox',
|
232 |
'default' => 'all',
|
233 |
),
|
234 |
+
'archive' => array( 'name' => __( 'Include Date Archive Pages', 'all-in-one-seo-pack' ) ),
|
235 |
+
'author' => array( 'name' => __( 'Include Author Pages', 'all-in-one-seo-pack' ) ),
|
236 |
+
'images' => array( 'name' => __( 'Exclude Images', 'all-in-one-seo-pack' ) ),
|
237 |
+
'gzipped' => array(
|
238 |
'name' => __( 'Create Compressed Sitemap', 'all-in-one-seo-pack' ),
|
239 |
'default' => 'On',
|
240 |
),
|
241 |
+
'robots' => array(
|
242 |
'name' => __( 'Link From Virtual Robots.txt', 'all-in-one-seo-pack' ),
|
243 |
'default' => 'On',
|
244 |
),
|
245 |
+
'rewrite' => array(
|
246 |
'name' => __( 'Dynamically Generate Sitemap', 'all-in-one-seo-pack' ),
|
247 |
'default' => 'On',
|
248 |
),
|
249 |
);
|
250 |
|
251 |
$status_options = array(
|
252 |
+
'link' => array(
|
253 |
+
'default' => '',
|
254 |
+
'type' => 'html',
|
255 |
+
'label' => 'none',
|
256 |
+
'save' => false,
|
257 |
+
),
|
258 |
);
|
259 |
|
260 |
$this->layout = array(
|
313 |
|
314 |
$arr[ $k . '_' . $opt ] = array(
|
315 |
'name' => $this->ucwords( $val ),
|
316 |
+
/* translators: Help Text string to display information about multiple different settings. */
|
317 |
'help_text' => sprintf( __( 'Manually set the %1$s of your %2$s.', 'all-in-one-seo-pack' ), $v, $val ),
|
318 |
'type' => 'select',
|
319 |
'initial_options' => $iopts,
|
382 |
'type' => 'multicheckbox',
|
383 |
'initial_options' => '',
|
384 |
),
|
385 |
+
'excl_pages' => array(
|
386 |
+
'name' => __( 'Excluded Pages', 'all-in-one-seo-pack' ),
|
387 |
+
'type' => 'text',
|
388 |
+
),
|
389 |
);
|
390 |
|
391 |
$this->layout['addl_pages'] = array(
|
403 |
$this->layout['priorities'] = array(
|
404 |
'name' => __( 'Priorities', 'all-in-one-seo-pack' ),
|
405 |
'help_link' => 'https://semperplugins.com/documentation/xml-sitemaps-module/#priorities-and-frequencies',
|
406 |
+
// TODO Fix undefined variable.
|
407 |
'options' => array_keys( $prio_options ),
|
408 |
);
|
409 |
|
410 |
$this->layout['frequencies'] = array(
|
411 |
'name' => __( 'Frequencies', 'all-in-one-seo-pack' ),
|
412 |
'help_link' => 'https://semperplugins.com/documentation/xml-sitemaps-module/#priorities-and-frequencies',
|
413 |
+
// TODO Fix undefined variable.
|
414 |
'options' => array_keys( $freq_options ),
|
415 |
);
|
416 |
|
419 |
$this->add_help_text_links();
|
420 |
|
421 |
add_action(
|
422 |
+
'after_doing_aioseop_updates',
|
423 |
+
array(
|
424 |
$this,
|
425 |
'do_sitemaps',
|
426 |
)
|
443 |
*
|
444 |
* @since 2.4.1
|
445 |
*/
|
446 |
+
public function sitemap_notices() {
|
447 |
|
448 |
$sitemap_max_url_notice_dismissed = get_user_meta( get_current_user_id(), 'aioseop_sitemap_max_url_notice_dismissed', true );
|
449 |
if ( ! empty( $sitemap_max_url_notice_dismissed ) ) {
|
454 |
|
455 |
$options = $this->options;
|
456 |
|
457 |
+
if (
|
458 |
+
isset( $options[ "{$this->prefix}indexes" ] ) &&
|
459 |
+
'on ' !== $options[ "{$this->prefix}indexes" ] &&
|
460 |
+
1001 < $options[ "{$this->prefix}max_posts" ]
|
461 |
+
) {
|
462 |
|
463 |
$post_counts = $this->get_total_post_count(
|
464 |
array(
|
472 |
$num_terms = array_sum( $term_counts );
|
473 |
}
|
474 |
|
475 |
+
// TODO Fix undefined variable.
|
476 |
$sitemap_urls = $post_counts + $num_terms;
|
477 |
|
478 |
if ( 1001 > $sitemap_urls ) {
|
482 |
$aioseop_plugin_dirname = AIOSEOP_PLUGIN_DIRNAME;
|
483 |
|
484 |
printf(
|
485 |
+
'<div id="message" class="notice-warning notice is-dismissible aioseop-notice sitemap_max_urls_notice visibility-notice">' .
|
486 |
+
'<p>' .
|
487 |
+
'<strong>%1$s</strong><br />' .
|
488 |
+
'%2$s' .
|
489 |
+
'</p>' .
|
490 |
+
'</div>',
|
491 |
+
// TODO Add esc_* or wp_kses function or _e().
|
492 |
__( 'Notice: To avoid problems with your XML Sitemap, we strongly recommend you enable Sitemap Indexes and set the Maximum Posts per Sitemap Page to 1000.', 'all-in-one-seo-pack' ),
|
493 |
+
sprintf(
|
494 |
+
// TODO Add esc_* or wp_kses function.
|
495 |
+
/* translators: Links to the current AIOSEOP Sitemap settings. */
|
496 |
+
__( '%1$s Click here%2$s to make these recommended changes.', 'all-in-one-seo-pack' ),
|
497 |
+
sprintf(
|
498 |
+
'<a href="%s">',
|
499 |
+
esc_url( get_admin_url( null, "admin.php?page=$aioseop_plugin_dirname/modules/aioseop_sitemap.php" ) )
|
500 |
+
),
|
501 |
+
'</a>'
|
502 |
+
)
|
503 |
);
|
504 |
}
|
505 |
}
|
511 |
* @param $old_status
|
512 |
* @param $post
|
513 |
*/
|
514 |
+
public function update_sitemap_from_posts( $new_status, $old_status, $post ) {
|
515 |
|
516 |
if ( $this->option_isset( 'rewrite' ) ) {
|
517 |
// TODO if dynamic, delete transient (we currently don't do transients).
|
534 |
|
535 |
if ( defined( 'AIOSEOP_UNIT_TESTING' ) ) {
|
536 |
$this->do_sitemaps();
|
537 |
+
} elseif ( ! has_action( 'shutdown', array( $this, 'do_sitemaps' ) ) ) {
|
538 |
/**
|
539 |
* Defer do_sitemaps until after everything is done.
|
540 |
* And run it only once regardless of posts updated.
|
541 |
*/
|
542 |
+
add_action( 'shutdown', array( $this, 'do_sitemaps' ) );
|
543 |
}
|
544 |
}
|
545 |
|
554 |
*
|
555 |
* @return mixed
|
556 |
*/
|
557 |
+
public function add_cron_schedules( $schedules ) {
|
558 |
$schedules['weekly'] = array(
|
559 |
'interval' => 604800, // 1 week in seconds.
|
560 |
'display' => __( 'Once Weekly', 'all-in-one-seo-pack' ),
|
570 |
/**
|
571 |
* Cron update.
|
572 |
*/
|
573 |
+
public function cron_update() {
|
574 |
add_filter( 'cron_schedules', array( $this, 'add_cron_schedules' ) );
|
575 |
if ( ! wp_next_scheduled( $this->prefix . 'daily_update_cron' ) ) {
|
576 |
wp_schedule_event( time(), $this->options[ $this->prefix . 'daily_cron' ], $this->prefix . 'daily_update_cron' );
|
580 |
/**
|
581 |
* Daily update.
|
582 |
*/
|
583 |
+
public function daily_update() {
|
584 |
$last_run = get_option( $this->prefix . 'cron_last_run' );
|
585 |
if ( empty( $last_run ) || ( time() - $last_run > 23.5 * 60 * 60 ) ) {
|
586 |
// Sanity check.
|
593 |
/**
|
594 |
* Initialize options, after constructor.
|
595 |
*/
|
596 |
+
public function load_sitemap_options() {
|
597 |
// Load initial options / set defaults.
|
598 |
$this->update_options();
|
599 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
617 |
if ( isset( $this->options[ $this->prefix . 'daily_cron' ] ) && $this->options[ $this->prefix . 'daily_cron' ] ) {
|
618 |
add_action( 'wp', array( $this, 'cron_update' ) );
|
619 |
} else {
|
620 |
+
$time = wp_next_scheduled( $this->prefix . 'daily_update_cron' );
|
621 |
+
if ( $time ) {
|
622 |
wp_unschedule_event( $time, $this->prefix . 'daily_update_cron' );
|
623 |
}
|
624 |
}
|
634 |
*
|
635 |
* @return string
|
636 |
*/
|
637 |
+
public function display_custom_options( $buf, $args ) {
|
638 |
if ( "{$this->prefix}addl_pages" === $args['name'] ) {
|
639 |
$buf .= "<div id='{$this->prefix}addl_pages'>";
|
640 |
if ( ! empty( $args['value'] ) ) {
|
666 |
/**
|
667 |
* Add post type details for settings once post types have been registered.
|
668 |
*/
|
669 |
+
public function add_post_types() {
|
670 |
$post_type_titles = $this->get_post_type_titles( array( 'public' => true ) );
|
671 |
$taxonomy_titles = $this->get_taxonomy_titles( array( 'public' => true ) );
|
672 |
if ( isset( $post_type_titles['attachment'] ) ) {
|
677 |
$this->default_options['posttypes']['default'] = array_keys( $this->default_options['posttypes']['initial_options'] );
|
678 |
$this->default_options['taxonomies']['default'] = array_keys( $this->default_options['taxonomies']['initial_options'] );
|
679 |
$this->default_options['excl_categories']['initial_options'] = $this->get_category_titles();
|
680 |
+
|
681 |
+
$prio_help = __( 'Manually set the priority for the ', 'all-in-one-seo-pack' );
|
682 |
+
$freq_help = __( 'Manually set the frequency for the ', 'all-in-one-seo-pack' );
|
683 |
+
$post_name = __( ' Post Type', 'all-in-one-seo-pack' );
|
684 |
+
$tax_name = __( ' Taxonomy', 'all-in-one-seo-pack' );
|
685 |
+
|
686 |
foreach ( $post_type_titles as $k => $v ) {
|
687 |
$key = 'prio_post_' . $k;
|
688 |
$this->default_options = aioseop_array_insert_after(
|
689 |
+
$this->default_options,
|
690 |
+
'prio_post',
|
691 |
+
array(
|
692 |
$key => array(
|
693 |
'name' => $v . $post_name,
|
694 |
'help_text' => $prio_help . $v . $post_name,
|
702 |
$this->layout['priorities']['options'][] = $key;
|
703 |
$key = 'freq_post_' . $k;
|
704 |
$this->default_options = aioseop_array_insert_after(
|
705 |
+
$this->default_options,
|
706 |
+
'freq_post',
|
707 |
+
array(
|
708 |
$key => array(
|
709 |
'name' => $v . $post_name,
|
710 |
'help_text' => $freq_help . $v . $post_name,
|
720 |
foreach ( $taxonomy_titles as $k => $v ) {
|
721 |
$key = 'prio_taxonomies_' . $k;
|
722 |
$this->default_options = aioseop_array_insert_after(
|
723 |
+
$this->default_options,
|
724 |
+
'prio_taxonomies',
|
725 |
+
array(
|
726 |
$key => array(
|
727 |
'name' => $v . $tax_name,
|
728 |
'help_text' => $prio_help . $v . $tax_name,
|
736 |
$this->layout['priorities']['options'][] = $key;
|
737 |
$key = 'freq_taxonomies_' . $k;
|
738 |
$this->default_options = aioseop_array_insert_after(
|
739 |
+
$this->default_options,
|
740 |
+
'freq_taxonomies',
|
741 |
+
array(
|
742 |
$key => array(
|
743 |
'name' => $v . $tax_name,
|
744 |
'help_text' => $freq_help . $v . $tax_name,
|
757 |
/**
|
758 |
* Set up settings, checking for sitemap conflicts, on settings page.
|
759 |
*/
|
760 |
+
public function add_page_hooks() {
|
761 |
$this->flush_rules_hook();
|
762 |
$this->add_post_types();
|
763 |
parent::add_page_hooks();
|
774 |
*
|
775 |
* @return mixed
|
776 |
*/
|
777 |
+
public function filter_submit( $submit ) {
|
778 |
$submit['Submit']['value'] = __( 'Update Sitemap', 'all-in-one-seo-pack' ) . ' »';
|
779 |
|
780 |
return $submit;
|
789 |
*
|
790 |
* @return mixed
|
791 |
*/
|
792 |
+
public function update_post_data( $options ) {
|
793 |
if ( is_multisite() ) {
|
794 |
$options[ $this->prefix . 'rewrite' ]['disabled'] = 'disabled';
|
795 |
}
|
802 |
*
|
803 |
* @return bool
|
804 |
*/
|
805 |
+
public function get_rewrite_url( $url ) {
|
806 |
global $wp_rewrite;
|
807 |
+
// TODO Change to wp_parse_url.
|
808 |
$url = parse_url( esc_url( $url ), PHP_URL_PATH );
|
809 |
$url = ltrim( $url, '/' );
|
810 |
if ( ! empty( $wp_rewrite ) ) {
|
828 |
*/
|
829 |
private function get_filename() {
|
830 |
$filename = 'sitemap';
|
831 |
+
if ( ! empty( $this->options[ "{$this->prefix}filename" ] ) ) {
|
832 |
+
$filename = $this->options[ "{$this->prefix}filename" ];
|
833 |
$filename = str_replace( '/', '', $filename );
|
834 |
+
} elseif ( 'aiosp_video_sitemap_' === $this->prefix ) {
|
835 |
+
$filename = 'video-sitemap';
|
836 |
}
|
837 |
/**
|
838 |
* Filters the filename: aiosp_sitemap_filename OR aiosp_video_sitemap_filename.
|
839 |
*
|
840 |
+
* @param string $filename The file name.
|
841 |
*/
|
842 |
return apply_filters( "{$this->prefix}filename", $filename );
|
843 |
}
|
854 |
*
|
855 |
* @return mixed
|
856 |
*/
|
857 |
+
public function filter_display_options( $options ) {
|
858 |
if ( is_multisite() ) {
|
859 |
$options[ $this->prefix . 'rewrite' ] = 'On';
|
860 |
}
|
862 |
$options[ $this->prefix . 'max_posts' ] = 50000;
|
863 |
}
|
864 |
$url = aioseop_home_url( '/' . $this->get_filename() . '.xml' );
|
|
|
865 |
|
866 |
+
/* translators: Link to documentation. */
|
867 |
+
$options[ $this->prefix . 'link' ] = sprintf( __( 'Click here to %s.', 'all-in-one-seo-pack' ), '<a href="' . esc_url( $url ) . '" target="_blank">' . __( 'view your XML sitemap', 'all-in-one-seo-pack' ) . '</a>' );
|
868 |
$options[ $this->prefix . 'link' ] .= __( ' Your sitemap has been created with content and images.', 'all-in-one-seo-pack' );
|
869 |
+
|
870 |
+
if ( $options[ "{$this->prefix}rss_sitemap" ] ) {
|
871 |
+
$url_rss = aioseop_home_url( '/' . $this->get_filename() . '.rss' );
|
872 |
+
/* translators: Link to sitemap within current site. */
|
873 |
+
$options[ $this->prefix . 'link' ] .= '<p>' . sprintf( __( 'Click here to %1$sview your RSS sitemap%2$s.', 'all-in-one-seo-pack' ), '<a href="' . esc_url( $url_rss ) . '" target="_blank">', '</a>' ) . '</p>';
|
874 |
+
}
|
875 |
+
|
876 |
if ( '0' !== get_option( 'blog_public' ) ) {
|
877 |
$options[ $this->prefix . 'link' ] .= ' ' . __( 'Changes are automatically submitted to search engines.', 'all-in-one-seo-pack' );
|
878 |
}
|
880 |
if ( $this->option_isset( 'rewrite' ) ) {
|
881 |
$rule = $this->get_rewrite_url( $url );
|
882 |
$rules = $this->get_rewrite_rules();
|
883 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
884 |
if ( ! in_array( $rule, $rules ) ) {
|
885 |
$options[ $this->prefix . 'link' ] .= '<p>' . __( 'Dynamic sitemap generation does not appear to be using the correct rewrite rules; please disable any other sitemap plugins or functionality on your site and reset your permalinks.', 'all-in-one-seo-pack' ) . '</p>';
|
886 |
}
|
892 |
} else {
|
893 |
$privacy_link = '<a href="options-privacy.php">' . __( 'Privacy Settings', 'all-in-one-seo-pack' ) . '</a>';
|
894 |
}
|
895 |
+
/* translators: Link to settings to disable "Discourage search engines from indexing this site". */
|
896 |
$options[ $this->prefix . 'link' ] .= '<p class="aioseop_error_notice">' . sprintf( __( 'Warning: your privacy settings are configured to ask search engines to not index your site; you can change this under %s for your blog.', 'all-in-one-seo-pack' ), $privacy_link );
|
897 |
}
|
898 |
return $options;
|
903 |
*
|
904 |
* Handle 'all' option for post types / taxonomies, further sanitization of filename, rewrites on for multisite, setting up addl pages option.
|
905 |
*
|
906 |
+
* @todo This needs nonce support.
|
907 |
+
*
|
908 |
* @param $options
|
909 |
*
|
910 |
* @return mixed
|
911 |
*/
|
912 |
+
public function filter_options( $options ) {
|
913 |
if ( ! isset( $this->default_options['posttypes']['initial_options'] ) ) {
|
914 |
$this->add_post_types();
|
915 |
}
|
916 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
917 |
if ( is_array( $options[ "{$this->prefix}posttypes" ] ) && in_array( 'all', $options[ "{$this->prefix}posttypes" ] ) && is_array( $this->default_options['posttypes']['initial_options'] ) ) {
|
918 |
$options[ "{$this->prefix}posttypes" ] = array_keys( $this->default_options['posttypes']['initial_options'] );
|
919 |
}
|
920 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
921 |
if ( is_array( $options[ "{$this->prefix}taxonomies" ] ) && in_array( 'all', $options[ "{$this->prefix}taxonomies" ] ) && is_array( $this->default_options['taxonomies']['initial_options'] ) ) {
|
922 |
$options[ "{$this->prefix}taxonomies" ] = array_keys( $this->default_options['taxonomies']['initial_options'] );
|
923 |
}
|
953 |
if ( ! empty( $_POST[ $this->prefix . 'addl_url' ] ) ) {
|
954 |
foreach ( array( 'addl_url', 'addl_prio', 'addl_freq', 'addl_mod' ) as $field ) {
|
955 |
if ( ! empty( $_POST[ $this->prefix . $field ] ) ) {
|
956 |
+
// TODO Add/Change to filter_input().
|
957 |
$_POST[ $this->prefix . $field ] = esc_attr( wp_kses_post( $_POST[ $this->prefix . $field ] ) );
|
958 |
} else {
|
959 |
+
// TODO Add/Change to filter_input().
|
960 |
$_POST[ $this->prefix . $field ] = '';
|
961 |
}
|
962 |
}
|
966 |
|
967 |
if ( aiosp_common::is_url_valid( $_POST[ $this->prefix . 'addl_url' ] ) ) {
|
968 |
$options[ $this->prefix . 'addl_pages' ][ $_POST[ $this->prefix . 'addl_url' ] ] = array(
|
969 |
+
// TODO Add/Change to filter_input().
|
970 |
'prio' => $_POST[ $this->prefix . 'addl_prio' ],
|
971 |
'freq' => $_POST[ $this->prefix . 'addl_freq' ],
|
972 |
'mod' => $_POST[ $this->prefix . 'addl_mod' ],
|
980 |
/**
|
981 |
* Get sitemap urls of child blogs, if any.
|
982 |
*
|
983 |
+
* @return array
|
984 |
*/
|
985 |
+
public function get_child_sitemap_urls() {
|
986 |
$siteurls = array();
|
987 |
$blogs = $this->get_child_blogs();
|
988 |
if ( ! empty( $blogs ) ) {
|
990 |
foreach ( $blogs as $blog_id ) {
|
991 |
if ( $this->is_aioseop_active_on_blog( $blog_id ) ) {
|
992 |
$options = get_blog_option( $blog_id, $this->parent_option );
|
993 |
+
if (
|
994 |
+
! empty( $options )
|
995 |
+
&& ! empty( $options['modules'] )
|
996 |
+
&& ! empty( $options['modules']['aiosp_feature_manager_options'] )
|
997 |
+
&& ! empty( $options['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_sitemap'] )
|
998 |
+
&& ! empty( $options['modules'][ $option_name ] )
|
999 |
) {
|
1000 |
global $wpdb;
|
1001 |
$sitemap_options = $options['modules'][ $option_name ];
|
1005 |
$domain = $wpdb->get_var( "SELECT domain FROM {$wpdb->dmtable} WHERE blog_id = '$blog_id' AND active = 1 LIMIT 1" );
|
1006 |
// @codingStandardsIgnoreEnd
|
1007 |
if ( $domain ) {
|
1008 |
+
if ( ! isset( $_SERVER['HTTPS'] ) ) {
|
1009 |
$_SERVER['HTTPS'] = 'Off';
|
1010 |
}
|
1011 |
+
$protocol = ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) ? 'https://' : 'http://';
|
1012 |
$siteurl = untrailingslashit( $protocol . $domain );
|
1013 |
}
|
1014 |
}
|
1038 |
*
|
1039 |
* @return mixed|string
|
1040 |
*/
|
1041 |
+
public function get_home_path() {
|
1042 |
|
1043 |
if ( function_exists( 'get_home_path' ) ) {
|
1044 |
return get_home_path();
|
1069 |
*
|
1070 |
* @return string
|
1071 |
*/
|
1072 |
+
public function whitelist_static_sitemaps( $file ) {
|
1073 |
|
1074 |
$whitelist = array( 'sitemap_news.xml', 'sitemap-news.xml' );
|
1075 |
|
1085 |
*
|
1086 |
* @return array
|
1087 |
*/
|
1088 |
+
public function scan_match_files() {
|
1089 |
+
$scan1 = '';
|
1090 |
+
$scan2 = '';
|
1091 |
$files = array();
|
1092 |
|
|
|
1093 |
$filename = $this->get_filename();
|
1094 |
if ( ! empty( $filename ) ) {
|
1095 |
$scan1 = get_home_path() . $filename . '*.xml';
|
1096 |
+
if ( ! empty( $this->options[ "{$this->prefix}gzipped" ] ) ) {
|
1097 |
$scan2 .= get_home_path() . $filename . '*.xml.gz';
|
1098 |
}
|
1099 |
|
1124 |
* Scan for sitemaps.
|
1125 |
*
|
1126 |
* Handle deleting / renaming of conflicting sitemap files.
|
1127 |
+
*
|
1128 |
+
* @todo Add/Fix nonce.
|
1129 |
*/
|
1130 |
+
public function do_sitemap_scan() {
|
1131 |
$msg = '';
|
1132 |
if ( ! empty( $this->options[ "{$this->prefix}rewrite" ] ) && ( get_option( 'permalink_structure' ) === '' ) ) {
|
1133 |
$msg = '<p>' . __( 'Warning: dynamic sitemap generation must have permalinks enabled.', 'all-in-one-seo-pack' ) . '</p>';
|
1134 |
}
|
1135 |
if ( ! empty( $_POST['aioseop_sitemap_rename_files'] ) || ! empty( $_POST['aioseop_sitemap_delete_files'] ) ) {
|
1136 |
+
// TODO Add/Change to filter_input().
|
1137 |
$nonce = $_POST['nonce-aioseop'];
|
1138 |
if ( ! wp_verify_nonce( $nonce, 'aioseop-nonce' ) ) {
|
1139 |
+
// TODO Change to wp_die().
|
1140 |
die( __( 'Security Check - If you receive this in error, log out and back in to WordPress', 'all-in-one-seo-pack' ) );
|
1141 |
}
|
1142 |
if ( ! empty( $_POST['aioseop_sitemap_conflict'] ) ) {
|
1146 |
}
|
1147 |
foreach ( $_POST['aioseop_sitemap_conflict'] as $ren_file ) {
|
1148 |
$ren_file = realpath( get_home_path() . $ren_file );
|
1149 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
1150 |
if ( in_array( $ren_file, $files ) ) {
|
1151 |
if ( ! empty( $_POST['aioseop_sitemap_delete_files'] ) ) {
|
1152 |
if ( $this->delete_file( $ren_file ) ) {
|
1153 |
+
/* translators: Shows which sitemap files have been deleted. */
|
1154 |
$msg .= '<p>' . sprintf( __( 'Deleted %s.', 'all-in-one-seo-pack' ), $ren_file ) . '</p>';
|
1155 |
}
|
1156 |
continue;
|
1161 |
$count ++;
|
1162 |
} while ( $this->file_exists( $ren_to ) && ( $count < 1000 ) );
|
1163 |
if ( $count >= 1000 ) {
|
1164 |
+
/* translators: Shows which sitemap files couldn't be renamed. */
|
1165 |
$msg .= '<p>' . sprintf( __( "Couldn't rename file %s!", 'all-in-one-seo-pack' ), $ren_file ) . '</p>';
|
1166 |
} else {
|
1167 |
$ren = $this->rename_file( $ren_file, $ren_to );
|
1168 |
if ( $ren ) {
|
1169 |
+
/* translators: Shows which sitemap files were renamed. */
|
1170 |
$msg .= '<p>' . sprintf( __( 'Renamed %1$s to %2$s.', 'all-in-one-seo-pack' ), $ren_file, $ren_to ) . '</p>';
|
1171 |
}
|
1172 |
}
|
1173 |
} else {
|
1174 |
+
/* translators: Shows which sitemap files couldn't be found. */
|
1175 |
$msg .= '<p>' . sprintf( __( "Couldn't find file %s!", 'all-in-one-seo-pack' ), $ren_file ) . '</p>';
|
1176 |
}
|
1177 |
}
|
1190 |
*
|
1191 |
* @return string
|
1192 |
*/
|
1193 |
+
public function scan_sitemaps() {
|
1194 |
$msg = '';
|
1195 |
$files = $this->scan_match_files();
|
1196 |
if ( ! empty( $files ) ) {
|
1212 |
*
|
1213 |
* @return array
|
1214 |
*/
|
1215 |
+
public function get_problem_files( $files, &$msg ) {
|
1216 |
$problem_files = array();
|
1217 |
$use_wpfs = true;
|
1218 |
$wpfs = $this->get_filesystem_object();
|
1243 |
} else {
|
1244 |
if ( $compressed ) {
|
1245 |
$file_resource = gzopen( $fn, 'rb' );
|
1246 |
+
$file = gzread( $file_resource, 4096 );
|
1247 |
gzclose( $file_resource );
|
1248 |
} else {
|
1249 |
+
// TODO Change to `wp_remote_get()`.
|
1250 |
$file = file_get_contents( $fn, false, null, 0, 4096 );
|
1251 |
}
|
1252 |
}
|
1254 |
$matches = array();
|
1255 |
if ( preg_match(
|
1256 |
'/<!-- ' . sprintf( $this->comment_string, '(.*)', '(.*)', '(.*)' ) . ' -->/',
|
1257 |
+
$file,
|
1258 |
+
$matches
|
1259 |
) ) {
|
1260 |
if ( ! empty( $this->options[ "{$this->prefix}rewrite" ] ) ) {
|
1261 |
$msg .= '<p>' . sprintf(
|
1262 |
__( "Warning: a static sitemap '%1\$s' generated by All in One SEO Pack %2\$s on %3\$s already exists that may conflict with dynamic sitemap generation.", 'all-in-one-seo-pack' ),
|
1263 |
+
$f,
|
1264 |
+
$matches[2],
|
1265 |
+
$matches[3]
|
1266 |
) . "</p>\n";
|
1267 |
+
|
1268 |
$problem_files[] = $f;
|
1269 |
}
|
1270 |
} else {
|
1271 |
+
/* translators: Shows which 'unknown' file is conflicting with the current sitemap settings. */
|
1272 |
$msg .= '<p>' . sprintf( __( 'Potential conflict with unknown file %s.', 'all-in-one-seo-pack' ), $f ) . "</p>\n";
|
1273 |
+
|
1274 |
$problem_files[] = $f;
|
1275 |
}
|
1276 |
} else {
|
1277 |
+
/* translators: Shows which files were removed. */
|
1278 |
$msg .= '<p>' . sprintf( __( 'Removed empty file %s.', 'all-in-one-seo-pack' ), $f ) . "</p>\n";
|
1279 |
+
|
1280 |
$problem_files[] = $f;
|
1281 |
|
1282 |
// This is causing all problem_files to be deleted automatically; which may be the intent.
|
1302 |
*
|
1303 |
* @return string
|
1304 |
*/
|
1305 |
+
public function sitemap_warning( $files ) {
|
1306 |
$msg = '';
|
1307 |
$conflict = false;
|
1308 |
$problem_files = $this->get_problem_files( $files, $msg );
|
1316 |
$msg .= "<input type='hidden' name='nonce-aioseop' value='" . wp_create_nonce( 'aioseop-nonce' ) . "'>\n";
|
1317 |
$msg .= "<input type='submit' name='aioseop_sitemap_rename_files' value='" . __( 'Rename Conflicting Files', 'all-in-one-seo-pack' ) . "'> ";
|
1318 |
$msg .= "<input type='submit' name='aioseop_sitemap_delete_files' value='" . __( 'Delete Conflicting Files', 'all-in-one-seo-pack' ) . "'>";
|
1319 |
+
|
1320 |
$msg = '<form action="" method="post">' . $msg . '</form>';
|
1321 |
}
|
1322 |
|
1330 |
*
|
1331 |
* @param $msg
|
1332 |
*/
|
1333 |
+
public function debug_message( $msg ) {
|
1334 |
aiosp_log( $msg );
|
1335 |
}
|
1336 |
|
1337 |
/**
|
1338 |
* Set up hooks for rewrite rules for dynamic sitemap generation.
|
1339 |
*/
|
1340 |
+
public function setup_rewrites() {
|
1341 |
add_filter( 'rewrite_rules_array', array( $this, 'rewrite_hook' ) );
|
1342 |
add_filter( 'query_vars', array( $this, 'query_var_hook' ) );
|
1343 |
add_action( 'parse_query', array( $this, 'sitemap_output_hook' ) );
|
1349 |
/**
|
1350 |
* Build and return our rewrite rules.
|
1351 |
*
|
1352 |
+
* @param string $prefix_removed_rules_with If rules are being removed, prefix them with this character
|
1353 |
+
* so that they are flushed properly and are not retained.
|
1354 |
* @return array
|
1355 |
*/
|
1356 |
+
public function get_rewrite_rules( $prefix_removed_rules_with = null ) {
|
1357 |
+
$sitemap_rules_gzipped = array();
|
1358 |
+
$sitemap_rules_normal = array(
|
1359 |
+
$this->get_filename() . '.xml' => 'index.php?' . $this->prefix . 'path=root',
|
|
|
1360 |
$this->get_filename() . '_(.+)_(\d+).xml' => 'index.php?' . $this->prefix . 'path=$matches[1]&' . $this->prefix . 'page=$matches[2]',
|
1361 |
$this->get_filename() . '_(.+).xml' => 'index.php?' . $this->prefix . 'path=$matches[1]',
|
|
|
|
|
1362 |
);
|
1363 |
+
|
1364 |
+
if ( isset( $this->options[ "{$this->prefix}rss_sitemap" ] ) && $this->options[ "{$this->prefix}rss_sitemap" ] ) {
|
1365 |
+
$sitemap_rules_normal += array(
|
1366 |
+
$this->get_filename() . '.rss' => 'index.php?' . $this->prefix . 'path=rss',
|
1367 |
+
$this->get_filename() . 'latest.rss' => 'index.php?' . $this->prefix . 'path=rss_latest',
|
1368 |
+
);
|
1369 |
+
} elseif ( ! empty( $prefix_removed_rules_with ) ) {
|
1370 |
+
$sitemap_rules_normal += array(
|
1371 |
+
$prefix_removed_rules_with . $this->get_filename() . '.rss' => 'index.php?' . $this->prefix . 'path=rss',
|
1372 |
+
$prefix_removed_rules_with . $this->get_filename() . 'latest.rss' => 'index.php?' . $this->prefix . 'path=rss_latest',
|
1373 |
+
);
|
1374 |
+
}
|
1375 |
+
|
1376 |
if ( $this->options[ "{$this->prefix}gzipped" ] ) {
|
1377 |
$sitemap_rules_gzipped = array(
|
1378 |
+
$this->get_filename() . '.xml.gz' => 'index.php?' . $this->prefix . 'gzipped=1&' . $this->prefix . 'path=root.gz',
|
|
|
1379 |
$this->get_filename() . '_(.+)_(\d+).xml.gz' => 'index.php?' . $this->prefix . 'path=$matches[1].gz&' . $this->prefix . 'page=$matches[2]',
|
1380 |
$this->get_filename() . '_(.+).xml.gz' => 'index.php?' . $this->prefix . 'path=$matches[1].gz',
|
1381 |
);
|
1392 |
*
|
1393 |
* @return array
|
1394 |
*/
|
1395 |
+
public function rewrite_hook( $rules ) {
|
1396 |
$sitemap_rules = $this->get_rewrite_rules();
|
1397 |
if ( ! empty( $sitemap_rules ) ) {
|
1398 |
$rules = $sitemap_rules + $rules;
|
1404 |
/**
|
1405 |
* Flush rewrite rules when necessary.
|
1406 |
*/
|
1407 |
+
public function flush_rules_hook() {
|
1408 |
global $wp_rewrite;
|
1409 |
+
$sitemap_rules = $this->get_rewrite_rules( '|' );
|
1410 |
if ( ! empty( $sitemap_rules ) ) {
|
1411 |
+
$rules = get_option( 'rewrite_rules' );
|
1412 |
$new_rules = array_keys( $sitemap_rules );
|
1413 |
foreach ( $new_rules as $rule ) {
|
1414 |
if ( ! isset( $rules[ $rule ] ) || ( $rules[ $rule ] !== $sitemap_rules[ $rule ] ) ) {
|
1426 |
*
|
1427 |
* @return array
|
1428 |
*/
|
1429 |
+
public function query_var_hook( $vars ) {
|
1430 |
$vars[] = "{$this->prefix}path";
|
1431 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
1432 |
$vars[] = "{$this->prefix}page";
|
1438 |
/**
|
1439 |
* Start timing and get initial memory usage for debug info.
|
1440 |
*/
|
1441 |
+
public function log_start() {
|
1442 |
$this->start_memory_usage = memory_get_peak_usage();
|
1443 |
timer_start();
|
1444 |
}
|
1451 |
* @param bool $compressed
|
1452 |
* @param bool $dynamic
|
1453 |
*/
|
1454 |
+
public function log_stats( $sitemap_type = 'static', $compressed = false, $dynamic = true ) {
|
1455 |
$time = timer_stop();
|
1456 |
$end_memory_usage = memory_get_peak_usage();
|
1457 |
$sitemap_memory_usage = $end_memory_usage - $this->start_memory_usage;
|
1472 |
*
|
1473 |
* @param $query
|
1474 |
*/
|
1475 |
+
public function sitemap_output_hook( $query ) {
|
1476 |
$page = 0;
|
1477 |
if ( $this->options[ "{$this->prefix}rewrite" ] && ! empty( $query->query_vars[ "{$this->prefix}path" ] ) ) {
|
1478 |
|
1505 |
}
|
1506 |
$this->do_rewrite_sitemap( $sitemap_type, $page );
|
1507 |
if ( $gzipped ) {
|
1508 |
+
// TODO Add esc_* function.
|
1509 |
echo gzencode( ob_get_clean() );
|
1510 |
}
|
1511 |
$this->log_stats( $sitemap_type, $gzipped );
|
1517 |
/**
|
1518 |
* Make dynamic xsl.
|
1519 |
*/
|
1520 |
+
public function make_dynamic_xsl() {
|
1521 |
// Make dynamic xsl file.
|
1522 |
if ( preg_match( '#(/sitemap\.xsl)$#i', $_SERVER['REQUEST_URI'] ) ) {
|
1523 |
$blog_charset = get_option( 'blog_charset' );
|
1524 |
header( "Content-Type: text/xml; charset=$blog_charset", true );
|
1525 |
+
include_once AIOSEOP_PLUGIN_DIR . '/inc/sitemap-xsl.php';
|
1526 |
exit();
|
1527 |
}
|
1528 |
}
|
1533 |
* @param $sitemap_type
|
1534 |
* @param int $page
|
1535 |
*
|
1536 |
+
* @return array
|
1537 |
*/
|
1538 |
+
public function get_sitemap_data( $sitemap_type, $page = 0 ) {
|
1539 |
$sitemap_data = array();
|
1540 |
|
1541 |
if ( 0 === strpos( $sitemap_type, 'rss' ) ) {
|
1542 |
$sitemap_data = $this->get_simple_sitemap();
|
1543 |
} elseif ( $this->options[ "{$this->prefix}indexes" ] ) {
|
1544 |
+
$posttypes = $this->options[ "{$this->prefix}posttypes" ];
|
1545 |
if ( empty( $posttypes ) ) {
|
1546 |
$posttypes = array();
|
1547 |
}
|
1558 |
} elseif ( 'author' === $sitemap_type && $this->option_isset( 'author' ) ) {
|
1559 |
$sitemap_data = $this->get_author_prio_data();
|
1560 |
} elseif ( in_array( $sitemap_type, $posttypes ) ) {
|
1561 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
1562 |
$sitemap_data = $this->get_all_post_priority_data( $sitemap_type, 'publish', $page );
|
1563 |
} elseif ( in_array( $sitemap_type, $taxonomies ) ) {
|
1564 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
1565 |
$sitemap_data = $this->get_term_priority_data( get_terms( $sitemap_type, $this->get_tax_args( $page ) ) );
|
1566 |
} else {
|
1567 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
1568 |
if ( is_array( $this->extra_sitemaps ) && in_array( $sitemap_type, $this->extra_sitemaps ) ) {
|
1569 |
$sitemap_data = apply_filters( $this->prefix . 'custom_' . $sitemap_type, $sitemap_data, $page, $this_options );
|
1570 |
}
|
1584 |
* @param $sitemap_type
|
1585 |
* @param int $page
|
1586 |
*/
|
1587 |
+
public function do_rewrite_sitemap( $sitemap_type, $page = 0 ) {
|
1588 |
$this->add_post_types();
|
1589 |
$comment = 'dynamically';
|
1590 |
+
// TODO Add esc_* or wp_kses function.
|
1591 |
echo $this->do_build_sitemap( $sitemap_type, $page, '', $comment );
|
1592 |
}
|
1593 |
|
1599 |
*
|
1600 |
* @return string
|
1601 |
*/
|
1602 |
+
public function get_sitemap_url() {
|
1603 |
|
1604 |
$gz = '';
|
1605 |
if ( $this->options[ "{$this->prefix}gzipped" ] ) {
|
1614 |
/**
|
1615 |
* Notify search engines, do logging.
|
1616 |
*/
|
1617 |
+
public function do_notify() {
|
1618 |
|
1619 |
if ( '0' === get_option( 'blog_public' ) ) {
|
1620 |
// Don't ping search engines if blog is set to not public.
|
1627 |
}
|
1628 |
|
1629 |
$notify_url = array(
|
1630 |
+
'google' => 'https://www.google.com/ping?sitemap=',
|
1631 |
+
'bing' => 'https://www.bing.com/ping?sitemap=',
|
1632 |
);
|
1633 |
|
1634 |
$notify_url = apply_filters( 'aioseo_sitemap_ping_urls', $notify_url );
|
1636 |
$url = $this->get_sitemap_url();
|
1637 |
if ( ! empty( $url ) ) {
|
1638 |
foreach ( $notify_url as $k => $v ) {
|
1639 |
+
// TODO Change urlencode() to rawurlencode().
|
1640 |
+
// @link http://php.net/manual/en/function.rawurlencode.php
|
1641 |
+
// @link http://www.faqs.org/rfcs/rfc3986.html
|
1642 |
$response = wp_remote_get( $notify_url[ $k ] . urlencode( $url ) );
|
1643 |
if ( is_array( $response ) && ! empty( $response['response'] ) && ! empty( $response['response']['code'] ) ) {
|
1644 |
+
if ( 200 !== intval( $response['response']['code'] ) ) {
|
1645 |
+
/* translators: Notifies the admin which sitemaps failed to notify with which search engine(s), and display the error code. */
|
1646 |
$this->debug_message( sprintf( __( 'Failed to notify %1$s about changes to your sitemap at %2$s, error code %3$s.', 'all-in-one-seo-pack' ), $k, $url, $response['response']['code'] ) );
|
1647 |
}
|
1648 |
} else {
|
1649 |
+
/* translators: Notifies the admin which sitemaps failed to notify with which search engine(s). */
|
1650 |
$this->debug_message( sprintf( __( 'Failed to notify %1$s about changes to your sitemap at %2$s, unable to access via wp_remote_get().', 'all-in-one-seo-pack' ), $k, $url ) );
|
1651 |
}
|
1652 |
}
|
1656 |
/**
|
1657 |
* Add Sitemap parameter to virtual robots.txt file.
|
1658 |
*/
|
1659 |
+
public function do_robots() {
|
1660 |
$url = $this->get_sitemap_url();
|
1661 |
+
// TODO Add esc_* or wp_kses function.
|
1662 |
echo "\nSitemap: $url\n";
|
1663 |
}
|
1664 |
|
1669 |
*
|
1670 |
* @param string $message
|
1671 |
*/
|
1672 |
+
public function do_sitemaps( $message = '' ) {
|
1673 |
if ( defined( 'AIOSEOP_UNIT_TESTING' ) ) {
|
1674 |
$aioseop_options = aioseop_get_options();
|
1675 |
+
$this->options = $aioseop_options['modules'][ "{$this->prefix}options" ];
|
1676 |
}
|
1677 |
|
1678 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
1692 |
|
1693 |
$comment = sprintf( "file '%s' statically", $this->get_filename() );
|
1694 |
$sitemap = $this->do_simple_sitemap( $comment );
|
|
|
1695 |
$this->write_sitemaps( $this->get_filename(), $sitemap );
|
1696 |
+
|
1697 |
+
if ( $this->options[ "{$this->prefix}rss_sitemap" ] ) {
|
1698 |
+
$rss = $this->do_simple_sitemap_rss( $comment );
|
1699 |
+
$this->write_sitemaps( $this->get_filename(), $rss, '.rss' );
|
1700 |
+
}
|
1701 |
+
|
1702 |
$this->log_stats( 'root', $this->options[ "{$this->prefix}gzipped" ], false );
|
1703 |
}
|
1704 |
} else {
|
1717 |
*
|
1718 |
* @return mixed
|
1719 |
*/
|
1720 |
+
public function add_xml_mime_type( $mime ) {
|
1721 |
if ( ! empty( $mime ) ) {
|
1722 |
$mime['xml'] = 'text/xml';
|
1723 |
}
|
1733 |
* @param $filename
|
1734 |
* @param $contents
|
1735 |
*/
|
1736 |
+
public function write_sitemaps( $filename, $contents, $extn = '.xml' ) {
|
1737 |
$this->write_sitemap( $filename . $extn, $contents );
|
1738 |
+
if ( $this->options[ "{$this->prefix}gzipped" ] ) {
|
1739 |
$this->write_sitemap( $filename . $extn . '.gz', $contents, true );
|
1740 |
}
|
1741 |
}
|
1751 |
*
|
1752 |
* @return bool
|
1753 |
*/
|
1754 |
+
public function write_sitemap( $filename, $contents, $gzip = false ) {
|
1755 |
if ( $gzip ) {
|
1756 |
$contents = gzencode( $contents );
|
1757 |
}
|
1776 |
*
|
1777 |
* @return bool
|
1778 |
*/
|
1779 |
+
public function get_default_values( $defaults, $prefix, &$cache, $item, $nodefaults = false, $type = '' ) {
|
1780 |
if ( ! empty( $cache[ $item . $type ] ) ) {
|
1781 |
return $cache[ $item . $type ];
|
1782 |
}
|
1783 |
if ( ! empty( $defaults[ $item ] ) ) {
|
1784 |
$field = $this->prefix . $prefix . $item;
|
1785 |
+
if ( $this->option_isset( $prefix . $item ) && 'no' !== $this->options[ $field ] ) {
|
1786 |
if ( ( 'sel' === $this->options[ $field ] ) && ! empty( $type ) && isset( $this->options[ $this->prefix . $prefix . $item . '_' . $type ] ) ) {
|
1787 |
+
if ( 'no' === $this->options[ $this->prefix . $prefix . $item . '_' . $type ] ) {
|
1788 |
return false;
|
1789 |
}
|
1790 |
if ( 'sel' === $this->options[ $this->prefix . $prefix . $item . '_' . $type ] ) {
|
1792 |
}
|
1793 |
$cache[ $item . $type ] = $this->options[ $this->prefix . $prefix . $item . '_' . $type ];
|
1794 |
} else {
|
1795 |
+
if ( 'no' === $this->options[ $field ] ) {
|
1796 |
return false;
|
1797 |
}
|
1798 |
if ( 'sel' === $this->options[ $field ] ) {
|
1822 |
*
|
1823 |
* @return bool
|
1824 |
*/
|
1825 |
+
public function get_default_priority( $item, $nodefaults = false, $type = '' ) {
|
1826 |
$defaults = array(
|
1827 |
'homepage' => '1.0',
|
1828 |
'blog' => '0.9',
|
1832 |
'author' => '0.3',
|
1833 |
'taxonomies' => '0.3',
|
1834 |
);
|
1835 |
+
|
1836 |
static $cache = array();
|
1837 |
|
1838 |
return $this->get_default_values( $defaults, 'prio_', $cache, $item, $nodefaults, $type );
|
1847 |
*
|
1848 |
* @return bool
|
1849 |
*/
|
1850 |
+
public function get_default_frequency( $item, $nodefaults = false, $type = '' ) {
|
1851 |
$defaults = array(
|
1852 |
'homepage' => 'always',
|
1853 |
'blog' => 'daily',
|
1857 |
'author' => 'weekly',
|
1858 |
'taxonomies' => 'monthly',
|
1859 |
);
|
1860 |
+
|
1861 |
static $cache = array();
|
1862 |
|
1863 |
return $this->get_default_values( $defaults, 'freq_', $cache, $item, $nodefaults, $type );
|
1871 |
*
|
1872 |
* @return array
|
1873 |
*/
|
1874 |
+
public function get_sitemap_index_filenames() {
|
1875 |
$files = array();
|
1876 |
$options = $this->options;
|
|
|
1877 |
$prefix = $this->get_filename();
|
1878 |
$suffix = '.xml';
|
1879 |
+
|
1880 |
if ( $options[ "{$this->prefix}gzipped" ] ) {
|
1881 |
$suffix .= '.gz';
|
1882 |
}
|
1902 |
);
|
1903 |
|
1904 |
foreach ( $options[ "{$this->prefix}posttypes" ] as $sm ) {
|
1905 |
+
if ( 0 === intval( $post_counts[ $sm ] ) ) {
|
1906 |
continue;
|
1907 |
}
|
1908 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
1910 |
$count = 1;
|
1911 |
for ( $post_count = 0; $post_count < $post_counts[ $sm ]; $post_count += $this->max_posts ) {
|
1912 |
$files[] = array(
|
1913 |
+
'loc' => aioseop_home_url( '/' . $prefix . '_' . $sm . '_' . ( $count ++ ) . $suffix ),
|
1914 |
'changefreq' => $freq,
|
1915 |
'priority' => $prio,
|
1916 |
);
|
1917 |
}
|
1918 |
} else {
|
1919 |
$files[] = array(
|
1920 |
+
'loc' => aioseop_home_url( '/' . $prefix . '_' . $sm . $suffix ),
|
1921 |
'changefreq' => $freq,
|
1922 |
'priority' => $prio,
|
1923 |
);
|
1924 |
}
|
1925 |
} else {
|
1926 |
$files[] = array(
|
1927 |
+
'loc' => aioseop_home_url( '/' . $prefix . '_' . $sm . $suffix ),
|
1928 |
'changefreq' => $freq,
|
1929 |
'priority' => $prio,
|
1930 |
);
|
1933 |
}
|
1934 |
if ( $this->option_isset( 'archive' ) ) {
|
1935 |
$files[] = array(
|
1936 |
+
'loc' => aioseop_home_url( '/' . $prefix . '_archive' . $suffix ),
|
1937 |
'changefreq' => $this->get_default_frequency( 'archive' ),
|
1938 |
'priority' => $this->get_default_priority( 'archive' ),
|
1939 |
);
|
1940 |
}
|
1941 |
if ( $this->option_isset( 'author' ) ) {
|
1942 |
$files[] = array(
|
1943 |
+
'loc' => aioseop_home_url( '/' . $prefix . '_author' . $suffix ),
|
1944 |
'changefreq' => $this->get_default_frequency( 'author' ),
|
1945 |
'priority' => $this->get_default_priority( 'author' ),
|
1946 |
);
|
1955 |
$count = 1;
|
1956 |
for ( $tc = 0; $tc < $term_count; $tc += $this->max_posts ) {
|
1957 |
$files[] = array(
|
1958 |
+
'loc' => aioseop_home_url( '/' . $prefix . '_' . $sm . '_' . ( $count ++ ) . $suffix ),
|
1959 |
'changefreq' => $this->get_default_frequency( 'taxonomies' ),
|
1960 |
'priority' => $this->get_default_priority( 'taxonomies' ),
|
1961 |
);
|
1962 |
}
|
1963 |
} else {
|
1964 |
$files[] = array(
|
1965 |
+
'loc' => aioseop_home_url( '/' . $prefix . '_' . $sm . $suffix ),
|
1966 |
'changefreq' => $this->get_default_frequency( 'taxonomies' ),
|
1967 |
'priority' => $this->get_default_priority( 'taxonomies' ),
|
1968 |
);
|
1969 |
}
|
1970 |
} else {
|
1971 |
$files[] = array(
|
1972 |
+
'loc' => aioseop_home_url( '/' . $prefix . '_' . $sm . $suffix ),
|
1973 |
'changefreq' => $this->get_default_frequency( 'taxonomies' ),
|
1974 |
'priority' => $this->get_default_priority( 'taxonomies' ),
|
1975 |
);
|
1985 |
);
|
1986 |
}
|
1987 |
|
1988 |
+
$files = apply_filters( 'aioseop_sitemap_index_filenames', $files, $prefix, $suffix );
|
1989 |
|
1990 |
return $files;
|
1991 |
}
|
2000 |
*
|
2001 |
* @return string
|
2002 |
*/
|
2003 |
+
public function do_build_sitemap( $sitemap_type, $page = 0, $filename = '', $comment = '' ) {
|
2004 |
if ( empty( $filename ) ) {
|
2005 |
switch ( $sitemap_type ) {
|
2006 |
case 'root':
|
2034 |
* @param string $filename
|
2035 |
* @param string $comment
|
2036 |
*/
|
2037 |
+
public function do_write_sitemap( $sitemap_type, $page = 0, $filename = '', $comment = '' ) {
|
2038 |
if ( empty( $filename ) ) {
|
2039 |
if ( 'root' === $sitemap_type ) {
|
2040 |
$filename = $this->get_filename();
|
2051 |
/**
|
2052 |
* Build all the indexes.
|
2053 |
*/
|
2054 |
+
public function do_indexed_sitemaps() {
|
2055 |
$this->start_memory_usage = memory_get_peak_usage();
|
2056 |
$options = $this->options;
|
2057 |
|
2120 |
$this->log_stats( 'indexed', $options[ "{$this->prefix}gzipped" ], false );
|
2121 |
}
|
2122 |
|
2123 |
+
public function remove_posts_page( $postspageid ) {
|
2124 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
2125 |
if ( in_array( $postspageid, $this->excludes ) ) {
|
2126 |
return true;
|
2127 |
}
|
2128 |
|
2129 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
2130 |
if ( in_array( get_post_field( 'post_name', $postspageid ), $this->excludes ) ) {
|
2131 |
return true;
|
2132 |
}
|
2134 |
return false;
|
2135 |
}
|
2136 |
|
2137 |
+
public function remove_homepage( $homepage_id ) {
|
2138 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
2139 |
if ( in_array( $homepage_id, $this->excludes ) ) {
|
|
|
2140 |
return true;
|
2141 |
}
|
2142 |
+
|
2143 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
2144 |
if ( in_array( get_post_field( 'post_name', $homepage_id ), $this->excludes ) ) {
|
2145 |
return true;
|
2146 |
}
|
2156 |
*
|
2157 |
* @return array
|
2158 |
*/
|
2159 |
+
public function get_simple_sitemap() {
|
2160 |
$child = $this->get_child_sitemap_urls();
|
2161 |
$options = $this->options;
|
2162 |
if ( is_array( $options[ "{$this->prefix}posttypes" ] ) ) {
|
2167 |
}
|
2168 |
$prio = $this->get_all_post_priority_data( $options[ "{$this->prefix}posttypes" ] );
|
2169 |
|
2170 |
+
// It's 0 if posts are on homepage, otherwise it's the id of the posts page.
|
2171 |
+
$posts = (int) get_option( 'page_for_posts' );
|
2172 |
+
$postspageid = (int) get_option( 'page_for_posts' );
|
2173 |
|
2174 |
$home = array(
|
2175 |
'loc' => aioseop_home_url(),
|
2180 |
|
2181 |
if ( $posts ) {
|
2182 |
$posts = $this->get_permalink( $posts );
|
2183 |
+
if ( $posts === $home['loc'] ) {
|
2184 |
$posts = null;
|
2185 |
} else {
|
2186 |
$posts = array(
|
2204 |
break;
|
2205 |
}
|
2206 |
}
|
2207 |
+
if ( ( null !== $posts ) && isset( $posts['loc'] ) ) {
|
2208 |
foreach ( $prio as $k => $p ) {
|
2209 |
if ( $p['loc'] === $posts['loc'] ) {
|
2210 |
$prio[ $k ]['changefreq'] = $this->get_default_frequency( 'blog' );
|
2243 |
*
|
2244 |
* @return string
|
2245 |
*/
|
2246 |
+
public function do_simple_sitemap( $comment = '' ) {
|
2247 |
$sitemap_data = $this->get_simple_sitemap();
|
2248 |
$sitemap_data = apply_filters( $this->prefix . 'data', $sitemap_data, 'root', 0, $this->options );
|
2249 |
|
2257 |
*
|
2258 |
* @return string
|
2259 |
*/
|
2260 |
+
public function do_simple_sitemap_rss( $comment = '' ) {
|
2261 |
$sitemap_data = $this->get_simple_sitemap();
|
2262 |
$sitemap_data = apply_filters( $this->prefix . 'data', $sitemap_data, 'rss', 0, $this->options );
|
2263 |
|
2275 |
* @since 2.3.6
|
2276 |
* @since 2.3.12.3 Refactored to use aioseop_home_url() for compatibility purposes.
|
2277 |
*/
|
2278 |
+
public function get_sitemap_xsl() {
|
2279 |
|
2280 |
return esc_url( apply_filters( 'aioseop_sitemap_xsl_url', aioseop_home_url( '/sitemap.xsl' ) ) );
|
2281 |
}
|
2289 |
*/
|
2290 |
private function output_rss( $urls, $sitemap_type, $comment ) {
|
2291 |
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n\r\n";
|
2292 |
+
// TODO Add esc_* function.
|
2293 |
echo '<!-- ' . sprintf( $this->comment_string, $comment, AIOSEOP_VERSION, date( 'D, d M Y H:i:s e' ) ) . " -->\r\n";
|
2294 |
|
2295 |
echo '<rss version="2.0"><channel>';
|
2296 |
if ( is_multisite() ) {
|
2297 |
+
// TODO Add esc_* function.
|
2298 |
+
echo
|
2299 |
+
'<title>' . aiosp_common::make_xml_safe( 'title', get_blog_option( get_current_blog_id(), 'blogname' ) ) . '</title>' .
|
2300 |
+
'<link>' . aiosp_common::make_xml_safe( 'link', get_blog_option( get_current_blog_id(), 'siteurl' ) ) . '</link>' .
|
2301 |
+
'<description>' . aiosp_common::make_xml_safe( 'description', get_blog_option( get_current_blog_id(), 'blogdescription' ) ) . '</description>';
|
2302 |
} else {
|
2303 |
+
// TODO Add esc_* function.
|
2304 |
+
echo
|
2305 |
+
'<title>' . aiosp_common::make_xml_safe( 'title', get_option( 'blogname' ) ) . '</title>' .
|
2306 |
+
'<link>' . aiosp_common::make_xml_safe( 'link', get_option( 'siteurl' ) ) . '</link>' .
|
2307 |
+
'<description>' . aiosp_common::make_xml_safe( 'description', get_option( 'blogdescription' ) ) . '</description>';
|
2308 |
}
|
2309 |
|
2310 |
// remove urls that do not have the rss element.
|
2317 |
}
|
2318 |
|
2319 |
foreach ( $urls as $url ) {
|
2320 |
+
// TODO Add esc_* function.
|
2321 |
echo
|
2322 |
+
'<item>' .
|
2323 |
+
'<guid>' . aiosp_common::make_xml_safe( 'guid', $url['loc'] ) . '</guid>' .
|
2324 |
+
'<title>' . aiosp_common::make_xml_safe( 'title', $url['rss']['title'] ) . '</title>' .
|
2325 |
+
'<link>' . aiosp_common::make_xml_safe( 'link', $url['loc'] ) . '</link>' .
|
2326 |
+
// TODO Add esc_* or wp_kses function.
|
2327 |
+
'<description><![CDATA[' . $url['rss']['description'] . ']]></description>' .
|
2328 |
+
'<pubDate>' . aiosp_common::make_xml_safe( 'pubDate', $url['rss']['pubDate'] ) . '</pubDate>' .
|
2329 |
+
'</item>';
|
2330 |
}
|
2331 |
echo '</channel></rss>';
|
2332 |
}
|
2333 |
|
2334 |
/**
|
2335 |
* Remove elements not containing the rss element.
|
2336 |
+
*
|
2337 |
+
* @since 2.9
|
2338 |
+
*
|
2339 |
+
* @param $array
|
2340 |
+
* @return bool
|
2341 |
*/
|
2342 |
public function include_in_rss( $array ) {
|
2343 |
return isset( $array['rss'] );
|
2374 |
return null;
|
2375 |
}
|
2376 |
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n\r\n";
|
2377 |
+
// TODO Add esc_* function.
|
2378 |
echo '<!-- ' . sprintf( $this->comment_string, $comment, AIOSEOP_VERSION, date( 'D, d M Y H:i:s e' ) ) . " -->\r\n";
|
2379 |
$plugin_path = $this->plugin_path['url'];
|
2380 |
+
// TODO Change to wp_parse_url().
|
2381 |
$plugin_url = parse_url( $plugin_path );
|
2382 |
$current_host = $_SERVER['HTTP_HOST'];
|
2383 |
if ( empty( $current_host ) ) {
|
2388 |
$plugin_url['host'] = $current_host;
|
2389 |
}
|
2390 |
|
2391 |
+
// Code `unset( $plugin_url['scheme'] )`.
|
2392 |
$plugin_path = $this->unparse_url( $plugin_url );
|
2393 |
|
2394 |
// Using the filter you need the full path to the custom xsl file.
|
2395 |
$xsl_url = $this->get_sitemap_xsl();
|
2396 |
|
2397 |
+
$xml_header = '<?xml-stylesheet type="text/xsl" href="' . $xsl_url . '"?>' . "\r\n" . '<urlset ';
|
|
|
2398 |
$namespaces = apply_filters(
|
2399 |
+
$this->prefix . 'xml_namespace',
|
2400 |
+
array(
|
2401 |
'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
|
2402 |
'xmlns:image' => 'http://www.google.com/schemas/sitemap-image/1.1',
|
2403 |
)
|
2405 |
if ( ! empty( $namespaces ) ) {
|
2406 |
$ns = array();
|
2407 |
foreach ( $namespaces as $k => $v ) {
|
2408 |
+
$ns[] = esc_attr( $k ) . '="' . esc_url( $v, array( 'http', 'https' ) ) . '"';
|
2409 |
}
|
2410 |
$xml_header .= join( "\r\n\t", $ns );
|
2411 |
}
|
2412 |
$xml_header .= '>' . "\r\n";
|
2413 |
+
// TODO Add esc_* function.
|
2414 |
echo $xml_header;
|
2415 |
$count = 0;
|
2416 |
foreach ( $urls as $url ) {
|
2421 |
}
|
2422 |
foreach ( $url as $k => $v ) {
|
2423 |
if ( ! empty( $v ) ) {
|
2424 |
+
$v = aiosp_common::make_xml_safe( $k, $v );
|
|
|
|
|
2425 |
if ( is_array( $v ) ) {
|
2426 |
$buf = "\t\t\t<$k>\r\n";
|
2427 |
foreach ( $v as $ext => $attr ) {
|
2428 |
if ( is_array( $attr ) ) {
|
2429 |
$buf = '';
|
2430 |
+
// TODO Add esc_* function.
|
2431 |
echo "\t\t<$k>\r\n";
|
2432 |
foreach ( $attr as $a => $nested ) {
|
2433 |
if ( is_array( $nested ) ) {
|
2434 |
+
// TODO Add esc_* function.
|
2435 |
echo "\t\t\t<$a>\r\n";
|
2436 |
foreach ( $nested as $next => $nattr ) {
|
2437 |
+
$value = aiosp_common::make_xml_safe( $next, $nattr );
|
2438 |
+
// TODO Add esc_* function.
|
2439 |
+
echo "\t\t\t\t<$next>$value</$next>\r\n";
|
2440 |
}
|
2441 |
+
// TODO Add esc_* function.
|
2442 |
echo "\t\t\t</$a>\r\n";
|
2443 |
} else {
|
2444 |
+
$value = aiosp_common::make_xml_safe( $a, $nested );
|
2445 |
+
// TODO Add esc_* function.
|
2446 |
+
echo "\t\t\t<$a>$value</$a>\r\n";
|
2447 |
}
|
2448 |
}
|
2449 |
+
// TODO Add esc_* function.
|
2450 |
echo "\t\t</$k>\r\n";
|
2451 |
} else {
|
2452 |
+
$value = aiosp_common::make_xml_safe( $ext, $attr );
|
2453 |
+
$buf .= "\t\t\t<$ext>$value</$ext>\r\n";
|
2454 |
}
|
2455 |
}
|
2456 |
if ( ! empty( $buf ) ) {
|
2457 |
+
// TODO Add esc_* function.
|
2458 |
echo $buf . "\t\t</$k>\r\n";
|
2459 |
}
|
2460 |
} else {
|
2461 |
+
$value = aiosp_common::make_xml_safe( $k, $v );
|
2462 |
+
// TODO Add esc_* function.
|
2463 |
+
echo "\t\t<$k>$value</$k>\r\n";
|
2464 |
}
|
2465 |
}
|
2466 |
}
|
2467 |
} else {
|
2468 |
+
$value = aiosp_common::make_xml_safe( 'loc', $url );
|
2469 |
+
// TODO Add esc_* function.
|
2470 |
+
echo "\t\t<loc>$value</loc>\r\n";
|
2471 |
}
|
2472 |
echo "\t</url>\r\n";
|
2473 |
if ( $count >= $max_items ) {
|
2485 |
*
|
2486 |
* @return null
|
2487 |
*/
|
2488 |
+
public function output_sitemap_index( $urls, $comment = '' ) {
|
2489 |
$max_items = 50000;
|
2490 |
if ( ! is_array( $urls ) ) {
|
2491 |
return null;
|
2492 |
}
|
2493 |
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n\r\n";
|
2494 |
+
// TODO Add esc_* function.
|
2495 |
echo '<!-- ' . sprintf( $this->comment_string, $comment, AIOSEOP_VERSION, date( 'D, d M Y H:i:s e' ) ) . " -->\r\n";
|
2496 |
$xsl_url = $this->get_sitemap_xsl();
|
2497 |
+
// TODO Add esc_* function.
|
2498 |
echo '<?xml-stylesheet type="text/xsl" href="' . $xsl_url . '"?>' . "\r\n";
|
2499 |
echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\r\n";
|
2500 |
$count = 0;
|
2502 |
echo "\t<sitemap>\r\n";
|
2503 |
if ( is_array( $url ) ) {
|
2504 |
foreach ( $url as $k => $v ) {
|
2505 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
2506 |
+
if ( ! in_array( $k, array( 'loc', 'lastmod' ) ) ) {
|
2507 |
+
continue;
|
|
|
2508 |
}
|
2509 |
+
$v = aiosp_common::make_xml_safe( $k, $v );
|
2510 |
+
// TODO Add esc_* function.
|
2511 |
+
echo "\t\t<$k>$v</$k>\r\n";
|
2512 |
}
|
2513 |
} else {
|
2514 |
+
$value = aiosp_common::make_xml_safe( 'loc', $url );
|
2515 |
+
// TODO Add esc_* function.
|
2516 |
+
echo "\t\t<loc>$value</loc>\r\n";
|
2517 |
}
|
2518 |
echo "\t</sitemap>\r\n";
|
2519 |
$count ++;
|
2532 |
*
|
2533 |
* @return string
|
2534 |
*/
|
2535 |
+
public function build_sitemap_index( $urls, $comment = '' ) {
|
2536 |
ob_start();
|
2537 |
$this->output_sitemap_index( $urls, $comment );
|
2538 |
|
2548 |
*
|
2549 |
* @return string
|
2550 |
*/
|
2551 |
+
public function build_sitemap( $urls, $sitemap_type, $comment = '' ) {
|
2552 |
ob_start();
|
2553 |
$this->output_sitemap( $urls, $sitemap_type, $comment );
|
2554 |
|
2562 |
*
|
2563 |
* @return array
|
2564 |
*/
|
2565 |
+
public function get_term_priority_data( $terms ) {
|
2566 |
$prio = array();
|
2567 |
if ( is_array( $terms ) ) {
|
2568 |
$def_prio = $this->get_default_priority( 'taxonomies' );
|
2570 |
foreach ( $terms as $term ) {
|
2571 |
$pr_info = array();
|
2572 |
$pr_info['loc'] = $this->get_term_link( $term, $term->taxonomy );
|
2573 |
+
if (
|
2574 |
+
( 'sel' === $this->options[ $this->prefix . 'freq_taxonomies' ] )
|
2575 |
+
&& isset( $this->options[ $this->prefix . 'freq_taxonomies_' . $term->taxonomy ] )
|
2576 |
+
&& ( 'no' !== $this->options[ $this->prefix . 'freq_taxonomies_' . $term->taxonomy ] )
|
2577 |
+
) {
|
2578 |
$pr_info['changefreq'] = $this->options[ $this->prefix . 'freq_taxonomies_' . $term->taxonomy ];
|
2579 |
} else {
|
2580 |
$pr_info['changefreq'] = $def_freq;
|
2581 |
}
|
2582 |
+
if (
|
2583 |
+
( 'sel' === $this->options[ $this->prefix . 'prio_taxonomies' ] )
|
2584 |
+
&& isset( $this->options[ $this->prefix . 'prio_taxonomies_' . $term->taxonomy ] )
|
2585 |
+
&& ( 'no' !== $this->options[ $this->prefix . 'prio_taxonomies_' . $term->taxonomy ] )
|
2586 |
+
) {
|
2587 |
$pr_info['priority'] = $this->options[ $this->prefix . 'prio_taxonomies_' . $term->taxonomy ];
|
2588 |
} else {
|
2589 |
$pr_info['priority'] = $def_prio;
|
2590 |
}
|
2591 |
|
2592 |
$pr_info['image:image'] = $this->get_images_from_term( $term );
|
2593 |
+
|
2594 |
$pr_info['rss'] = array(
|
2595 |
+
'title' => $term->name,
|
2596 |
'description' => $term->description,
|
2597 |
+
'pubDate' => $this->get_date_for_term( $term ),
|
2598 |
);
|
2599 |
+
|
2600 |
+
$prio[] = $pr_info;
|
2601 |
}
|
2602 |
}
|
2603 |
|
2612 |
* @return string
|
2613 |
*/
|
2614 |
private function get_date_for_term( $term ) {
|
2615 |
+
$date = '';
|
2616 |
+
$query = new WP_Query(
|
2617 |
+
array(
|
2618 |
+
'orderby' => 'post_date',
|
2619 |
+
'order' => 'DESC',
|
2620 |
+
'numberposts' => 1,
|
2621 |
+
'post_type' => 'any',
|
2622 |
+
'post_status' => 'publish',
|
2623 |
+
'tax_query' => array(
|
2624 |
+
array(
|
2625 |
+
'taxonomy' => $term->taxonomy,
|
2626 |
+
'terms' => $term->term_id,
|
2627 |
+
),
|
2628 |
),
|
2629 |
+
)
|
2630 |
+
);
|
2631 |
|
2632 |
if ( $query->have_posts() ) {
|
2633 |
$timestamp = mysql2date( 'U', $query->post->post_modified_gmt );
|
2634 |
+
$date = date( 'r', $timestamp );
|
2635 |
}
|
2636 |
|
2637 |
return $date;
|
2644 |
*
|
2645 |
* @return array
|
2646 |
*/
|
2647 |
+
public function get_term_permalinks( $terms ) {
|
2648 |
$links = array();
|
2649 |
if ( is_array( $terms ) ) {
|
2650 |
foreach ( $terms as $term ) {
|
2663 |
*
|
2664 |
* @return array
|
2665 |
*/
|
2666 |
+
public function get_archive_permalinks( $posts ) {
|
2667 |
$links = array();
|
2668 |
$archives = array();
|
2669 |
if ( is_array( $posts ) ) {
|
2689 |
*
|
2690 |
* @return array
|
2691 |
*/
|
2692 |
+
public function get_author_permalinks( $posts ) {
|
2693 |
$links = array();
|
2694 |
$authors = array();
|
2695 |
if ( is_array( $posts ) ) {
|
2712 |
*
|
2713 |
* @return array
|
2714 |
*/
|
2715 |
+
public function get_post_permalinks( $posts ) {
|
2716 |
$links = array();
|
2717 |
if ( is_array( $posts ) ) {
|
2718 |
foreach ( $posts as $post ) {
|
2736 |
*
|
2737 |
* @return string
|
2738 |
*/
|
2739 |
+
public function unparse_url( $parsed_url ) {
|
2740 |
$scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
|
2741 |
$host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
|
2742 |
if ( ! empty( $host ) && empty( $scheme ) ) {
|
2760 |
* @since 2.3.6
|
2761 |
* @since 2.3.12.3 Refactored to use aioseop_home_url() for compatibility purposes.
|
2762 |
*
|
2763 |
+
* @return array
|
2764 |
*/
|
2765 |
+
public function get_addl_pages_only() {
|
2766 |
$pages = array();
|
2767 |
if ( ! empty( $this->options[ $this->prefix . 'addl_pages' ] ) ) {
|
2768 |
+
// TODO Change to wp_parse_url().
|
2769 |
$siteurl = parse_url( aioseop_home_url() );
|
2770 |
foreach ( $this->options[ $this->prefix . 'addl_pages' ] as $k => $v ) {
|
2771 |
+
$k = aiosp_common::make_url_valid_smartly( $k );
|
2772 |
+
// TODO Change to wp_parse_url().
|
2773 |
$url = parse_url( $k );
|
2774 |
if ( empty( $url['host'] ) ) {
|
2775 |
$url['host'] = $siteurl['host'];
|
2777 |
if ( ! empty( $url['path'] ) && substr( $url['path'], 0, 1 ) !== '/' ) {
|
2778 |
$url['path'] = '/' . $url['path'];
|
2779 |
}
|
2780 |
+
$freq = '';
|
2781 |
+
$prio = '';
|
2782 |
+
$mod = '';
|
2783 |
if ( ! empty( $v['mod'] ) ) {
|
2784 |
$mod = $v['mod'];
|
2785 |
}
|
2789 |
if ( ! empty( $v['prio'] ) ) {
|
2790 |
$prio = $v['prio'];
|
2791 |
}
|
2792 |
+
if ( 'no' === $freq ) {
|
2793 |
$freq = '';
|
2794 |
}
|
2795 |
+
if ( 'no' === $prio ) {
|
2796 |
$prio = '';
|
2797 |
}
|
2798 |
$mod = date( 'Y-m-d\TH:i:s\Z', mysql2date( 'U', $mod ) );
|
2815 |
* @since 2.3.6
|
2816 |
* @since 2.3.12.3 Refactored to use aioseop_home_url() for compatibility purposes.
|
2817 |
*
|
2818 |
+
* @return array
|
2819 |
*/
|
2820 |
+
public function get_addl_pages() {
|
2821 |
+
$home = array();
|
2822 |
+
$home = array(
|
2823 |
'loc' => aioseop_home_url(),
|
2824 |
'changefreq' => $this->get_default_frequency( 'homepage' ),
|
2825 |
'priority' => $this->get_default_priority( 'homepage' ),
|
2829 |
$posts = (int) get_option( 'page_for_posts' );
|
2830 |
if ( $posts ) {
|
2831 |
$posts = $this->get_permalink( $posts );
|
2832 |
+
if ( $posts === $home['loc'] ) {
|
2833 |
$posts = array();
|
2834 |
} else {
|
2835 |
$posts = array(
|
2858 |
*
|
2859 |
* @return array
|
2860 |
*/
|
2861 |
+
public function get_addl_page_links() {
|
2862 |
if ( ! empty( $this->options[ $this->prefix . 'addl_pages' ] ) ) {
|
2863 |
return array_keys( $this->options[ $this->prefix . 'addl_pages' ] );
|
2864 |
}
|
2874 |
*
|
2875 |
* @return array
|
2876 |
*/
|
2877 |
+
public function get_prio_calc( $date, $stats ) {
|
2878 |
static $cur_time = null;
|
2879 |
if ( null === $cur_time ) {
|
2880 |
$cur_time = time();
|
2925 |
$prev_days = $max_days;
|
2926 |
}
|
2927 |
|
2928 |
+
return array(
|
2929 |
+
'lastmod' => $date,
|
2930 |
+
'changefreq' => $changefreq,
|
2931 |
+
'priority' => $prio,
|
2932 |
+
);
|
2933 |
}
|
2934 |
|
2935 |
/**
|
2939 |
*
|
2940 |
* @return array
|
2941 |
*/
|
2942 |
+
public function get_date_archive_prio_from_posts( $posts ) {
|
2943 |
$archives = array();
|
2944 |
if ( is_array( $posts ) ) {
|
2945 |
foreach ( $posts as $p ) {
|
2959 |
}
|
2960 |
|
2961 |
if ( ! empty( $archives ) ) {
|
2962 |
+
return $this->get_prio_from_posts(
|
2963 |
+
$archives,
|
2964 |
+
$this->get_default_priority( 'archive', true ),
|
2965 |
+
$this->get_default_frequency( 'archive', true ),
|
2966 |
array(
|
2967 |
$this,
|
2968 |
'get_date_archive_link_from_post',
|
2983 |
*/
|
2984 |
private function get_archive_prio_from_posts( $posts ) {
|
2985 |
$posttypes = array();
|
2986 |
+
if ( ! empty( $this->options[ "{$this->prefix}posttypes" ] ) ) {
|
2987 |
+
$posttypes = $this->options[ "{$this->prefix}posttypes" ];
|
2988 |
}
|
2989 |
|
2990 |
+
$types_supporting_archives = get_post_types(
|
2991 |
+
array(
|
2992 |
+
'has_archive' => true,
|
2993 |
+
'_builtin' => false,
|
2994 |
+
),
|
2995 |
+
'names'
|
2996 |
+
);
|
2997 |
+
$types = array();
|
2998 |
foreach ( $posts as $p ) {
|
2999 |
if ( array_key_exists( $p->post_type, $types ) ) {
|
3000 |
continue;
|
3002 |
$types[ $p->post_type ] = $p;
|
3003 |
}
|
3004 |
|
3005 |
+
$archives = array();
|
3006 |
+
$types = apply_filters( "{$this->prefix}include_post_types_archives", $types );
|
3007 |
if ( $types ) {
|
3008 |
foreach ( $types as $post_type => $p ) {
|
3009 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
3010 |
if ( ! ( in_array( $post_type, $posttypes ) && in_array( $post_type, $types_supporting_archives ) ) ) {
|
3011 |
continue;
|
3012 |
}
|
3013 |
+
$archives = array_merge(
|
3014 |
$archives,
|
3015 |
$this->get_prio_from_posts(
|
3016 |
+
array( $p ),
|
3017 |
+
$this->get_default_priority( 'archive', true ),
|
3018 |
+
$this->get_default_frequency( 'archive', true ),
|
3019 |
+
array(
|
3020 |
$this,
|
3021 |
'get_archive_link_from_post',
|
3022 |
)
|
3034 |
*
|
3035 |
* @return bool|string
|
3036 |
*/
|
3037 |
+
public function get_archive_link_from_post( $post ) {
|
3038 |
return get_post_type_archive_link( $post->post_type );
|
3039 |
}
|
3040 |
|
3045 |
*
|
3046 |
* @return bool|string
|
3047 |
*/
|
3048 |
+
public function get_date_archive_link_from_post( $post ) {
|
3049 |
$extra = array();
|
3050 |
if ( 'post' !== $post->post_type ) {
|
3051 |
return false;
|
3062 |
*
|
3063 |
* @return array
|
3064 |
*/
|
3065 |
+
public function get_author_prio_from_posts( $posts ) {
|
3066 |
$authors = array();
|
3067 |
if ( is_array( $posts ) ) {
|
3068 |
foreach ( $posts as $p ) {
|
3079 |
}
|
3080 |
}
|
3081 |
|
3082 |
+
return $this->get_prio_from_posts(
|
3083 |
+
$authors,
|
3084 |
+
$this->get_default_priority( 'author', true ),
|
3085 |
+
$this->get_default_frequency( 'author', true ),
|
3086 |
array(
|
3087 |
$this,
|
3088 |
'get_author_link_from_post',
|
3098 |
*
|
3099 |
* @return string
|
3100 |
*/
|
3101 |
+
public function get_author_link_from_post( $post ) {
|
3102 |
return get_author_posts_url( $post->post_author );
|
3103 |
}
|
3104 |
|
3109 |
*
|
3110 |
* @return array|int
|
3111 |
*/
|
3112 |
+
public function get_comment_count_stats( $posts ) {
|
3113 |
$count = 0;
|
3114 |
$total = 0.0;
|
3115 |
$min = null;
|
3133 |
}
|
3134 |
}
|
3135 |
if ( $count ) {
|
3136 |
+
return array(
|
3137 |
+
'max' => $max,
|
3138 |
+
'min' => $min,
|
3139 |
+
'total' => $total,
|
3140 |
+
'count' => $cnt,
|
3141 |
+
);
|
3142 |
} else {
|
3143 |
return 0;
|
3144 |
}
|
3155 |
*
|
3156 |
* @return array
|
3157 |
*/
|
3158 |
+
public function get_prio_from_posts( $posts, $prio_override = false, $freq_override = false, $linkfunc = 'get_permalink', $type = 'post' ) {
|
3159 |
$prio = array();
|
3160 |
$args = array(
|
3161 |
'prio_override' => $prio_override,
|
3170 |
if ( is_array( $posts ) ) {
|
3171 |
foreach ( $posts as $key => $post ) {
|
3172 |
// Determine if we check the post for images.
|
3173 |
+
$is_single = true;
|
3174 |
$post->filter = 'sample';
|
3175 |
+
$timestamp = null;
|
3176 |
if ( 'get_permalink' === $linkfunc ) {
|
3177 |
$url = $this->get_permalink( $post );
|
3178 |
} else {
|
3179 |
+
$url = call_user_func( $linkfunc, $post );
|
3180 |
$is_single = false;
|
3181 |
}
|
3182 |
|
3191 |
}
|
3192 |
if ( '0000-00-00 00:00:00' !== $date ) {
|
3193 |
$timestamp = $date;
|
3194 |
+
$date = date( 'Y-m-d\TH:i:s\Z', mysql2date( 'U', $date ) );
|
3195 |
} else {
|
3196 |
$date = 0;
|
3197 |
}
|
3198 |
if ( $prio_override && $freq_override ) {
|
3199 |
+
$pr_info = array(
|
3200 |
+
'lastmod' => $date,
|
3201 |
+
'changefreq' => null,
|
3202 |
+
'priority' => null,
|
3203 |
+
);
|
3204 |
} else {
|
3205 |
if ( empty( $post->comment_count ) ) {
|
3206 |
$stat = 0;
|
3219 |
$pr_info['priority'] = $prio_override;
|
3220 |
}
|
3221 |
if ( ( 'sel' === $this->options[ $this->prefix . 'prio_post' ] ) && isset( $this->options[ $this->prefix . 'prio_post_' . $post->post_type ] ) ) {
|
3222 |
+
if (
|
3223 |
+
'no' !== $this->options[ $this->prefix . 'prio_post_' . $post->post_type ]
|
3224 |
+
&& 'sel' !== $this->options[ $this->prefix . 'prio_post_' . $post->post_type ]
|
3225 |
+
) {
|
3226 |
$pr_info['priority'] = $this->options[ $this->prefix . 'prio_post_' . $post->post_type ];
|
3227 |
}
|
3228 |
}
|
3229 |
if ( ( 'sel' === $this->options[ $this->prefix . 'freq_post' ] ) && isset( $this->options[ $this->prefix . 'freq_post_' . $post->post_type ] ) ) {
|
3230 |
+
if (
|
3231 |
+
'no' !== $this->options[ $this->prefix . 'freq_post_' . $post->post_type ]
|
3232 |
+
&& 'sel' !== $this->options[ $this->prefix . 'freq_post_' . $post->post_type ]
|
3233 |
+
) {
|
3234 |
$pr_info['changefreq'] = $this->options[ $this->prefix . 'freq_post_' . $post->post_type ];
|
3235 |
}
|
3236 |
}
|
3254 |
}
|
3255 |
|
3256 |
// RSS expects the GMT date.
|
3257 |
+
$timestamp = mysql2date( 'U', $post->post_modified_gmt );
|
3258 |
$pr_info['rss'] = array(
|
3259 |
+
'title' => $title,
|
3260 |
'description' => $this->get_the_excerpt( $post ),
|
3261 |
+
'pubDate' => date( 'r', $timestamp ),
|
3262 |
+
'timestamp ' => $timestamp,
|
3263 |
+
'post_type' => $post->post_type,
|
3264 |
);
|
3265 |
}
|
3266 |
|
|
|
3267 |
$pr_info['image:image'] = $is_single ? $this->get_images_from_post( $post ) : null;
|
3268 |
+
|
3269 |
$pr_info = apply_filters( $this->prefix . 'prio_item_filter', $pr_info, $post, $args );
|
3270 |
if ( ! empty( $pr_info ) ) {
|
3271 |
$prio[] = $pr_info;
|
3293 |
$text = strip_shortcodes( $post->post_content );
|
3294 |
$text = apply_filters( 'the_content', $text );
|
3295 |
$text = str_replace( ']]>', ']]>', $text );
|
3296 |
+
|
3297 |
$excerpt_length = apply_filters( 'excerpt_length', 55 );
|
3298 |
+
$excerpt_more = apply_filters( 'excerpt_more', '[…]' );
|
3299 |
return wp_trim_words( $text, $excerpt_length, $excerpt_more );
|
3300 |
}
|
3301 |
return '';
|
3317 |
return array();
|
3318 |
}
|
3319 |
|
3320 |
+
$images = array();
|
3321 |
// the table term meta table is not defined for lower versions.
|
3322 |
if ( version_compare( $wp_version, '4.4.0', '>=' ) ) {
|
3323 |
$thumbnail_id = get_term_meta( $term->term_id, 'thumbnail_id', true );
|
3339 |
/**
|
3340 |
* Return the images from the post.
|
3341 |
*
|
3342 |
+
* @param WP_Post|int $post the post object.
|
3343 |
*
|
3344 |
* @since 2.4
|
3345 |
*
|
3346 |
* @return array
|
3347 |
*/
|
3348 |
private function get_images_from_post( $post ) {
|
|
|
|
|
3349 |
if ( ! aiosp_include_images() ) {
|
3350 |
return array();
|
3351 |
}
|
3403 |
}
|
3404 |
}
|
3405 |
|
|
|
3406 |
$content = $post->post_content;
|
3407 |
|
3408 |
$this->get_gallery_images( $post, $images );
|
3416 |
// Filter out duplicates.
|
3417 |
$tmp = array_unique( $images );
|
3418 |
}
|
3419 |
+
|
3420 |
// remove any invalid/empty images.
|
3421 |
$tmp = array_filter( $images, array( $this, 'is_image_valid' ) );
|
3422 |
+
|
3423 |
$images = array();
|
3424 |
foreach ( $tmp as $image ) {
|
3425 |
+
$image_attributes = $this->get_image_attributes( $image );
|
3426 |
+
|
3427 |
$images[] = array_merge(
|
3428 |
+
array(
|
3429 |
+
'image:loc' => $this->clean_url( $image ),
|
3430 |
+
),
|
3431 |
+
$image_attributes
|
3432 |
);
|
3433 |
}
|
3434 |
}
|
3440 |
* Fetch image attributes such as title and caption given the image URL.
|
3441 |
*
|
3442 |
* @param string $url The image URL.
|
3443 |
+
* @return array
|
3444 |
*/
|
3445 |
private function get_image_attributes( $url ) {
|
|
|
3446 |
global $wpdb;
|
3447 |
+
$attributes = array();
|
3448 |
+
|
3449 |
+
$attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid='%s';", $url ) );
|
3450 |
if ( $attachment && is_array( $attachment ) && is_numeric( $attachment[0] ) ) {
|
3451 |
+
$attributes = array(
|
3452 |
'image:caption' => wp_get_attachment_caption( $attachment[0] ),
|
3453 |
+
'image:title' => get_the_title( $attachment[0] ),
|
3454 |
);
|
3455 |
}
|
3456 |
return $attributes;
|
3459 |
/**
|
3460 |
* Fetch images from WP, Jetpack and WooCommerce galleries.
|
3461 |
*
|
3462 |
+
* @param WP_Post $post The post.
|
3463 |
+
* @param array $images the array of images.
|
3464 |
*
|
3465 |
* @since 2.4.2
|
3466 |
*/
|
3473 |
if ( has_shortcode( $post->post_content, 'gallery' ) ) {
|
3474 |
// Get the jetpack gallery images.
|
3475 |
if ( class_exists( 'Jetpack_PostImages' ) ) {
|
3476 |
+
$jetpack = Jetpack_PostImages::get_images( $post->ID );
|
3477 |
if ( $jetpack ) {
|
3478 |
foreach ( $jetpack as $jetpack_image ) {
|
3479 |
+
$images[] = $jetpack_image['src'];
|
3480 |
}
|
3481 |
}
|
3482 |
}
|
3518 |
*/
|
3519 |
private function get_content_from_galleries( $content ) {
|
3520 |
// Support for NextGen Gallery.
|
3521 |
+
static $gallery_types;
|
|
|
3522 |
|
3523 |
+
$gallery_types = array( 'ngg_images' );
|
3524 |
+
$types = apply_filters( 'aioseop_gallery_shortcodes', $gallery_types );
|
3525 |
+
$gallery_content = '';
|
3526 |
|
3527 |
if ( ! $types ) {
|
3528 |
return $gallery_content;
|
3529 |
}
|
3530 |
|
3531 |
+
$found = array();
|
3532 |
if ( $types ) {
|
3533 |
foreach ( $types as $type ) {
|
3534 |
if ( has_shortcode( $content, $type ) ) {
|
3567 |
// Recreate the shortcodes and then render them to get the HTML content.
|
3568 |
if ( $galleries ) {
|
3569 |
foreach ( $galleries as $shortcode => $attributes ) {
|
3570 |
+
$code = '[' . $shortcode;
|
3571 |
+
|
3572 |
foreach ( $attributes as $key => $value ) {
|
3573 |
+
$code .= " $key=$value";
|
3574 |
}
|
3575 |
$code .= ']';
|
3576 |
+
|
3577 |
$gallery_content .= do_shortcode( $code );
|
3578 |
}
|
3579 |
}
|
3590 |
*
|
3591 |
* @return string
|
3592 |
*/
|
3593 |
+
public function clean_url( $url ) {
|
3594 |
// remove the query string.
|
3595 |
+
$url = strtok( $url, '?' );
|
3596 |
// make the url XML-safe.
|
3597 |
+
$url = htmlspecialchars( $url );
|
3598 |
// Make the url absolute, if its relative.
|
3599 |
+
$url = aiosp_common::absolutize_url( $url );
|
3600 |
return apply_filters( 'aioseop_clean_url', $url );
|
3601 |
}
|
3602 |
|
3612 |
*
|
3613 |
* @return bool
|
3614 |
*/
|
3615 |
+
public function is_image_valid( $image ) {
|
3616 |
global $wp_version;
|
3617 |
|
3618 |
// Bail if empty image.
|
3622 |
|
3623 |
global $wp_version;
|
3624 |
if ( version_compare( $wp_version, '4.4', '<' ) ) {
|
3625 |
+
// TODO Change to wp_parse_url().
|
3626 |
$p_url = parse_url( $image );
|
3627 |
+
$url = $p_url['scheme'] . $p_url['host'] . $p_url['path'];
|
3628 |
} elseif ( version_compare( $wp_version, '4.7', '<' ) ) {
|
3629 |
// Compatability for older WP version that don't have 4.7 changes.
|
3630 |
// @link https://core.trac.wordpress.org/changeset/38726
|
3631 |
$p_url = wp_parse_url( $image );
|
3632 |
+
$url = $p_url['scheme'] . $p_url['host'] . $p_url['path'];
|
3633 |
} else {
|
3634 |
$component = PHP_URL_PATH;
|
3635 |
+
$url = wp_parse_url( $image, $component );
|
3636 |
}
|
3637 |
|
3638 |
// make the url absolute, if its relative.
|
3639 |
+
$image = aiosp_common::absolutize_url( $image );
|
3640 |
+
// TODO Change to wp_parse_url().
|
3641 |
+
$extn = pathinfo( parse_url( $image, PHP_URL_PATH ), PATHINFO_EXTENSION );
|
3642 |
+
$allowed = apply_filters( 'aioseop_allowed_image_extensions', self::$image_extensions );
|
3643 |
// Bail if image does not refer to an image file otherwise google webmaster tools might reject the sitemap.
|
3644 |
if ( ! in_array( $extn, $allowed, true ) ) {
|
3645 |
return false;
|
3646 |
}
|
3647 |
|
3648 |
+
// TODO Change to wp_parse_url().
|
3649 |
$image_host = parse_url( $image, PHP_URL_HOST );
|
3650 |
$host = parse_url( home_url(), PHP_URL_HOST );
|
3651 |
|
3652 |
if ( $image_host !== $host ) {
|
3653 |
// Allowed hosts will be provided in a wildcard format i.e. img.yahoo.* or *.akamai.*.
|
3654 |
// And we will convert that into a regular expression for matching.
|
3655 |
+
$whitelist = apply_filters( 'aioseop_images_allowed_from_hosts', array() );
|
3656 |
+
$allowed = false;
|
3657 |
if ( $whitelist ) {
|
3658 |
foreach ( $whitelist as $pattern ) {
|
3659 |
if ( preg_match( '/' . str_replace( '*', '.*', $pattern ) . '/', $image_host ) === 1 ) {
|
3674 |
* @param string $content the post content.
|
3675 |
* @param array $images the array of images.
|
3676 |
*/
|
3677 |
+
public function parse_content_for_images( $content, &$images ) {
|
3678 |
// These tags should be WITHOUT trailing space because some plugins such as the nextgen gallery put newlines immediately after <img.
|
3679 |
+
$total = substr_count( $content, '<img' ) + substr_count( $content, '<IMG' );
|
3680 |
// no images found.
|
3681 |
if ( 0 === $total ) {
|
3682 |
return;
|
3684 |
|
3685 |
if ( class_exists( 'DOMDocument' ) ) {
|
3686 |
$dom = new domDocument();
|
3687 |
+
|
3688 |
// Non-compliant HTML might give errors, so ignore them.
|
3689 |
libxml_use_internal_errors( true );
|
3690 |
$dom->loadHTML( $content );
|
3691 |
libxml_clear_errors();
|
3692 |
+
|
3693 |
$dom->preserveWhiteSpace = false;
|
3694 |
+
|
3695 |
$matches = $dom->getElementsByTagName( 'img' );
|
3696 |
foreach ( $matches as $match ) {
|
3697 |
$images[] = $match->getAttribute( 'src' );
|
3718 |
*
|
3719 |
* @return array
|
3720 |
*/
|
3721 |
+
public function get_tax_args( $page = 0 ) {
|
3722 |
$args = array();
|
3723 |
if ( $this->option_isset( 'excl_categories' ) ) {
|
3724 |
$args['exclude'] = $this->options[ $this->prefix . 'excl_categories' ];
|
3740 |
*
|
3741 |
* @return mixed
|
3742 |
*/
|
3743 |
+
public function set_post_args( $args ) {
|
3744 |
if ( $this->option_isset( 'excl_categories' ) ) {
|
3745 |
$cats = array();
|
3746 |
foreach ( $this->options[ $this->prefix . 'excl_categories' ] as $c ) {
|
3760 |
*
|
3761 |
* @return array
|
3762 |
*/
|
3763 |
+
public function get_date_archive_prio_data() {
|
3764 |
$args = array(
|
3765 |
'numberposts' => 50000,
|
3766 |
+
'post_type' => 'post',
|
3767 |
);
|
3768 |
$args = $this->set_post_args( $args );
|
3769 |
$posts = $this->get_all_post_type_data( $args );
|
3776 |
*
|
3777 |
* @return array
|
3778 |
*/
|
3779 |
+
public function get_author_prio_data() {
|
3780 |
+
$args = array(
|
3781 |
+
'numberposts' => 50000,
|
3782 |
+
'post_type' => 'post',
|
3783 |
+
);
|
3784 |
$args = $this->set_post_args( $args );
|
3785 |
$posts = $this->get_all_post_type_data( $args );
|
3786 |
|
3796 |
*
|
3797 |
* @return array
|
3798 |
*/
|
3799 |
+
public function get_all_post_priority_data( $include = 'any', $status = 'publish', $page = 0 ) {
|
3800 |
+
$posts = array();
|
3801 |
+
$page_query = array();
|
3802 |
if ( ! empty( $this->options[ "{$this->prefix}indexes" ] ) ) {
|
3803 |
$page_query = array( 'offset' => $page * $this->max_posts );
|
3804 |
}
|
3805 |
if ( ( 'publish' === $status ) && ( 'attachment' === $include ) ) {
|
3806 |
$status = 'inherit';
|
3807 |
}
|
3808 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
3809 |
if ( is_array( $include ) && ( ( $pos = array_search( 'attachment', $include ) ) !== false ) ) {
|
3810 |
unset( $include[ $pos ] );
|
3811 |
+
$att_args = array(
|
3812 |
+
'post_type' => 'attachment',
|
3813 |
+
'post_status' => 'inherit',
|
3814 |
+
);
|
3815 |
$att_args = array_merge( $att_args, $page_query );
|
3816 |
$posts = $this->get_all_post_type_data( $att_args );
|
3817 |
}
|
3818 |
+
$args = array(
|
3819 |
+
'post_type' => $include,
|
3820 |
+
'post_status' => $status,
|
3821 |
+
);
|
3822 |
$args = array_merge( $args, $page_query );
|
3823 |
$args = $this->set_post_args( $args );
|
3824 |
$posts = array_merge( $this->get_all_post_type_data( $args ), $posts );
|
3825 |
|
3826 |
+
$links = $this->get_prio_from_posts( $posts, $this->get_default_priority( 'post', true ), $this->get_default_frequency( 'post', true ) );
|
3827 |
+
$links = array_merge( $links, $this->get_archive_prio_from_posts( $posts ) );
|
3828 |
return $links;
|
3829 |
}
|
3830 |
|
3836 |
*
|
3837 |
* @return array
|
3838 |
*/
|
3839 |
+
public function get_all_permalinks( $include = 'any', $status = 'publish' ) {
|
3840 |
+
$args = array(
|
3841 |
+
'post_type' => $include,
|
3842 |
+
'post_status' => $status,
|
3843 |
+
);
|
3844 |
$args = $this->set_post_args( $args );
|
3845 |
$posts = $this->get_all_post_type_data( $args );
|
3846 |
$links = $this->get_post_permalinks( $posts );
|
3861 |
*
|
3862 |
* @return null
|
3863 |
*/
|
3864 |
+
public function cache_structure( $pre ) {
|
3865 |
return $this->cache_struct;
|
3866 |
}
|
3867 |
|
3872 |
*
|
3873 |
* @return null
|
3874 |
*/
|
3875 |
+
public function cache_home( $pre ) {
|
3876 |
return $this->cache_home;
|
3877 |
}
|
3878 |
|
3879 |
/**
|
3880 |
* Cache permalink_structure and home for repeated sitemap queries.
|
3881 |
*/
|
3882 |
+
public function cache_options() {
|
3883 |
static $start = true;
|
3884 |
if ( $start ) {
|
3885 |
$this->cache_struct = get_option( 'permalink_structure' );
|
3902 |
*
|
3903 |
* @return string|WP_Error
|
3904 |
*/
|
3905 |
+
public function get_term_link( $term, $taxonomy = '' ) {
|
3906 |
static $start = true;
|
3907 |
if ( $start ) {
|
3908 |
$this->cache_options();
|
3919 |
*
|
3920 |
* @return false|string
|
3921 |
*/
|
3922 |
+
public function get_permalink( $post ) {
|
3923 |
static $start = true;
|
3924 |
if ( $start ) {
|
3925 |
$this->cache_options();
|
3934 |
*
|
3935 |
* @param $args
|
3936 |
*
|
3937 |
+
* @return array|int|mixed|null|WP_Error
|
3938 |
*/
|
3939 |
+
public function get_all_term_counts( $args ) {
|
3940 |
$term_counts = null;
|
3941 |
if ( ! empty( $args ) && ! empty( $args['taxonomy'] ) ) {
|
3942 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
3943 |
if ( ! is_array( $args['taxonomy'] ) || ( count( $args['taxonomy'] ) == 1 ) ) {
|
3944 |
if ( is_array( $args['taxonomy'] ) ) {
|
3945 |
$args['taxonomy'] = array_shift( $args['taxonomy'] );
|
3967 |
*
|
3968 |
* @return array
|
3969 |
*/
|
3970 |
+
public function get_all_post_counts( $args ) {
|
3971 |
$post_counts = array();
|
3972 |
$status = 'inherit';
|
3973 |
if ( ! empty( $args['post_status'] ) ) {
|
3984 |
$count_args['post_status'] = 'inherit';
|
3985 |
}
|
3986 |
|
3987 |
+
$count_args['post_type'] = $post_type;
|
3988 |
$post_counts[ $post_type ] = $this->get_post_count( $count_args );
|
3989 |
}
|
3990 |
}
|
3998 |
*
|
3999 |
* @param $args
|
4000 |
*/
|
4001 |
+
public function modify_post_params_for_external_plugins( &$args ) {
|
4002 |
// if WPML is being used, do not suppress filters.
|
4003 |
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
4004 |
$args['suppress_filters'] = false;
|
4014 |
*
|
4015 |
* @return int
|
4016 |
*/
|
4017 |
+
public function get_post_count( $args ) {
|
4018 |
$this->modify_post_params_for_external_plugins( $args );
|
4019 |
|
4020 |
// we will use WP_Query instead of get_posts here as that is more efficient.
|
4037 |
*
|
4038 |
* @return int
|
4039 |
*/
|
4040 |
+
public function get_total_post_count( $args ) {
|
4041 |
$total = 0;
|
4042 |
$counts = $this->get_all_post_counts( $args );
|
4043 |
if ( ! empty( $counts ) ) {
|
4054 |
*
|
4055 |
* @param $args
|
4056 |
*
|
4057 |
+
* @return array|mixed
|
4058 |
*/
|
4059 |
+
public function get_all_post_type_data( $args ) {
|
4060 |
$defaults = array(
|
4061 |
'numberposts' => $this->max_posts,
|
4062 |
'offset' => 0,
|
4094 |
$exclude = preg_split( '/[\s,]+/', trim( $args['exclude'] ) );
|
4095 |
if ( ! empty( $exclude ) ) {
|
4096 |
foreach ( $exclude as $k => $v ) {
|
4097 |
+
if ( ! is_numeric( $v ) ) {
|
4098 |
$exclude_slugs[] = $v;
|
4099 |
unset( $exclude[ $k ] );
|
4100 |
}
|
4124 |
$posts = get_posts( apply_filters( $this->prefix . 'post_query', $args ) );
|
4125 |
if ( ! empty( $exclude_slugs ) ) {
|
4126 |
foreach ( $posts as $k => $v ) {
|
4127 |
+
// TODO Add `true` in 3rd argument with in_array(); which changes it to a strict comparison.
|
4128 |
if ( in_array( $v->post_name, $exclude_slugs ) ) {
|
4129 |
unset( $posts[ $k ] );
|
4130 |
}
|
4135 |
return $posts;
|
4136 |
}
|
4137 |
}
|
4138 |
+
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: hallsofmontezuma, wpsmort, dougal, pbaylies, arnaudbroes
|
|
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¤cy_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
|
4 |
Tags: seo, all in one seo, google, twitter, page, image seo, social, search engine optimization, sitemap, WordPress SEO, meta, meta description, xml sitemap, google sitemap, sitemaps, robots meta, yahoo, bing, news sitemaps, multisite, canonical, nofollow, noindex, keywords, description, webmaster tools, google webmaster tools, google analytics
|
5 |
Requires at least: 4.4
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
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¤cy_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
|
4 |
Tags: seo, all in one seo, google, twitter, page, image seo, social, search engine optimization, sitemap, WordPress SEO, meta, meta description, xml sitemap, google sitemap, sitemaps, robots meta, yahoo, bing, news sitemaps, multisite, canonical, nofollow, noindex, keywords, description, webmaster tools, google webmaster tools, google analytics
|
5 |
Requires at least: 4.4
|
6 |
+
Tested up to: 5.0
|
7 |
+
Stable tag: 2.10
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|