The SEO Framework - Version 3.0.4

Version Description

  • Illustrious =

Release date:

  • February 25th, 2017

Did you know?

  • We're working on an extension for keyword and subject analysis, named Focus.
  • In its current state, it's already on par with other solutions, but we are going to take it even further.
  • More details will follow in a blog post, which we'll link to on our Twitter page when the features are ready.

Summarized:

  • This is a maintenance release with over 10 bugs fixed. Most notoriously were pixel guideline calculation errors and home page title errors.
  • Open Graph and Twitter custom title and description options have been added to every post, page, and CPT.
  • The description character count and pixel length guidelines have been updated.
  • All publicly queryable CPT posts and pages now support SEO settings and are included in the sitemap. No more messing with filters is needed.

About the new description guidelines:

  • Google increased their SERP's description length a few months ago, so we've updated the upper-limit guidelines.
  • We recommend enforcing these new guidelines for new pages, cornerstone pages, and the home page.
  • Although the description lengths have been updated, the transient cache isn't invalidated.
  • Over time the cache will refresh itself, this is done automatically by WordPress, or via your caching plugin's transients handler (if applicable).

About the social meta input:

  • There are new Open Graph and Twitter inputs in the SEO Settings.
  • The Twitter settings, when left empty, will use the Open Graph output.
  • The Open Graph settings, when left empty, will use the SEO meta output.
  • As always, auto-generated Open Graph and Twitter descriptions won't use prefixes.

Found unwanted links in the sitemap?

  • If you find posts in the sitemap that shouldn't be there, please refer to our renewed FAQ.
  • The FAQ entry title is "The sitemap contains unwanted links".

View the detailed log.

Download this release

Release Info

Developer Cybr
Plugin Icon 128x128 The SEO Framework
Version 3.0.4
Comparing to
See all releases

Code changes from version 3.0.3 to 3.0.4

Files changed (55) hide show
  1. autodescription.php +3 -3
  2. inc/classes/admin-init.class.php +27 -20
  3. inc/classes/admin-pages.class.php +16 -4
  4. inc/classes/cache.class.php +1 -1
  5. inc/classes/compat.class.php +1 -1
  6. inc/classes/core.class.php +36 -34
  7. inc/classes/debug.class.php +3 -3
  8. inc/classes/deprecated.class.php +1 -1
  9. inc/classes/detect.class.php +17 -16
  10. inc/classes/doing-it-right.class.php +71 -11
  11. inc/classes/feed.class.php +1 -1
  12. inc/classes/generate-description.class.php +97 -6
  13. inc/classes/generate-image.class.php +2 -1
  14. inc/classes/generate-ldjson.class.php +4 -3
  15. inc/classes/generate-title.class.php +118 -34
  16. inc/classes/generate-url.class.php +3 -5
  17. inc/classes/generate.class.php +1 -1
  18. inc/classes/init.class.php +4 -1
  19. inc/classes/inpost.class.php +18 -3
  20. inc/classes/load.class.php +1 -1
  21. inc/classes/metaboxes.class.php +8 -8
  22. inc/classes/post-data.class.php +20 -12
  23. inc/classes/profile.class.php +1 -1
  24. inc/classes/query.class.php +1 -1
  25. inc/classes/render.class.php +17 -13
  26. inc/classes/sanitize.class.php +3 -2
  27. inc/classes/site-options.class.php +2 -2
  28. inc/classes/sitemaps.class.php +141 -131
  29. inc/classes/term-data.class.php +17 -11
  30. inc/classes/user-data.class.php +1 -1
  31. inc/compat/plugin-bbpress.php +2 -1
  32. inc/compat/plugin-wpml.php +1 -1
  33. inc/functions/deprecated.php +1 -1
  34. inc/functions/optionsapi.php +1 -1
  35. inc/functions/plugin-activation.php +1 -1
  36. inc/functions/plugin-deactivation.php +1 -1
  37. inc/functions/plugin-test-server.php +4 -4
  38. inc/functions/upgrade.php +1 -1
  39. inc/interfaces/debug.interface.php +1 -1
  40. inc/views/inpost/seo-settings-singular.php +119 -7
  41. inc/views/inpost/seo-settings-tt.php +2 -1
  42. inc/views/metaboxes/homepage-metabox.php +2 -1
  43. inc/views/metaboxes/schema-metabox.php +1 -0
  44. language/autodescription.pot +217 -199
  45. lib/css/tsf-rtl.css +7 -6
  46. lib/css/tsf-rtl.min.css +1 -1
  47. lib/css/tsf.css +7 -6
  48. lib/css/tsf.min.css +1 -1
  49. lib/js/externs/tsf.externs.js +2 -2
  50. lib/js/externs/tsf.externs.protected.js +2 -2
  51. lib/js/tsf.js +365 -73
  52. lib/js/tsf.min.js +1 -1
  53. load.php +1 -1
  54. readme.txt +79 -32
  55. wpml-config.xml +13 -0
autodescription.php CHANGED
@@ -3,7 +3,7 @@
3
* Plugin Name: The SEO Framework
4
* Plugin URI: https://theseoframework.com/
5
* Description: An automated, advanced, accessible, unbranded and extremely fast SEO solution for any WordPress website.
6
- * Version: 3.0.3
7
* Author: Sybre Waaijer
8
* Author URI: https://theseoframework.com/
9
* License: GPLv3
@@ -15,7 +15,7 @@ defined( 'ABSPATH' ) or die;
15
16
/**
17
* The SEO Framework plugin
18
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
19
*
20
* This program is free software: you can redistribute it and/or modify
21
* it under the terms of the GNU General Public License version 3 as published
@@ -51,7 +51,7 @@ defined( 'ABSPATH' ) or die;
51
*
52
* @since 1.0.0
53
*/
54
- define( 'THE_SEO_FRAMEWORK_VERSION', '3.0.3' );
55
56
/**
57
* The plugin Database version.
3
* Plugin Name: The SEO Framework
4
* Plugin URI: https://theseoframework.com/
5
* Description: An automated, advanced, accessible, unbranded and extremely fast SEO solution for any WordPress website.
6
+ * Version: 3.0.4
7
* Author: Sybre Waaijer
8
* Author URI: https://theseoframework.com/
9
* License: GPLv3
15
16
/**
17
* The SEO Framework plugin
18
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
19
*
20
* This program is free software: you can redistribute it and/or modify
21
* it under the terms of the GNU General Public License version 3 as published
51
*
52
* @since 1.0.0
53
*/
54
+ define( 'THE_SEO_FRAMEWORK_VERSION', '3.0.4' );
55
56
/**
57
* The plugin Database version.
inc/classes/admin-init.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -207,11 +207,12 @@ class Admin_Init extends Init {
207
* @since 2.6.0
208
* @staticvar array $strings : The l10n strings.
209
* @since 2.7.0 Added AJAX nonce: 'autodescription-ajax-nonce'
210
- * @since 2.8.0 1. Added input detection: 'hasInput'
211
- * 2. Reworked output.
212
- * 3. Removed unused caching.
213
- * 4. Added dynamic output control.
214
* @since 2.9.0 Added boolean $returnValue['states']['isSettingsPage']
215
*
216
* @return array $strings The l10n strings.
217
*/
@@ -265,7 +266,7 @@ class Admin_Init extends Init {
265
$ishome = true;
266
267
if ( $use_additions ) {
268
- $additions = $home_tagline ? $home_tagline : $description;
269
} else {
270
$additions = '';
271
}
@@ -369,7 +370,7 @@ class Admin_Init extends Init {
369
'descriptionSeparator' => $description_separator,
370
'titleLocation' => $title_location,
371
'titlePixelGuideline' => 600,
372
- 'descPixelGuideline' => $is_post_edit ? ( $this->is_page() ? 920 : 820 ) : 920,
373
),
374
'other' => $this->additional_js_l10n( null, array(), true ),
375
);
@@ -555,18 +556,22 @@ class Admin_Init extends Init {
555
556
$_colors = $GLOBALS['_wp_admin_css_colors'];
557
558
- if ( ! isset( $_colors[ $scheme ]->colors ) || ! is_array( $_colors[ $scheme ]->colors ) )
559
- return '';
560
561
- $_scheme = $_colors[ $scheme ]->colors;
562
563
- $bg = $_scheme[0];
564
- $bg_accent = $_scheme[1];
565
- $color = $_scheme[2];
566
- $color_accent = $_scheme[3];
567
568
- $bg_alt_font = '#' . $this->get_relative_fontcolor( $bg );
569
- // $bg_accent_alt_font = '#' . $this->get_relative_fontcolor( $bg_accent );
570
571
$css = array(
572
'.tsf-flex-nav-tab .tsf-flex-nav-tab-radio:checked + .tsf-flex-nav-tab-label' => array(
@@ -574,7 +579,7 @@ class Admin_Init extends Init {
574
),
575
'.tsf-tooltip-text-wrap' => array(
576
"background-color:$bg_accent",
577
- "color:$bg_alt_font",
578
),
579
'.tsf-tooltip-arrow:after' => array(
580
"border-top-color:$bg_accent",
@@ -588,10 +593,12 @@ class Admin_Init extends Init {
588
* Applies filters 'the_seo_framework_admin_color_css'
589
*
590
* @since 3.0.0
591
- * @param array $css The current styles.
592
- * @param string $scheme The current admin scheme.
593
*/
594
- $css = (array) \apply_filters( 'the_seo_framework_admin_color_css', $css, $scheme );
595
596
$out = '';
597
foreach ( $css as $attr => $style )
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
207
* @since 2.6.0
208
* @staticvar array $strings : The l10n strings.
209
* @since 2.7.0 Added AJAX nonce: 'autodescription-ajax-nonce'
210
+ * @since 2.8.0 1 : Added input detection: 'hasInput'
211
+ * 2 : Reworked output.
212
+ * 3 : Removed unused caching.
213
+ * 4 : Added dynamic output control.
214
* @since 2.9.0 Added boolean $returnValue['states']['isSettingsPage']
215
+ * @since 3.0.4 `descPixelGuideline` has been increased from "920 and 820" to "1820 and 1720" respectively.
216
*
217
* @return array $strings The l10n strings.
218
*/
266
$ishome = true;
267
268
if ( $use_additions ) {
269
+ $additions = $home_tagline ?: $description;
270
} else {
271
$additions = '';
272
}
370
'descriptionSeparator' => $description_separator,
371
'titleLocation' => $title_location,
372
'titlePixelGuideline' => 600,
373
+ 'descPixelGuideline' => $is_post_edit ? ( $this->is_page() ? 1820 : 1720 ) : 1820,
374
),
375
'other' => $this->additional_js_l10n( null, array(), true ),
376
);
556
557
$_colors = $GLOBALS['_wp_admin_css_colors'];
558
559
+ if (
560
+ ! isset( $_colors[ $scheme ]->colors )
561
+ || ! is_array( $_colors[ $scheme ]->colors )
562
+ || count( $_colors[ $scheme ]->colors ) < 4
563
+ ) return '';
564
565
+ $colors = $_colors[ $scheme ]->colors;
566
567
+ $bg = $colors[0];
568
+ $bg_accent = $colors[1];
569
+ $color = $colors[2];
570
+ $color_accent = $colors[3];
571
572
+ // TODO fix this.
573
+ // $bg_alt_font = '#' . $this->get_relative_fontcolor( $bg );
574
+ $bg_accent_alt_font = '#' . $this->get_relative_fontcolor( $bg_accent );
575
576
$css = array(
577
'.tsf-flex-nav-tab .tsf-flex-nav-tab-radio:checked + .tsf-flex-nav-tab-label' => array(
579
),
580
'.tsf-tooltip-text-wrap' => array(
581
"background-color:$bg_accent",
582
+ "color:$bg_accent_alt_font",
583
),
584
'.tsf-tooltip-arrow:after' => array(
585
"border-top-color:$bg_accent",
593
* Applies filters 'the_seo_framework_admin_color_css'
594
*
595
* @since 3.0.0
596
+ * @since 3.0.4 Now passes $colors.
597
+ * @param array $css The current styles. Empty it to disable conditional styling.
598
+ * @param string $scheme The current admin scheme name.
599
+ * @param array $colors The current admin scheme values.
600
*/
601
+ $css = (array) \apply_filters( 'the_seo_framework_admin_color_css', $css, $scheme, $colors );
602
603
$out = '';
604
foreach ( $css as $attr => $style )
inc/classes/admin-pages.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -871,18 +871,30 @@ class Admin_Pages extends Inpost {
871
}
872
873
/**
874
- * Outputs floating title HTML for JavaScript.
875
*
876
- * @since 3.0.0
877
*/
878
- public function output_floating_title_elements() {
879
?>
880
<span id="tsf-title-offset" class="hide-if-no-js"></span>
881
<span id="tsf-title-placeholder" class="hide-if-no-js"></span>
882
<span id="tsf-title-placeholder-prefix" class="hide-if-no-js"></span>
883
<?php
884
}
885
886
/**
887
* Outputs character counter wrap for both JavaScript and no-Javascript.
888
*
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
871
}
872
873
/**
874
+ * Outputs floating and reference title HTML elements for JavaScript.
875
*
876
+ * @since 3.0.4
877
*/
878
+ public function output_js_title_elements() {
879
?>
880
+ <span id="tsf-title-reference" style="display:none"></span>
881
<span id="tsf-title-offset" class="hide-if-no-js"></span>
882
<span id="tsf-title-placeholder" class="hide-if-no-js"></span>
883
<span id="tsf-title-placeholder-prefix" class="hide-if-no-js"></span>
884
<?php
885
}
886
887
+ /**
888
+ * Outputs reference description HTML elements for JavaScript.
889
+ *
890
+ * @since 3.0.4
891
+ */
892
+ public function output_js_description_elements() {
893
+ ?>
894
+ <span id="tsf-description-reference" style="display:none"></span>
895
+ <?php
896
+ }
897
+
898
/**
899
* Outputs character counter wrap for both JavaScript and no-Javascript.
900
*
inc/classes/cache.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
inc/classes/compat.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
inc/classes/core.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -820,6 +820,9 @@ class Core {
820
* @since 2.8.0
821
* @since 2.9.0 Now adds a little more relative softness based on rel_lum.
822
* @since 2.9.2 (Typo): Renamed from 'get_relatitve_fontcolor' to 'get_relative_fontcolor'.
823
*
824
* @param string $hex The 3 to 6 character RGB hex. '#' prefix is supported.
825
* @return string The hexadecimal RGB relative font color, without '#' prefix.
@@ -839,41 +842,41 @@ class Core {
839
$g = hexdec( $hex[1] );
840
$b = hexdec( $hex[2] );
841
842
- //* Convert to sRGB for relative luminance.
843
- $sr = 0.2125 * $r;
844
- $sg = 0.7154 * $g;
845
- $sb = 0.0721 * $b;
846
- $rel_lum = 1 - ( $sr + $sg + $sb ) / 255;
847
-
848
- //* Convert to relative intvals between 1 and 0 for L from HSL
849
- // $rr = $r / 255;
850
- // $rg = $g / 255;
851
- // $rb = $b / 255;
852
- // $luminance = ( min( $rr, $rg, $rb ) + max( $rr, $rg, $rb ) ) / 2;
853
-
854
- //* Get perceptive luminance (greyscale) according to W3C.
855
- $gr = 0.2989 * $r;
856
- $gg = 0.5870 * $g;
857
- $gb = 0.1140 * $b;
858
- $per_lum = 1 - ( $gr + $gg + $gb ) / 255;
859
-
860
- //* Invert colors if they hit luminance boundaries.
861
if ( $rel_lum < 0.5 ) {
862
- //* Build dark. Add softness.
863
- $gr = $gr * $per_lum / 8 / 0.2989 + 8 * 0.2989 / $rel_lum;
864
- $gg = $gg * $per_lum / 8 / 0.5870 + 8 * 0.5870 / $rel_lum;
865
- $gb = $gb * $per_lum / 8 / 0.1140 + 8 * 0.1140 / $rel_lum;
866
} else {
867
- //* Build light. Add (subtract) softness.
868
- $gr = 255 - $gr * $per_lum / 8 * 0.2989 - 8 * 0.2989 / $rel_lum;
869
- $gg = 255 - $gg * $per_lum / 8 * 0.5870 - 8 * 0.5870 / $rel_lum;
870
- $gb = 255 - $gb * $per_lum / 8 * 0.1140 - 8 * 0.1140 / $rel_lum;
871
}
872
873
- //* Complete hexvals.
874
- $retr = str_pad( dechex( $gr ), 2, '0', STR_PAD_LEFT );
875
- $retg = str_pad( dechex( $gg ), 2, '0', STR_PAD_LEFT );
876
- $retb = str_pad( dechex( $gb ), 2, '0', STR_PAD_LEFT );
877
878
return $retr . $retg . $retb;
879
}
@@ -888,8 +891,7 @@ class Core {
888
* @since 2.9.0 : 1. Removed word boundary requirement for strong.
889
* 2. Now accepts regex count their numeric values in string.
890
* 3. Fixed header 1~6 calculation.
891
- * @since 2.9.3 : 1. Added $args parameter.
892
- * 2. TODO It now uses substr_replace instead of str_replace to prevent duplicated replacements.
893
* @link https://wordpress.org/plugins/about/readme.txt
894
*
895
* @param string $text The text that might contain markdown. Expected to be escaped.
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
820
* @since 2.8.0
821
* @since 2.9.0 Now adds a little more relative softness based on rel_lum.
822
* @since 2.9.2 (Typo): Renamed from 'get_relatitve_fontcolor' to 'get_relative_fontcolor'.
823
+ * @since 3.0.4 : Now uses WCAG's relative luminance formula
824
+ * @link https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast
825
+ * @link https://www.w3.org/WAI/GL/wiki/Relative_luminance
826
*
827
* @param string $hex The 3 to 6 character RGB hex. '#' prefix is supported.
828
* @return string The hexadecimal RGB relative font color, without '#' prefix.
842
$g = hexdec( $hex[1] );
843
$b = hexdec( $hex[2] );
844
845
+ $get_relative_luminance = function( $v ) {
846
+ //= Convert to 0~1 value.
847
+ $v = $v / 255;
848
+
849
+ if ( $v > .03928 ) {
850
+ $lum = pow( ( $v + .055 ) / 1.055, 2.4 );
851
+ } else {
852
+ $lum = $v / 12.92;
853
+ }
854
+ return $lum;
855
+ };
856
+
857
+ //* Use sRGB for relative luminance.
858
+ $sr = 0.2126 * $get_relative_luminance( $r );
859
+ $sg = 0.7152 * $get_relative_luminance( $g );
860
+ $sb = 0.0722 * $get_relative_luminance( $b );
861
+ $rel_lum = ( $sr + $sg + $sb );
862
+
863
+ //= Invert colors if they hit luminance boundaries.
864
if ( $rel_lum < 0.5 ) {
865
+ //* Build dark greyscale.
866
+ $gr = 255 - ( $r * 0.2989 / 8 ) * $rel_lum;
867
+ $gg = 255 - ( $g * 0.5870 / 8 ) * $rel_lum;
868
+ $gb = 255 - ( $b * 0.1140 / 8 ) * $rel_lum;
869
} else {
870
+ //* Build light greyscale.
871
+ $gr = ( $r * 0.2989 / 8 ) * $rel_lum;
872
+ $gg = ( $g * 0.5870 / 8 ) * $rel_lum;
873
+ $gb = ( $b * 0.1140 / 8 ) * $rel_lum;
874
}
875
876
+ //* Build RGB hex.
877
+ $retr = str_pad( dechex( round( $gr ) ), 2, '0', STR_PAD_LEFT );
878
+ $retg = str_pad( dechex( round( $gg ) ), 2, '0', STR_PAD_LEFT );
879
+ $retb = str_pad( dechex( round( $gb ) ), 2, '0', STR_PAD_LEFT );
880
881
return $retr . $retg . $retb;
882
}
891
* @since 2.9.0 : 1. Removed word boundary requirement for strong.
892
* 2. Now accepts regex count their numeric values in string.
893
* 3. Fixed header 1~6 calculation.
894
+ * @since 2.9.3 : Added $args parameter.
895
* @link https://wordpress.org/plugins/about/readme.txt
896
*
897
* @param string $text The text that might contain markdown. Expected to be escaped.
inc/classes/debug.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -228,7 +228,7 @@ final class Debug implements Debug_Interface {
228
/**
229
* Filter whether to trigger an error for _doing_it_wrong() calls.
230
*
231
- * @since 3.1.0
232
*
233
* @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
234
*/
@@ -280,7 +280,7 @@ final class Debug implements Debug_Interface {
280
/**
281
* Filter whether to trigger an error for _doing_it_wrong() calls.
282
*
283
- * @since 3.1.0
284
*
285
* @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
286
*/
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
228
/**
229
* Filter whether to trigger an error for _doing_it_wrong() calls.
230
*
231
+ * @since WP Core 3.1.0
232
*
233
* @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
234
*/
280
/**
281
* Filter whether to trigger an error for _doing_it_wrong() calls.
282
*
283
+ * @since WP Core 3.1.0
284
*
285
* @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
286
*/
inc/classes/deprecated.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
inc/classes/detect.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -249,7 +249,7 @@ class Detect extends Render {
249
}
250
}
251
252
- //* No class, function or constant found to exist
253
return false;
254
}
255
@@ -799,7 +799,7 @@ class Detect extends Render {
799
static $sep_output = null;
800
static $seplocation_output = null;
801
802
- if ( ! isset( $title_output ) || ! isset( $sep_output ) || ! isset( $seplocation_output ) ) {
803
//* Initiate caches, set up variables.
804
805
if ( '' === $title )
@@ -889,12 +889,13 @@ class Detect extends Render {
889
public function post_type_supports_inpost( $post_type = null ) {
890
891
if ( isset( $post_type ) && $post_type ) {
892
- $supports = (array) \apply_filters( 'the_seo_framework_custom_post_type_support',
893
- array(
894
- 'title',
895
- 'editor',
896
- )
897
- );
898
899
foreach ( $supports as $support ) {
900
if ( ! \post_type_supports( $post_type, $support ) ) {
@@ -922,23 +923,23 @@ class Detect extends Render {
922
*/
923
public function post_type_supports_custom_seo( $post_type = '' ) {
924
925
- $post_type = $this->get_supported_post_type( true, $post_type );
926
-
927
- if ( empty( $post_type ) )
928
- return false;
929
-
930
static $supported = array();
931
932
if ( isset( $supported[ $post_type ] ) )
933
return $supported[ $post_type ];
934
935
/**
936
* We now support all posts that allow a title, content editor and excerpt.
937
* To ease the flow, we have our basic list to check first.
938
*
939
* @since 2.3.5
940
*/
941
- if ( \post_type_supports( $post_type, 'autodescription-meta' ) || $this->post_type_supports_inpost( $post_type ) )
942
return $supported[ $post_type ] = true;
943
944
return $supported[ $post_type ] = false;
@@ -991,7 +992,7 @@ class Detect extends Render {
991
* Applies filters 'the_seo_framework_supported_post_type' : string
992
* @since 2.6.2
993
*
994
- * @param string $post_type The supported post type. Is boolean false if not supported.
995
* @param string $post_type_evaluated The evaluated post type.
996
*/
997
$post_type = (string) \apply_filters( 'the_seo_framework_supported_post_type', $post_type, $post_type_evaluated );
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
249
}
250
}
251
252
+ //* No globals, constant, function, or class found to exist
253
return false;
254
}
255
799
static $sep_output = null;
800
static $seplocation_output = null;
801
802
+ if ( ! isset( $title_output, $sep_output, $seplocation_output ) ) {
803
//* Initiate caches, set up variables.
804
805
if ( '' === $title )
889
public function post_type_supports_inpost( $post_type = null ) {
890
891
if ( isset( $post_type ) && $post_type ) {
892
+ /**
893
+ * Applies filters 'the_seo_framework_custom_post_type_support'
894
+ * @since 2.3.5
895
+ * @since 3.0.4 Default parameter now is `[]` instead of `['title','editor']`.
896
+ * @param array $supports The required post type support, like 'title', 'editor'.
897
+ */
898
+ $supports = (array) \apply_filters( 'the_seo_framework_custom_post_type_support', array() );
899
900
foreach ( $supports as $support ) {
901
if ( ! \post_type_supports( $post_type, $support ) ) {
923
*/
924
public function post_type_supports_custom_seo( $post_type = '' ) {
925
926
static $supported = array();
927
928
if ( isset( $supported[ $post_type ] ) )
929
return $supported[ $post_type ];
930
931
+ $post_type = $this->get_supported_post_type( true, $post_type );
932
+
933
+ if ( empty( $post_type ) )
934
+ return $supported[ $post_type ] = false;
935
+
936
/**
937
* We now support all posts that allow a title, content editor and excerpt.
938
* To ease the flow, we have our basic list to check first.
939
*
940
* @since 2.3.5
941
*/
942
+ if ( $this->post_type_supports_inpost( $post_type ) )
943
return $supported[ $post_type ] = true;
944
945
return $supported[ $post_type ] = false;
992
* Applies filters 'the_seo_framework_supported_post_type' : string
993
* @since 2.6.2
994
*
995
+ * @param string|bool $post_type The supported post type. Is boolean false if not supported.
996
* @param string $post_type_evaluated The evaluated post type.
997
*/
998
$post_type = (string) \apply_filters( 'the_seo_framework_supported_post_type', $post_type, $post_type_evaluated );
inc/classes/doing-it-right.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -207,7 +207,7 @@ class Doing_It_Right extends Generate_Ldjson {
207
208
if ( $id ) {
209
//* Everything but inline-save-tax action.
210
- \add_filter( 'manage_' . $id . '_columns', array( $this, 'add_column' ), 1 );
211
212
/**
213
* Always load pages and posts.
@@ -217,11 +217,11 @@ class Doing_It_Right extends Generate_Ldjson {
217
\add_action( 'manage_pages_custom_column', array( $this, 'seo_bar_ajax' ), 1, 3 );
218
} elseif ( $taxonomy ) {
219
//* Action: inline-save-tax does not POST screen.
220
- \add_filter( 'manage_edit-' . $taxonomy . '_columns', array( $this, 'add_column' ), 1 );
221
}
222
223
if ( $taxonomy )
224
- \add_action( 'manage_' . $taxonomy . '_custom_column', array( $this, 'seo_bar_ajax' ), 1, 3 );
225
226
} else {
227
$id = isset( $screen->id ) ? $screen->id : '';
@@ -232,7 +232,7 @@ class Doing_It_Right extends Generate_Ldjson {
232
$taxonomy = isset( $screen->taxonomy ) ? $screen->taxonomy : '';
233
234
if ( $taxonomy )
235
- \add_action( 'manage_' . $taxonomy . '_custom_column', array( $this, 'seo_bar' ), 1, 3 );
236
237
/**
238
* Always load pages and posts.
@@ -306,7 +306,7 @@ class Doing_It_Right extends Generate_Ldjson {
306
}
307
308
/**
309
- * Echo's the SEO Bar.
310
*
311
* @since 2.6.0
312
* @staticvar string $type
@@ -316,6 +316,34 @@ class Doing_It_Right extends Generate_Ldjson {
316
* @param string $tax_id this is empty : If it's a taxonomy, this is the taxonomy id
317
*/
318
public function seo_bar( $column, $post_id, $tax_id = '' ) {
319
320
static $type = null;
321
@@ -340,12 +368,13 @@ class Doing_It_Right extends Generate_Ldjson {
340
}
341
342
if ( 'tsf-seo-bar-wrap' === $column )
343
- $this->post_status( $post_id, $type, true );
344
345
}
346
347
/**
348
- * Echo's the SEO column in edit screens on Ajax call.
349
*
350
* @since 2.1.9
351
*
@@ -354,6 +383,33 @@ class Doing_It_Right extends Generate_Ldjson {
354
* @param string $tax_id this is empty : If it's a taxonomy, this is the taxonomy id
355
*/
356
public function seo_bar_ajax( $column, $post_id, $tax_id = '' ) {
357
358
$is_term = false;
359
@@ -372,8 +428,10 @@ class Doing_It_Right extends Generate_Ldjson {
372
373
$ajax_id = $column . $post_id;
374
375
- $this->post_status_special( $context, '?', 'unknown', $is_term, $ajax_id, true );
376
}
377
}
378
379
/**
@@ -981,6 +1039,8 @@ class Doing_It_Right extends Generate_Ldjson {
981
* Description Length notices.
982
*
983
* @since 2.6.0
984
*
985
* @param int $desc_len The Title length
986
* @param string $class The current color class.
@@ -1006,12 +1066,12 @@ class Doing_It_Right extends Generate_Ldjson {
1006
1007
// Don't make it okay if it's already bad.
1008
$class = $bad === $class ? $class : $okay;
1009
- } elseif ( $desc_len > 155 && $desc_len < 175 ) {
1010
$notice = $i18n['length_too_long'];
1011
1012
// Don't make it okay if it's already bad.
1013
$class = $bad === $class ? $class : $okay;
1014
- } elseif ( $desc_len >= 175 ) {
1015
$notice = $i18n['length_far_too_long'];
1016
$class = $bad;
1017
} else {
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
207
208
if ( $id ) {
209
//* Everything but inline-save-tax action.
210
+ \add_filter( 'manage_' . $id . '_columns', array( $this, 'add_column' ), 10, 1 );
211
212
/**
213
* Always load pages and posts.
217
\add_action( 'manage_pages_custom_column', array( $this, 'seo_bar_ajax' ), 1, 3 );
218
} elseif ( $taxonomy ) {
219
//* Action: inline-save-tax does not POST screen.
220
+ \add_filter( 'manage_edit-' . $taxonomy . '_columns', array( $this, 'add_column' ), 1, 1 );
221
}
222
223
if ( $taxonomy )
224
+ \add_filter( 'manage_' . $taxonomy . '_custom_column', array( $this, 'get_taxonomy_seo_bar_ajax' ), 1, 3 );
225
226
} else {
227
$id = isset( $screen->id ) ? $screen->id : '';
232
$taxonomy = isset( $screen->taxonomy ) ? $screen->taxonomy : '';
233
234
if ( $taxonomy )
235
+ \add_filter( 'manage_' . $taxonomy . '_custom_column', array( $this, 'get_taxonomy_seo_bar' ), 1, 3 );
236
237
/**
238
* Always load pages and posts.
306
}
307
308
/**
309
+ * Echos the SEO Bar.
310
*
311
* @since 2.6.0
312
* @staticvar string $type
316
* @param string $tax_id this is empty : If it's a taxonomy, this is the taxonomy id
317
*/
318
public function seo_bar( $column, $post_id, $tax_id = '' ) {
319
+ echo $this->get_seo_bar( $column, $post_id, $tax_id );
320
+ }
321
+
322
+ /**
323
+ * Returns the SEO Bar for taxonomies.
324
+ *
325
+ * @since 3.0.4
326
+ * @staticvar string $type
327
+ *
328
+ * @param string $string The current column string.
329
+ * @param string $column_name Name of the column.
330
+ * @param string $term_id Term ID.
331
+ */
332
+ public function get_taxonomy_seo_bar( $string, $column_name, $term_id ) {
333
+ return $string . $this->get_seo_bar( '', $column_name, $term_id );
334
+ }
335
+
336
+ /**
337
+ * Returns the SEO Bar.
338
+ *
339
+ * @since 3.0.4
340
+ * @staticvar string $type
341
+ *
342
+ * @param string $column the current column : If it's a taxonomy, this is empty
343
+ * @param int $post_id the post id : If it's a taxonomy, this is the column name
344
+ * @param string $tax_id this is empty : If it's a taxonomy, this is the taxonomy id
345
+ */
346
+ public function get_seo_bar( $column, $post_id, $tax_id = '' ) {
347
348
static $type = null;
349
368
}
369
370
if ( 'tsf-seo-bar-wrap' === $column )
371
+ return $this->post_status( $post_id, $type );
372
373
+ return '';
374
}
375
376
/**
377
+ * Echos the SEO column in edit screens on AJAX.
378
*
379
* @since 2.1.9
380
*
383
* @param string $tax_id this is empty : If it's a taxonomy, this is the taxonomy id
384
*/
385
public function seo_bar_ajax( $column, $post_id, $tax_id = '' ) {
386
+ echo $this->get_seo_bar_ajax( $column, $post_id, $tax_id );
387
+ }
388
+
389
+ /**
390
+ * Returns the SEO Bar for taxonomies on AJAX.
391
+ *
392
+ * @since 3.0.4
393
+ * @staticvar string $type
394
+ *
395
+ * @param string $string The current column string.
396
+ * @param string $column_name Name of the column.
397
+ * @param string $term_id Term ID.
398
+ */
399
+ public function get_taxonomy_seo_bar_ajax( $string, $column_name, $term_id ) {
400
+ return $string . $this->get_seo_bar_ajax( '', $column_name, $term_id );
401
+ }
402
+
403
+ /**
404
+ * Returns the SEO column in edit screens on AJAX.
405
+ *
406
+ * @since 3.0.4
407
+ *
408
+ * @param string $column the current column : If it's a taxonomy, this is empty
409
+ * @param int $post_id the post id : If it's a taxonomy, this is the column name
410
+ * @param string $tax_id this is empty : If it's a taxonomy, this is the taxonomy id
411
+ */
412
+ public function get_seo_bar_ajax( $column, $post_id, $tax_id = '' ) {
413
414
$is_term = false;
415
428
429
$ajax_id = $column . $post_id;
430
431
+ return $this->post_status_special( $context, '?', 'unknown', $is_term, $ajax_id );
432
}
433
+
434
+ return '';
435
}
436
437
/**
1039
* Description Length notices.
1040
*
1041
* @since 2.6.0
1042
+ * @since 3.0.4 : 1. Threshold "too long" has been increased from 155 to 300.
1043
+ * 2. Threshold "far too long" has been increased to 330 from 175.
1044
*
1045
* @param int $desc_len The Title length
1046
* @param string $class The current color class.
1066
1067
// Don't make it okay if it's already bad.
1068
$class = $bad === $class ? $class : $okay;
1069
+ } elseif ( $desc_len > 300 && $desc_len < 330 ) {
1070
$notice = $i18n['length_too_long'];
1071
1072
// Don't make it okay if it's already bad.
1073
$class = $bad === $class ? $class : $okay;
1074
+ } elseif ( $desc_len >= 330 ) {
1075
$notice = $i18n['length_far_too_long'];
1076
$class = $bad;
1077
} else {
inc/classes/feed.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
inc/classes/generate-description.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -39,6 +39,87 @@ class Generate_Description extends Generate {
39
parent::__construct();
40
}
41
42
/**
43
* Creates description. Base function.
44
*
@@ -107,7 +188,10 @@ class Generate_Description extends Generate {
107
if ( \apply_filters( 'the_seo_framework_do_shortcodes_in_description', false ) )
108
$description = \do_shortcode( $description );
109
110
- return $this->escape_description( $description );
111
}
112
113
/**
@@ -130,6 +214,7 @@ class Generate_Description extends Generate {
130
'is_home' => false,
131
'get_custom_field' => true,
132
'social' => false,
133
);
134
135
/**
@@ -139,9 +224,11 @@ class Generate_Description extends Generate {
139
* @param bool $is_home We're generating for the home page.
140
* @param bool $get_custom_field Do not fetch custom title when false.
141
* @param bool $social Generate Social Description when true.
142
* }
143
*
144
* @since 2.5.0
145
*
146
* @param array $defaults The description defaults.
147
* @param array $args The input args.
@@ -159,6 +246,7 @@ class Generate_Description extends Generate {
159
$args['is_home'] = isset( $args['is_home'] ) ? (bool) $args['is_home'] : $defaults['is_home'];
160
$args['get_custom_field'] = isset( $args['get_custom_field'] ) ? (bool) $args['get_custom_field'] : $defaults['get_custom_field'];
161
$args['social'] = isset( $args['social'] ) ? (bool) $args['social'] : $defaults['social'];
162
163
return $args;
164
}
@@ -473,6 +561,7 @@ class Generate_Description extends Generate {
473
* Returns the generated description excerpt array for the normal description tag.
474
*
475
* @since 2.8.0
476
*
477
* @param int $id The post/term ID.
478
* @param bool|object The term object.
@@ -506,12 +595,13 @@ class Generate_Description extends Generate {
506
* Determine if the title is far too long (72+, rather than 75 in the Title guidelines).
507
* If this is the case, trim the "title on blogname" part from the description.
508
* @since 2.8.0
509
*/
510
if ( $additions_length > 71 ) {
511
- $max_char_length = 155;
512
$trim = true;
513
} else {
514
- $max_char_length = 155 - $additions_length;
515
$trim = false;
516
}
517
@@ -761,7 +851,7 @@ class Generate_Description extends Generate {
761
$id = $this->get_the_real_ID();
762
763
if ( $page_on_front || $this->is_front_page_by_id( $id ) ) :
764
- $title = $this->get_option( 'homepage_title_tagline' ) ?: $this->get_blogdescription();
765
else :
766
/**
767
* No need to parse these when generating social description.
@@ -815,6 +905,7 @@ class Generate_Description extends Generate {
815
*
816
* @since 2.3.4
817
* @since 2.8.2 Now no longer escapes excerpt by accident in processing, preventing "too short" output.
818
* @staticvar array $excerpt_cache Holds the excerpt
819
* @staticvar array $excerptlength_cache Holds the excerpt length
820
*
@@ -823,7 +914,7 @@ class Generate_Description extends Generate {
823
* @param int $max_char_length The maximum excerpt char length.
824
* @return string $excerpt The excerpt, not escaped.
825
*/
826
- public function generate_excerpt( $page_id, $term = '', $max_char_length = 155 ) {
827
828
static $excerpt_cache = array();
829
static $excerptlength_cache = array();
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
39
parent::__construct();
40
}
41
42
+ /**
43
+ * Returns the Twitter meta description. Falls back to Open Graph description.
44
+ *
45
+ * @since 3.0.4
46
+ * @uses $this->get_open_graph_description()
47
+ *
48
+ * @param int|null $id The post or term ID. Falls back to queried ID.
49
+ * @param bool $escape Whether to escape the description.
50
+ * @return string Twitter Description.
51
+ */
52
+ public function get_twitter_description( $id = null, $escape = true ) {
53
+
54
+ if ( is_null( $id ) )
55
+ $id = $this->get_the_real_ID();
56
+
57
+ $desc = $this->get_custom_field( '_twitter_description', $id )
58
+ ?: $this->get_open_graph_description( $id, false );
59
+
60
+ return $escape ? $this->escape_description( $desc ) : $desc;
61
+ }
62
+
63
+ /**
64
+ * Returns the Open Graph meta description. Falls back to meta description.
65
+ *
66
+ * @since 3.0.4
67
+ * @uses $this->get_generated_open_graph_description()
68
+ *
69
+ * @param int|null $id The post or term ID. Falls back to queried ID.
70
+ * @param bool $escape Whether to escape the description.
71
+ * @return string Open Graph Description.
72
+ */
73
+ public function get_open_graph_description( $id = null, $escape = true ) {
74
+
75
+ if ( is_null( $id ) )
76
+ $id = $this->get_the_real_ID();
77
+
78
+ $desc = $this->get_custom_field( '_open_graph_description', $id )
79
+ ?: $this->get_generated_open_graph_description( $id, false );
80
+
81
+ return $escape ? $this->escape_description( $desc ) : $desc;
82
+ }
83
+
84
+ /**
85
+ * Returns the autogenerated open graph meta description. Falls back to meta description.
86
+ *
87
+ * @since 3.0.4
88
+ * @uses $this->get_generated_open_graph_description()
89
+ *
90
+ * @param int|null $id The post or term ID. Falls back to queried ID.
91
+ * @param bool $escape Whether to escape the description.
92
+ * @return string Autogenerated Twitter Description.
93
+ */
94
+ public function get_generated_twitter_description( $id = null, $escape = true ) {
95
+ return $this->get_generated_open_graph_description( $id, $escape );
96
+ }
97
+
98
+ /**
99
+ * Returns the autogenerated open graph meta description. Falls back to meta description.
100
+ *
101
+ * @since 3.0.4
102
+ * @uses $this->generate_description()
103
+ * @staticvar array $cache
104
+ *
105
+ * @param int|null $id The post or term ID. Falls back to queried ID.
106
+ * @param bool $escape Whether to escape the description.
107
+ * @return string Autogenerated Open Graph Description.
108
+ */
109
+ public function get_generated_open_graph_description( $id = null, $escape = true ) {
110
+
111
+ if ( is_null( $id ) )
112
+ $id = $this->get_the_real_ID();
113
+
114
+ static $cache = array();
115
+
116
+ $desc = isset( $cache[ $id ] )
117
+ ? $cache[ $id ]
118
+ : $cache[ $id ] = $this->generate_description( '', array( 'id' => $id, 'social' => true, 'escape' => false ) );
119
+
120
+ return $escape ? $this->escape_description( $desc ) : $desc;
121
+ }
122
+
123
/**
124
* Creates description. Base function.
125
*
188
if ( \apply_filters( 'the_seo_framework_do_shortcodes_in_description', false ) )
189
$description = \do_shortcode( $description );
190
191
+ if ( $args['escape'] )
192
+ $description = $this->escape_description( $description );
193
+
194
+ return $description;
195
}
196
197
/**
214
'is_home' => false,
215
'get_custom_field' => true,
216
'social' => false,
217
+ 'escape' => true,
218
);
219
220
/**
224
* @param bool $is_home We're generating for the home page.
225
* @param bool $get_custom_field Do not fetch custom title when false.
226
* @param bool $social Generate Social Description when true.
227
+ * @param bool $escape Whether to escape the description.
228
* }
229
*
230
* @since 2.5.0
231
+ * @since 3.0.4 Added escape parameter.
232
*
233
* @param array $defaults The description defaults.
234
* @param array $args The input args.
246
$args['is_home'] = isset( $args['is_home'] ) ? (bool) $args['is_home'] : $defaults['is_home'];
247
$args['get_custom_field'] = isset( $args['get_custom_field'] ) ? (bool) $args['get_custom_field'] : $defaults['get_custom_field'];
248
$args['social'] = isset( $args['social'] ) ? (bool) $args['social'] : $defaults['social'];
249
+ $args['escape'] = isset( $args['escape'] ) ? (bool) $args['escape'] : $defaults['escape'];
250
251
return $args;
252
}
561
* Returns the generated description excerpt array for the normal description tag.
562
*
563
* @since 2.8.0
564
+ * @since 3.0.4 Now uses 300 characters instead of 155.
565
*
566
* @param int $id The post/term ID.
567
* @param bool|object The term object.
595
* Determine if the title is far too long (72+, rather than 75 in the Title guidelines).
596
* If this is the case, trim the "title on blogname" part from the description.
597
* @since 2.8.0
598
+ * @since 3.0.4 Increased to basis 300, from 155.
599
*/
600
if ( $additions_length > 71 ) {
601
+ $max_char_length = 300;
602
$trim = true;
603
} else {
604
+ $max_char_length = 300 - $additions_length;
605
$trim = false;
606
}
607
851
$id = $this->get_the_real_ID();
852
853
if ( $page_on_front || $this->is_front_page_by_id( $id ) ) :
854
+ $title = $this->get_home_page_tagline();
855
else :
856
/**
857
* No need to parse these when generating social description.
905
*
906
* @since 2.3.4
907
* @since 2.8.2 Now no longer escapes excerpt by accident in processing, preventing "too short" output.
908
+ * @since 3.0.4 The default $max_char_length has been increased from 155 to 300.
909
* @staticvar array $excerpt_cache Holds the excerpt
910
* @staticvar array $excerptlength_cache Holds the excerpt length
911
*
914
* @param int $max_char_length The maximum excerpt char length.
915
* @return string $excerpt The excerpt, not escaped.
916
*/
917
+ public function generate_excerpt( $page_id, $term = '', $max_char_length = 300 ) {
918
919
static $excerpt_cache = array();
920
static $excerptlength_cache = array();
inc/classes/generate-image.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -118,6 +118,7 @@ class Generate_Image extends Generate_Url {
118
/**
119
* Applies filters 'the_seo_framework_ld_json_breadcrumb_image' : string
120
* @since 2.7.0
121
* @param string $image The current image.
122
* @param int $id The page, post, product or term ID.
123
* @param bool $singular Whether the ID is singular.
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
118
/**
119
* Applies filters 'the_seo_framework_ld_json_breadcrumb_image' : string
120
* @since 2.7.0
121
+ * TODO deprecate filter and exchange with a suiting name.
122
* @param string $image The current image.
123
* @param int $id The page, post, product or term ID.
124
* @param bool $singular Whether the ID is singular.
inc/classes/generate-ldjson.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -447,7 +447,7 @@ class Generate_Ldjson extends Generate_Image {
447
$taxonomies = $this->get_hierarchical_taxonomies_as( 'names', \get_post_type( $post_id ) );
448
449
/**
450
- * Applies filters 'the_seo_framework_ld_json_breadcrumb_terms'
451
*
452
* @since 3.0.0
453
* @param array|string $taxonomies The assigned hierarchical taxonomies.
@@ -471,7 +471,7 @@ class Generate_Ldjson extends Generate_Image {
471
* Applies filter 'the_seo_framework_ld_json_breadcrumb_terms' : array
472
* @since 2.8.0
473
*
474
- * @param array $terms The LD+JSON terms that are being used
475
* @param int $post_id The current Post ID.
476
* @param string $taxonomy The current taxonomy (either category or product_cat).
477
*/
@@ -865,6 +865,7 @@ class Generate_Ldjson extends Generate_Image {
865
/**
866
* Applies filters the_seo_framework_json_breadcrumb_output
867
* @since 2.4.2
868
*/
869
$filter = (bool) \apply_filters( 'the_seo_framework_json_breadcrumb_output', true );
870
$option = $this->is_option_checked( 'ld_json_breadcrumbs' );
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
447
$taxonomies = $this->get_hierarchical_taxonomies_as( 'names', \get_post_type( $post_id ) );
448
449
/**
450
+ * Applies filters 'the_seo_framework_ld_json_breadcrumb_taxonomies'
451
*
452
* @since 3.0.0
453
* @param array|string $taxonomies The assigned hierarchical taxonomies.
471
* Applies filter 'the_seo_framework_ld_json_breadcrumb_terms' : array
472
* @since 2.8.0
473
*
474
+ * @param array $terms The candidate terms.
475
* @param int $post_id The current Post ID.
476
* @param string $taxonomy The current taxonomy (either category or product_cat).
477
*/
865
/**
866
* Applies filters the_seo_framework_json_breadcrumb_output
867
* @since 2.4.2
868
+ * @param bool $output
869
*/
870
$filter = (bool) \apply_filters( 'the_seo_framework_json_breadcrumb_output', true );
871
$option = $this->is_option_checked( 'ld_json_breadcrumbs' );
inc/classes/generate-title.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -41,6 +41,87 @@ class Generate_Title extends Generate_Description {
41
parent::__construct();
42
}
43
44
/**
45
* Gets the title. Main function.
46
* Always use this function for the title unless you're absolutely sure what you're doing.
@@ -584,6 +665,7 @@ class Generate_Title extends Generate_Description {
584
* Generate the title based on conditions for the home page.
585
*
586
* @since 2.3.4
587
* @access private
588
*
589
* @param bool $get_custom_field Fetch Title from Custom Fields.
@@ -592,8 +674,8 @@ class Generate_Title extends Generate_Description {
592
* @param bool $escape Parse Title through saninitation calls.
593
* @param bool $get_option Whether to fetch the SEO Settings option.
594
* @return array {
595
- * 'title' => (string) $title : The Generated Title
596
- * 'blogname' => (string) $blogname : The Generated Blogname
597
* 'add_tagline' => (bool) $add_tagline : Whether to add the tagline
598
* 'seplocation' => (string) $seplocation : The Separator Location
599
* }
@@ -601,22 +683,7 @@ class Generate_Title extends Generate_Description {
601
public function generate_home_title( $get_custom_field = true, $seplocation = '', $deprecated = '', $escape = true, $get_option = true ) {
602
603
$add_tagline = $this->home_page_add_title_tagline();
604
-
605
- /**
606
- * Add tagline or not based on option
607
- *
608
- * @since 2.2.2
609
- */
610
- if ( $add_tagline ) {
611
- /**
612
- * Tagline based on option.
613
- * @since 2.3.8
614
- */
615
- $blogname = $this->get_option( 'homepage_title_tagline' );
616
- $blogname = $blogname ? $blogname : $this->get_blogdescription();
617
- } else {
618
- $blogname = '';
619
- }
620
621
/**
622
* Render from function
@@ -638,17 +705,17 @@ class Generate_Title extends Generate_Description {
638
);
639
640
/**
641
- * Applies filters 'the_seo_framework_home_title_args' : array {
642
- * @param string $title : NOTE: This is the blogname
643
- * @param string $blogname : NOTE: This is the tagline.
644
- * @param bool $add_tagline
645
- * @param string $seplocation : 'left' or 'right'
646
- * }
647
*
648
* @since 2.8.0
649
*
650
* @param array $args
651
- * @param array $defaults
652
*/
653
$args = (array) \apply_filters( 'the_seo_framework_home_title_args', array(), $defaults );
654
@@ -799,12 +866,15 @@ class Generate_Title extends Generate_Description {
799
/**
800
* Gets the archive Title, including filter. Also works in admin.
801
*
802
- * @NOTE Taken from WordPress core. Altered to work in the Admin area.
803
*
804
* @since 2.6.0
805
* @since 2.9.2 : Added WordPress core filter 'get_the_archive_title'
806
*
807
- * @param object $term The Term object.
808
* @param array $args The Title arguments.
809
* @return string The Archive Title, not escaped.
810
*/
@@ -904,11 +974,12 @@ class Generate_Title extends Generate_Description {
904
/**
905
* Filters the archive title.
906
*
907
- * @since WordPress Core 4.1.0
908
*
909
* @param string $title Archive title to be displayed.
910
*/
911
- return \apply_filters( 'get_the_archive_title', $title );
912
}
913
914
/**
@@ -932,7 +1003,7 @@ class Generate_Title extends Generate_Description {
932
/**
933
* Filter the category archive page title.
934
*
935
- * @since 2.0.10 WP CORE
936
*
937
* @param string $term_name Category name for archive being displayed.
938
*/
@@ -941,7 +1012,7 @@ class Generate_Title extends Generate_Description {
941
/**
942
* Filter the tag archive page title.
943
*
944
- * @since 2.3.0 WP CORE
945
*
946
* @param string $term_name Tag name for archive being displayed.
947
*/
@@ -950,7 +1021,7 @@ class Generate_Title extends Generate_Description {
950
/**
951
* Filter the custom taxonomy archive page title.
952
*
953
- * @since 3.1.0 WP CORE
954
*
955
* @param string $term_name Term name for archive being displayed.
956
*/
@@ -1376,14 +1447,27 @@ class Generate_Title extends Generate_Description {
1376
return $title;
1377
}
1378
1379
/**
1380
* Determines whether to add home page tagline.
1381
*
1382
* @since 2.6.0
1383
*
1384
* @return bool
1385
*/
1386
public function home_page_add_title_tagline() {
1387
- return $this->is_option_checked( 'homepage_tagline' );
1388
}
1389
}
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
41
parent::__construct();
42
}
43
44
+ /**
45
+ * Returns the Twitter meta title. Falls back to Open Graph title.
46
+ *
47
+ * @since 3.0.4
48
+ * @uses $this->get_open_graph_title()
49
+ *
50
+ * @param int|null $id The post or term ID. Falls back to queried ID.
51
+ * @param bool $escape Whether to escape the title.
52
+ * @return string Twitter Title.
53
+ */
54
+ public function get_twitter_title( $id = null, $escape = true ) {
55
+
56
+ if ( is_null( $id ) )
57
+ $id = $this->get_the_real_ID();
58
+
59
+ $title = $this->get_custom_field( '_twitter_title', $id )
60
+ ?: $this->get_open_graph_title( $id, false );
61
+
62
+ return $escape ? $this->escape_title( $title ) : $title;
63
+ }
64
+
65
+ /**
66
+ * Returns the Open Graph meta title. Falls back to meta title.
67
+ *
68
+ * @since 3.0.4
69
+ * @uses $this->get_generated_open_graph_title()
70
+ *
71
+ * @param int|null $id The post or term ID. Falls back to queried ID.
72
+ * @param bool $escape Whether to escape the title.
73
+ * @return string Open Graph Title.
74
+ */
75
+ public function get_open_graph_title( $id = null, $escape = true ) {
76
+
77
+ if ( is_null( $id ) )
78
+ $id = $this->get_the_real_ID();
79
+
80
+ $title = $this->get_custom_field( '_open_graph_title', $id )
81
+ ?: $this->get_generated_open_graph_title( $id, false );
82
+
83
+ return $escape ? $this->escape_title( $title ) : $title;
84
+ }
85
+
86
+ /**
87
+ * Returns the autogenerated open graph meta title. Falls back to meta title.
88
+ *
89
+ * @since 3.0.4
90
+ * @uses $this->get_generated_open_graph_title()
91
+ *
92
+ * @param int|null $id The post or term ID. Falls back to queried ID.
93
+ * @param bool $escape Whether to escape the title.
94
+ * @return string Autogenerated Twitter Title.
95
+ */
96
+ public function get_generated_twitter_title( $id = null, $escape = true ) {
97
+ return $this->get_generated_open_graph_title( $id, $escape );
98
+ }
99
+
100
+ /**
101
+ * Returns the autogenerated open graph meta title. Falls back to meta title.
102
+ *
103
+ * @since 3.0.4
104
+ * @uses $this->build_title()
105
+ * @staticvar array $cache
106
+ *
107
+ * @param int|null $id The post or term ID. Falls back to queried ID.
108
+ * @param bool $escape Whether to escape the title.
109
+ * @return string Autogenerated Open Graph Title.
110
+ */
111
+ public function get_generated_open_graph_title( $id = null, $escape = true ) {
112
+
113
+ if ( is_null( $id ) )
114
+ $id = $this->get_the_real_ID();
115
+
116
+ static $cache = array();
117
+
118
+ $title = isset( $cache[ $id ] )
119
+ ? $cache[ $id ]
120
+ : $cache[ $id ] = $this->build_title( '', '', array( 'meta' => true, 'term_id' => $id, 'escape' => false ) );
121
+
122
+ return $escape ? $this->escape_title( $title ) : $title;
123
+ }
124
+
125
/**
126
* Gets the title. Main function.
127
* Always use this function for the title unless you're absolutely sure what you're doing.
665
* Generate the title based on conditions for the home page.
666
*
667
* @since 2.3.4
668
+ * @since 2.3.8 Now checks tagline option.
669
* @access private
670
*
671
* @param bool $get_custom_field Fetch Title from Custom Fields.
674
* @param bool $escape Parse Title through saninitation calls.
675
* @param bool $get_option Whether to fetch the SEO Settings option.
676
* @return array {
677
+ * 'title' => (string) $title : The Generated "Title"
678
+ * 'blogname' => (string) $blogname : The Generated "Blogname"
679
* 'add_tagline' => (bool) $add_tagline : Whether to add the tagline
680
* 'seplocation' => (string) $seplocation : The Separator Location
681
* }
683
public function generate_home_title( $get_custom_field = true, $seplocation = '', $deprecated = '', $escape = true, $get_option = true ) {
684
685
$add_tagline = $this->home_page_add_title_tagline();
686
+ $blogname = $add_tagline ? $this->get_home_page_tagline() : '';
687
688
/**
689
* Render from function
705
);
706
707
/**
708
+ * Applies filters 'the_seo_framework_home_title_args'
709
*
710
* @since 2.8.0
711
*
712
* @param array $args
713
+ * @param array $defaults : {
714
+ * string $title : NOTE: This is the blogname or homepage title option.
715
+ * string $blogname : NOTE: This is the tagline.
716
+ * bool $add_tagline
717
+ * string $seplocation : 'left' or 'right'
718
+ * }
719
*/
720
$args = (array) \apply_filters( 'the_seo_framework_home_title_args', array(), $defaults );
721
866
/**
867
* Gets the archive Title, including filter. Also works in admin.
868
*
869
+ * @NOTE Taken from WordPress core. Altered to work for metadata.
870
+ * @see WP Core get_the_archive_title()
871
*
872
* @since 2.6.0
873
* @since 2.9.2 : Added WordPress core filter 'get_the_archive_title'
874
+ * @since 3.0.4 : 1. Removed WordPress core filter 'get_the_archive_title'
875
+ * 2. Added filter 'the_seo_framework_generated_archive_title'
876
*
877
+ * @param \WP_Term|null $term The Term object.
878
* @param array $args The Title arguments.
879
* @return string The Archive Title, not escaped.
880
*/
974
/**
975
* Filters the archive title.
976
*
977
+ * @since 3.0.4
978
*
979
* @param string $title Archive title to be displayed.
980
+ * @param \WP_Term $term The term object.
981
*/
982
+ return \apply_filters( 'the_seo_framework_generated_archive_title', $title, $term );
983
}
984
985
/**
1003
/**
1004
* Filter the category archive page title.
1005
*
1006
+ * @since WP Core 2.0.10
1007
*
1008
* @param string $term_name Category name for archive being displayed.
1009
*/
1012
/**
1013
* Filter the tag archive page title.
1014
*
1015
+ * @since WP Core 2.3.0
1016
*
1017
* @param string $term_name Tag name for archive being displayed.
1018
*/
1021
/**
1022
* Filter the custom taxonomy archive page title.
1023
*
1024
+ * @since WP Core 3.1.0
1025
*
1026
* @param string $term_name Term name for archive being displayed.
1027
*/
1447
return $title;
1448
}
1449
1450
+ /**
1451
+ * Returns the home page tagline from option or bloginfo, when set.
1452
+ *
1453
+ * @since 3.0.4
1454
+ * @uses $this->get_blogdescription(), this method already trims.
1455
+ *
1456
+ * @return string The trimmed tagline.
1457
+ */
1458
+ public function get_home_page_tagline() {
1459
+ return trim( $this->get_option( 'homepage_title_tagline' ) ) ?: $this->get_blogdescription() ?: '';
1460
+ }
1461
+
1462
/**
1463
* Determines whether to add home page tagline.
1464
*
1465
* @since 2.6.0
1466
+ * @since 3.0.4 Now checks for custom tagline or blogname existence.
1467
*
1468
* @return bool
1469
*/
1470
public function home_page_add_title_tagline() {
1471
+ return $this->is_option_checked( 'homepage_tagline' ) && $this->get_home_page_tagline();
1472
}
1473
}
inc/classes/generate-url.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -374,14 +374,12 @@ class Generate_Url extends Generate_Title {
374
case 'day' :
375
$_day = \get_query_var( 'day' );
376
$_paginate = $_paginate && $_day == $day;
377
- $_get = 'month';
378
- // Continue switch.
379
380
case 'month' :
381
$_month = \get_query_var( 'monthnum' );
382
$_paginate = $_paginate && $_month == $month;
383
- $_get = 'year';
384
- // Continue switch.
385
386
case 'year' :
387
$_year = \get_query_var( 'year' );
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
374
case 'day' :
375
$_day = \get_query_var( 'day' );
376
$_paginate = $_paginate && $_day == $day;
377
+ // No break. Get month too.
378
379
case 'month' :
380
$_month = \get_query_var( 'monthnum' );
381
$_paginate = $_paginate && $_month == $month;
382
+ // No break. Get year too.
383
384
case 'year' :
385
$_year = \get_query_var( 'year' );
inc/classes/generate.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
inc/classes/init.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -79,6 +79,9 @@ class Init extends Query {
79
/**
80
* Runs the plugin on the front-end.
81
*
82
* @since 1.0.0
83
* @since 2.8.0 Silently deprecated. Displaying legacy roots.
84
* @deprecated
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
79
/**
80
* Runs the plugin on the front-end.
81
*
82
+ * To overwrite any of the filters, use (n>0):
83
+ * `add_action( 'init', callback, n );`
84
+ *
85
* @since 1.0.0
86
* @since 2.8.0 Silently deprecated. Displaying legacy roots.
87
* @deprecated
inc/classes/inpost.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -281,7 +281,7 @@ class Inpost extends Profile {
281
$is_term = false;
282
283
// Args are passed.
284
- if ( is_array( $args ) && isset( $args['args'] ) ) {
285
$args_split = $args['args'];
286
287
//* The post type callback arg (translated)
@@ -418,7 +418,9 @@ class Inpost extends Profile {
418
* Do not use. It will take a little too much time to perfect this.
419
*
420
* @since 2.9.0
421
* @access private
422
* @ignore
423
* @todo Remove and refactor caller.
424
*
@@ -426,9 +428,20 @@ class Inpost extends Profile {
426
* @param string $doctitle_placeholder. Passed by reference.
427
* @param string $desc_len_parsed. Passed by reference.
428
* @param string $description_placeholder. Passed by reference.
429
*/
430
public function _get_inpost_general_tab_vars( &$tit_len_parsed, &$doctitle_placeholder, &$desc_len_parsed, &$description_placeholder ) {
431
432
$post_id = $this->get_the_real_ID();
433
$is_static_frontpage = $this->is_static_frontpage( $post_id );
434
@@ -473,7 +486,7 @@ class Inpost extends Profile {
473
);
474
}
475
$generated_doctitle = $this->title( '', '', '', $generated_doctitle_args );
476
- $generated_description = $this->generate_description_from_id( $generated_description_args );
477
478
/**
479
* Start Title vars
@@ -551,5 +564,7 @@ class Inpost extends Profile {
551
*/
552
$doctitle_placeholder = $generated_doctitle;
553
$description_placeholder = $generated_description;
554
}
555
}
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
281
$is_term = false;
282
283
// Args are passed.
284
+ if ( isset( $args['args'] ) ) {
285
$args_split = $args['args'];
286
287
//* The post type callback arg (translated)
418
* Do not use. It will take a little too much time to perfect this.
419
*
420
* @since 2.9.0
421
+ * @since 3.0.4 Added caching.
422
* @access private
423
+ * @staticvar $cache
424
* @ignore
425
* @todo Remove and refactor caller.
426
*
428
* @param string $doctitle_placeholder. Passed by reference.
429
* @param string $desc_len_parsed. Passed by reference.
430
* @param string $description_placeholder. Passed by reference.
431
+ * @return void
432
*/
433
public function _get_inpost_general_tab_vars( &$tit_len_parsed, &$doctitle_placeholder, &$desc_len_parsed, &$description_placeholder ) {
434
435
+ static $cache = array();
436
+
437
+ if ( ! empty( $cache ) ) {
438
+ //! Overwrites variables passed by reference via variable variables.
439
+ foreach ( $cache as $k => $v ) {
440
+ $k = $v;
441
+ }
442
+ return;
443
+ }
444
+
445
$post_id = $this->get_the_real_ID();
446
$is_static_frontpage = $this->is_static_frontpage( $post_id );
447
486
);
487
}
488
$generated_doctitle = $this->title( '', '', '', $generated_doctitle_args );
489
+ $generated_description = $this->generate_description( '', $generated_description_args );
490
491
/**
492
* Start Title vars
564
*/
565
$doctitle_placeholder = $generated_doctitle;
566
$description_placeholder = $generated_description;
567
+
568
+ $cache = compact( 'tit_len_parsed', 'doctitle_placeholder', 'desc_len_parsed', 'description_placeholder' );
569
}
570
}
inc/classes/load.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
inc/classes/metaboxes.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -48,13 +48,13 @@ class Metaboxes extends Site_Options {
48
*
49
* @param string $id The Nav Tab ID
50
* @param array $tabs the tab content {
51
- * $tabs = tab ID key = array(
52
- * $tabs['name'] => tab name
53
- * $tabs['callback'] => string|array callback function
54
- * $tabs['dashicon'] => string Dashicon
55
- * $tabs['args'] => mixed optional callback function args
56
- * )
57
- * }
58
* @param string $version the The SEO Framework version for debugging. May be emptied.
59
* @param bool $use_tabs Whether to output tabs, only works when $tabs is greater than 1.
60
*/
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
48
*
49
* @param string $id The Nav Tab ID
50
* @param array $tabs the tab content {
51
+ * $tabs = tab ID key = array(
52
+ * $tabs['name'] => tab name
53
+ * $tabs['callback'] => string|array callback function
54
+ * $tabs['dashicon'] => string Dashicon
55
+ * $tabs['args'] => mixed optional callback function args
56
+ * )
57
+ * }
58
* @param string $version the The SEO Framework version for debugging. May be emptied.
59
* @param bool $use_tabs Whether to output tabs, only works when $tabs is greater than 1.
60
*/
inc/classes/post-data.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -98,17 +98,21 @@ class Post_Data extends Detect {
98
return;
99
100
$defaults = array(
101
- '_genesis_title' => '',
102
- '_genesis_description' => '',
103
- '_genesis_canonical_uri' => '',
104
- 'redirect' => '', // Will be displayed in custom fields when set...
105
- '_social_image_url' => '',
106
- '_social_image_id' => 0,
107
- '_genesis_noindex' => 0,
108
- '_genesis_nofollow' => 0,
109
- '_genesis_noarchive' => 0,
110
- 'exclude_local_search' => 0, // Will be displayed in custom fields when set...
111
- 'exclude_from_archive' => 0, // Will be displayed in custom fields when set...
112
);
113
114
/**
@@ -120,10 +124,14 @@ class Post_Data extends Detect {
120
foreach ( (array) $data as $key => $value ) :
121
switch ( $key ) :
122
case '_genesis_title' :
123
$data[ $key ] = $this->s_title_raw( $value );
124
continue 2;
125
126
case '_genesis_description' :
127
$data[ $key ] = $this->s_description_raw( $value );
128
continue 2;
129
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
98
return;
99
100
$defaults = array(
101
+ '_genesis_title' => '',
102
+ '_genesis_description' => '',
103
+ '_genesis_canonical_uri' => '',
104
+ 'redirect' => '', // Will be displayed in custom fields when set...
105
+ '_social_image_url' => '',
106
+ '_social_image_id' => 0,
107
+ '_genesis_noindex' => 0,
108
+ '_genesis_nofollow' => 0,
109
+ '_genesis_noarchive' => 0,
110
+ 'exclude_local_search' => 0, // Will be displayed in custom fields when set...
111
+ 'exclude_from_archive' => 0, // Will be displayed in custom fields when set...
112
+ '_open_graph_title' => '',
113
+ '_open_graph_description' => '',
114
+ '_twitter_title' => '',
115
+ '_twitter_description' => '',
116
);
117
118
/**
124
foreach ( (array) $data as $key => $value ) :
125
switch ( $key ) :
126
case '_genesis_title' :
127
+ case '_open_graph_title' :
128
+ case '_twitter_title' :
129
$data[ $key ] = $this->s_title_raw( $value );
130
continue 2;
131
132
case '_genesis_description' :
133
+ case '_open_graph_description' :
134
+ case '_twitter_description' :
135
$data[ $key ] = $this->s_description_raw( $value );
136
continue 2;
137
inc/classes/profile.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
inc/classes/query.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
inc/classes/render.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -230,7 +230,8 @@ class Render extends Admin_Init {
230
* Renders og:description meta tag
231
*
232
* @since 1.3.0
233
- * @uses $this->description_from_cache()
234
*
235
* @return string The Open Graph description meta tag.
236
*/
@@ -244,7 +245,7 @@ class Render extends Admin_Init {
244
* @since 2.3.0
245
* @since 2.7.0 Added output within filter.
246
*/
247
- $description = (string) \apply_filters( 'the_seo_framework_ogdescription_output', $this->description_from_cache( true ), $this->get_the_real_ID() );
248
249
if ( $description )
250
return '<meta property="og:description" content="' . \esc_attr( $description ) . '" />' . "\r\n";
@@ -280,8 +281,9 @@ class Render extends Admin_Init {
280
/**
281
* Renders the Open Graph title meta tag.
282
*
283
- * @uses $this->title_from_cache()
284
* @since 2.0.3
285
*
286
* @return string The Open Graph title meta tag.
287
*/
@@ -295,7 +297,7 @@ class Render extends Admin_Init {
295
* @since 2.3.0
296
* @since 2.7.0 Added output within filter.
297
*/
298
- $title = (string) \apply_filters( 'the_seo_framework_ogtitle_output', $this->title_from_cache( '', '', '', true ), $this->get_the_real_ID() );
299
300
if ( $title )
301
return '<meta property="og:title" content="' . \esc_attr( $title ) . '" />' . "\r\n";
@@ -567,8 +569,9 @@ class Render extends Admin_Init {
567
/**
568
* Renders Twitter Title meta tag.
569
*
570
- * @uses $this->title_from_cache()
571
* @since 2.2.2
572
*
573
* @return string The Twitter Title meta tag.
574
*/
@@ -582,7 +585,7 @@ class Render extends Admin_Init {
582
* @since 2.3.0
583
* @since 2.7.0 Added output within filter.
584
*/
585
- $title = (string) \apply_filters( 'the_seo_framework_twittertitle_output', $this->title_from_cache( '', '', '', true ), $this->get_the_real_ID() );
586
587
if ( $title )
588
return '<meta name="twitter:title" content="' . \esc_attr( $title ) . '" />' . "\r\n";
@@ -593,8 +596,9 @@ class Render extends Admin_Init {
593
/**
594
* Renders Twitter Description meta tag.
595
*
596
- * @uses $this->description_from_cache()
597
* @since 2.2.2
598
*
599
* @return string The Twitter Descritpion meta tag.
600
*/
@@ -608,7 +612,7 @@ class Render extends Admin_Init {
608
* @since 2.3.0
609
* @since 2.7.0 Added output within filter.
610
*/
611
- $description = (string) \apply_filters( 'the_seo_framework_twitterdescription_output', $this->description_from_cache( true ), $this->get_the_real_ID() );
612
613
if ( $description )
614
return '<meta name="twitter:description" content="' . \esc_attr( $description ) . '" />' . "\r\n";
@@ -1159,7 +1163,7 @@ class Render extends Admin_Init {
1159
}
1160
1161
/**
1162
- * Determines whether we can use Open Graph tags.
1163
*
1164
* @since 2.6.0
1165
* @staticvar bool $cache
@@ -1177,7 +1181,7 @@ class Render extends Admin_Init {
1177
}
1178
1179
/**
1180
- * Determines whether we can use Facebook tags.
1181
*
1182
* @since 2.6.0
1183
* @staticvar bool $cache
@@ -1195,7 +1199,7 @@ class Render extends Admin_Init {
1195
}
1196
1197
/**
1198
- * Determines whether we can use Twitter tags.
1199
*
1200
* @since 2.6.0
1201
* @since 2.8.2 : Now also considers Twitter card type output.
@@ -1214,7 +1218,7 @@ class Render extends Admin_Init {
1214
}
1215
1216
/**
1217
- * Determines whether we can use Google+ tags.
1218
*
1219
* @since 2.6.0
1220
* @staticvar bool $cache
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
230
* Renders og:description meta tag
231
*
232
* @since 1.3.0
233
+ * @since 3.0.4 No longer uses $this->description_from_cache()
234
+ * @uses $this->get_open_graph_title()
235
*
236
* @return string The Open Graph description meta tag.
237
*/
245
* @since 2.3.0
246
* @since 2.7.0 Added output within filter.
247
*/
248
+ $description = (string) \apply_filters( 'the_seo_framework_ogdescription_output', $this->get_open_graph_description(), $this->get_the_real_ID() );
249
250
if ( $description )
251
return '<meta property="og:description" content="' . \esc_attr( $description ) . '" />' . "\r\n";
281
/**
282
* Renders the Open Graph title meta tag.
283
*
284
* @since 2.0.3
285
+ * @since 3.0.4 No longer uses $this->title_from_cache()
286
+ * @uses $this->get_open_graph_title()
287
*
288
* @return string The Open Graph title meta tag.
289
*/
297
* @since 2.3.0
298
* @since 2.7.0 Added output within filter.
299
*/
300
+ $title = (string) \apply_filters( 'the_seo_framework_ogtitle_output', $this->get_open_graph_title(), $this->get_the_real_ID() );
301
302
if ( $title )
303
return '<meta property="og:title" content="' . \esc_attr( $title ) . '" />' . "\r\n";
569
/**
570
* Renders Twitter Title meta tag.
571
*
572
+ * @uses $this->get_twitter_title()
573
* @since 2.2.2
574
+ * @since 3.0.4 No longer uses $this->title_from_cache()
575
*
576
* @return string The Twitter Title meta tag.
577
*/
585
* @since 2.3.0
586
* @since 2.7.0 Added output within filter.
587
*/
588
+ $title = (string) \apply_filters( 'the_seo_framework_twittertitle_output', $this->get_twitter_title(), $this->get_the_real_ID() );
589
590
if ( $title )
591
return '<meta name="twitter:title" content="' . \esc_attr( $title ) . '" />' . "\r\n";
596
/**
597
* Renders Twitter Description meta tag.
598
*
599
* @since 2.2.2
600
+ * @since 3.0.4 No longer uses $this->description_from_cache()
601
+ * @uses $this->get_twitter_description()
602
*
603
* @return string The Twitter Descritpion meta tag.
604
*/
612
* @since 2.3.0
613
* @since 2.7.0 Added output within filter.
614
*/
615
+ $description = (string) \apply_filters( 'the_seo_framework_twitterdescription_output', $this->get_twitter_description(), $this->get_the_real_ID() );
616
617
if ( $description )
618
return '<meta name="twitter:description" content="' . \esc_attr( $description ) . '" />' . "\r\n";
1163
}
1164
1165
/**
1166
+ * Determines whether we can use Open Graph tags on the front-end.
1167
*
1168
* @since 2.6.0
1169
* @staticvar bool $cache
1181
}
1182
1183
/**
1184
+ * Determines whether we can use Facebook tags on the front-end.
1185
*
1186
* @since 2.6.0
1187
* @staticvar bool $cache
1199
}
1200
1201
/**
1202
+ * Determines whether we can use Twitter tags on the front-end.
1203
*
1204
* @since 2.6.0
1205
* @since 2.8.2 : Now also considers Twitter card type output.
1218
}
1219
1220
/**
1221
+ * Determines whether we can use Google+ tags on the front-end.
1222
*
1223
* @since 2.6.0
1224
* @staticvar bool $cache
inc/classes/sanitize.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -932,14 +932,15 @@ class Sanitize extends Admin_Pages {
932
* @return string 'in_query' or 'post_query'
933
*/
934
public function s_alter_query_type( $new_value ) {
935
-
936
switch ( $new_value ) {
937
case 'in_query' :
938
case 'post_query' :
939
return (string) $new_value;
940
941
default :
942
return 'in_query';
943
}
944
}
945
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
932
* @return string 'in_query' or 'post_query'
933
*/
934
public function s_alter_query_type( $new_value ) {
935
switch ( $new_value ) {
936
case 'in_query' :
937
case 'post_query' :
938
return (string) $new_value;
939
+ break;
940
941
default :
942
return 'in_query';
943
+ break;
944
}
945
}
946
inc/classes/site-options.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -122,7 +122,7 @@ class Site_Options extends Sanitize {
122
'display_seo_bar_metabox' => 0, // SEO Bar post SEO Settings.
123
124
'display_pixel_counter' => 1, // Pixel counter.
125
- 'display_character_counter' => 0, // Character counter.
126
127
// General. Canonical.
128
'canonical_scheme' => 'automatic', // Canonical URL scheme.
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
122
'display_seo_bar_metabox' => 0, // SEO Bar post SEO Settings.
123
124
'display_pixel_counter' => 1, // Pixel counter.
125
+ 'display_character_counter' => 1, // Character counter.
126
127
// General. Canonical.
128
'canonical_scheme' => 'automatic', // Canonical URL scheme.
inc/classes/sitemaps.class.php CHANGED
@@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die;
8
9
/**
10
* The SEO Framework plugin
11
- * Copyright (C) 2015 - 2017 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
@@ -541,6 +541,7 @@ class Sitemaps extends Metaboxes {
541
* @since 2.2.9
542
* @since 2.8.0 Now adjusts memory limit when possible.
543
* @since 2.9.3 No longer crashes on WordPress sites below WP 4.6.
544
*
545
* @return string The sitemap content.
546
*/
@@ -552,20 +553,6 @@ class Sitemaps extends Metaboxes {
552
553
$content = '';
554
555
- /**
556
- * Applies filters the_seo_framework_sitemap_exclude_ids : array of id's
557
- *
558
- * @since 2.5.2
559
- * @since 2.8.0 : No longer accepts '0' as entry.
560
- */
561
- $excluded = (array) \apply_filters( 'the_seo_framework_sitemap_exclude_ids', array() );
562
-
563
- if ( empty( $excluded ) ) {
564
- $excluded = '';
565
- } else {
566
- $excluded = array_flip( $excluded );
567
- }
568
-
569
/**
570
* Maximum pages and posts to fetch.
571
* A total of 2100, consisting of 3 times $max_posts
@@ -594,9 +581,7 @@ class Sitemaps extends Metaboxes {
594
* We can't get specific on the home page, unfortunately.
595
*/
596
$sitemaps_modified = $this->is_option_checked( 'sitemaps_modified' );
597
- if ( $sitemaps_modified ) {
598
- $page_lastmod = $post_lastmod = $home_lastmod = true;
599
- }
600
601
/**
602
* Generation time output
@@ -655,21 +640,28 @@ class Sitemaps extends Metaboxes {
655
unset( $latest_pages[ $key_on_front ] );
656
}
657
658
- //* Render frontpage.
659
- if ( '' === $excluded || empty( $excluded[ $id_on_front ] ) ) :
660
- //* Fetch the noindex option from the page and homepage.
661
- $indexed = ! $this->get_option( 'homepage_noindex' ) && ( ! $id_on_front || ! $this->get_custom_field( '_genesis_noindex', $id_on_front ) );
662
-
663
- //* Continue if indexed.
664
- if ( $indexed ) {
665
$content .= "\t<url>\n";
666
- $content .= "\t\t<loc>" . $this->get_homepage_permalink() . "</loc>\n";
667
668
// Keep it consistent. Only parse if page_lastmod is true.
669
if ( $home_lastmod ) {
670
if ( $page_on_front ) {
671
- $front_object = \get_post( $id_on_front );
672
- $front_modified_gmt = isset( $front_object->post_modified_gmt ) ? $front_object->post_modified_gmt : '0000-00-00 00:00:00';
673
} else {
674
$args = array(
675
'numberposts' => 1,
@@ -680,10 +672,9 @@ class Sitemaps extends Metaboxes {
680
'order' => 'DESC',
681
'offset' => 0,
682
);
683
- $post = \wp_get_recent_posts( $args, OBJECT );
684
- $front_object = isset( $post[0] ) ? $post[0] : null;
685
- unset( $post );
686
- $front_modified_gmt = isset( $front_object->post_date_gmt ) ? $front_object->post_date_gmt : '0000-00-00 00:00:00';
687
}
688
689
if ( '0000-00-00 00:00:00' !== $front_modified_gmt )
@@ -693,27 +684,29 @@ class Sitemaps extends Metaboxes {
693
$content .= "\t\t<priority>1.0</priority>\n";
694
$content .= "\t</url>\n";
695
}
696
- endif;
697
698
- //* Render the page for posts.
699
if ( $page_on_front && $page_for_posts_id ) :
700
-
701
//* Remove ID for blog from list and add frontpage to list.
702
if ( false !== $key_for_posts = array_search( $page_for_posts_id, $latest_pages, true ) ) {
703
unset( $latest_pages[ $key_for_posts ] );
704
}
705
706
- if ( '' === $excluded || empty( $excluded[ $page_for_posts_id ] ) ) :
707
- //* Fetch the noindex option from the page and homepage.
708
- $indexed = ! $this->get_custom_field( '_genesis_noindex', $page_for_posts_id );
709
- $page = \get_post( $page_for_posts_id );
710
711
- //* Continue if indexed.
712
- if ( $indexed && isset( $page->ID ) ) {
713
$content .= "\t<url>\n";
714
- $content .= "\t\t<loc>" . $this->create_canonical_url( array( 'id' => $page->ID ) ) . "</loc>\n";
715
716
- // Keep it consistent. Only parse if page_lastmod is true.
717
if ( $page_lastmod ) {
718
$args = array(
719
'numberposts' => 1,
@@ -724,10 +717,10 @@ class Sitemaps extends Metaboxes {
724
'order' => 'DESC',
725
'offset' => 0,
726
);
727
- $post = \wp_get_recent_posts( $args, OBJECT );
728
- $lastest_post = isset( $post[0] ) ? $post[0] : null;
729
$latest_post_published_gmt = isset( $lastest_post->post_date_gmt ) ? $lastest_post->post_date_gmt : '0000-00-00 00:00:00';
730
- $page_for_posts_modified_gmt = $page->post_modified_gmt;
731
732
if ( strtotime( $latest_post_published_gmt ) > strtotime( $page_for_posts_modified_gmt ) ) {
733
$page_modified_gmt = $latest_post_published_gmt;
@@ -742,44 +735,38 @@ class Sitemaps extends Metaboxes {
742
$content .= "\t\t<priority>0.9</priority>\n";
743
$content .= "\t</url>\n";
744
}
745
- endif;
746
747
endif;
748
749
- /**
750
- * This can be heavy.
751
- */
752
foreach ( $latest_pages as $page_id ) :
753
$page = \get_post( $page_id );
754
755
- if ( isset( $page->ID ) ) :
756
- $page_id = $page->ID;
757
- if ( '' === $excluded || empty( $excluded[ $page_id ] ) ) {
758
- //* Fetch the noindex option, per page.
759
- $indexed = ! $this->get_custom_field( '_genesis_noindex', $page_id );
760
761
- //* Continue if indexed.
762
- if ( $indexed ) {
763
- $content .= "\t<url>\n";
764
- $content .= "\t\t<loc>" . $this->create_canonical_url( array( 'id' => $page_id ) ) . "</loc>\n";
765
766
- // Keep it consistent. Only parse if page_lastmod is true.
767
- if ( $page_lastmod ) {
768
- $page_modified_gmt = $page->post_modified_gmt;
769
770
- if ( '0000-00-00 00:00:00' !== $page_modified_gmt )
771
- $content .= "\t\t<lastmod>" . $this->gmt2date( $timestamp_format, $page_modified_gmt ) . "</lastmod>\n";
772
- }
773
774
- $content .= "\t\t<priority>0.9</priority>\n";
775
- $content .= "\t</url>\n";
776
- }
777
- }
778
- endif;
779
endforeach;
780
781
//* Free memory.
782
- unset( $latest_pages );
783
endif;
784
785
if ( $totalposts ) {
@@ -842,43 +829,37 @@ class Sitemaps extends Metaboxes {
842
*/
843
foreach ( $latest_posts as $post_id ) :
844
$post = \get_post( $post_id );
845
846
- if ( isset( $post->ID ) ) :
847
- $post_id = $post->ID;
848
- if ( '' === $excluded || empty( $excluded[ $post_id ] ) ) {
849
- //* Fetch the noindex option, per page.
850
- $indexed = ! $this->get_custom_field( '_genesis_noindex', $post_id );
851
-
852
- //* Continue if indexed
853
- if ( $indexed ) {
854
855
- $content .= "\t<url>\n";
856
- // No need to use static vars
857
- $content .= "\t\t<loc>" . $this->create_canonical_url( array( 'id' => $post_id ) ) . "</loc>\n";
858
859
- // Keep it consistent. Only parse if page_lastmod is true.
860
- if ( $post_lastmod ) {
861
- $post_modified_gmt = $post->post_modified_gmt;
862
863
- if ( '0000-00-00 00:00:00' !== $post_modified_gmt )
864
- $content .= "\t\t<lastmod>" . $this->gmt2date( $timestamp_format, $post_modified_gmt ) . "</lastmod>\n";
865
- }
866
867
- $content .= "\t\t<priority>" . number_format( $priority, 1 ) . "</priority>\n";
868
- $content .= "\t</url>\n";
869
870
- // Lower the priority for the next pass.
871
- $priority = $priority - $prioritydiff;
872
873
- // Cast away negative numbers.
874
- $priority = $priority <= 0 ? 0 : (float) $priority;
875
- }
876
- }
877
- endif;
878
endforeach;
879
880
//* Free memory.
881
- unset( $latest_posts );
882
endif;
883
884
if ( $total_cpt_posts ) :
@@ -956,48 +937,38 @@ class Sitemaps extends Metaboxes {
956
* This can be heavy.
957
*/
958
foreach ( $latest_cpt_posts as $ctp_post_id ) :
959
-
960
$ctp_post = \get_post( $ctp_post_id );
961
962
- if ( isset( $ctp_post->ID ) ) :
963
- $cpt_id = $ctp_post->ID;
964
-
965
- if ( '' === $excluded || empty( $excluded[ $cpt_id ] ) ) {
966
-
967
- //* Fetch the noindex option, per page.
968
- $indexed = ! $this->get_custom_field( '_genesis_noindex', $cpt_id );
969
970
- //* Continue if indexed
971
- if ( $indexed ) {
972
-
973
- $content .= "\t<url>\n";
974
- //* No need to use static vars
975
- $content .= "\t\t<loc>" . $this->create_canonical_url( array( 'id' => $cpt_id ) ) . "</loc>\n";
976
-
977
- //* Keep it consistent. Only parse if page_lastmod is true.
978
- if ( $post_lastmod ) {
979
- $cpt_modified_gmt = $ctp_post->post_modified_gmt;
980
-
981
- //* Some CPT don't set modified time.
982
- if ( '0000-00-00 00:00:00' !== $cpt_modified_gmt )
983
- $content .= "\t\t<lastmod>" . $this->gmt2date( $timestamp_format, $cpt_modified_gmt ) . "</lastmod>\n";
984
- }
985
986
- $content .= "\t\t<priority>" . number_format( $priority_cpt, 1 ) . "</priority>\n";
987
- $content .= "\t</url>\n";
988
989
- // Lower the priority for the next pass.
990
- $priority_cpt = $priority_cpt - $prioritydiff_cpt;
991
992
- // Cast away negative numbers.
993
- $priority_cpt = $priority_cpt <= 0 ? 0 : (float) $priority_cpt;
994
- }
995
- }
996
- endif;
997
endforeach;
998
999
//* Free memory.
1000
- unset( $latest_cpt_posts );
1001
endif;
1002
1003
/**
@@ -1061,6 +1032,45 @@ class Sitemaps extends Metaboxes {
1061
return $content;
1062
}
1063
1064
/**
1065
* Ping search engines on post publish.
1066
*
8
9
/**
10
* The SEO Framework plugin
11
+ * Copyright (C) 2015 - 2018 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License version 3 as published
541
* @since 2.2.9
542
* @since 2.8.0 Now adjusts memory limit when possible.
543
* @since 2.9.3 No longer crashes on WordPress sites below WP 4.6.
544
+ * @since 3.0.4 No longer outputs empty URL entries.
545
*
546
* @return string The sitemap content.
547
*/
553
554
$content = '';
555
556
/**
557
* Maximum pages and posts to fetch.
558
* A total of 2100, consisting of 3 times $max_posts
581
* We can't get specific on the home page, unfortunately.
582
*/
583
$sitemaps_modified = $this->is_option_checked( 'sitemaps_modified' );
584
+ $page_lastmod = $post_lastmod = $home_lastmod = (bool) $sitemaps_modified;
585
586
/**
587
* Generation time output
640
unset( $latest_pages[ $key_on_front ] );
641
}
642
643
+ //= Render frontpage.
644
+ $front_page = $page_on_front ? \get_post( $id_on_front ) : null;
645
+ $render_front = false;
646
+ if ( ! $this->get_option( 'homepage_noindex' ) ) {
647
+ if ( $page_on_front ) {
648
+ $render_front = isset( $front_page->ID )
649
+ && $this->is_post_included_in_sitemap( $front_page->ID )
650
+ && ! $this->is_protected( $front_page->ID );
651
+ } else {
652
+ $render_front = $this->is_post_included_in_sitemap( $id_on_front );
653
+ }
654
+ }
655
+ if ( $render_front ) {
656
+ $_url = $this->get_homepage_permalink();
657
+ if ( $_url ) {
658
$content .= "\t<url>\n";
659
+ $content .= "\t\t<loc>" . $_url . "</loc>\n";
660
661
// Keep it consistent. Only parse if page_lastmod is true.
662
if ( $home_lastmod ) {
663
if ( $page_on_front ) {
664
+ $front_modified_gmt = isset( $front_page->post_modified_gmt ) ? $front_page->post_modified_gmt : '0000-00-00 00:00:00';
665
} else {
666
$args = array(
667
'numberposts' => 1,
672
'order' => 'DESC',
673
'offset' => 0,
674
);
675
+ $latests_posts = \wp_get_recent_posts( $args, OBJECT );
676
+ $latest_post = isset( $latests_posts[0] ) ? $latests_posts[0] : null;
677
+ $front_modified_gmt = isset( $latest_post->post_date_gmt ) ? $latest_post->post_date_gmt : '0000-00-00 00:00:00';
678
}
679
680
if ( '0000-00-00 00:00:00' !== $front_modified_gmt )
684
$content .= "\t\t<priority>1.0</priority>\n";
685
$content .= "\t</url>\n";
686
}
687
+ //* Free memory.
688
+ unset( $latests_posts, $latest_post, $front_page );
689
+ }
690
691
+ //= Render the page for posts.
692
if ( $page_on_front && $page_for_posts_id ) :
693
//* Remove ID for blog from list and add frontpage to list.
694
if ( false !== $key_for_posts = array_search( $page_for_posts_id, $latest_pages, true ) ) {
695
unset( $latest_pages[ $key_for_posts ] );
696
}
697
698
+ $blog_page = \get_post( $page_for_posts_id );
699
+ $render_blog = isset( $blog_page->ID )
700
+ && $this->is_post_included_in_sitemap( $blog_page->ID )
701
+ && ! $this->is_protected( $blog_page->ID );
702
703
+ if ( $render_blog ) {
704
+ $_url = $this->create_canonical_url( array( 'id' => $blog_page->ID ) );
705
+ if ( $_url ) {
706
$content .= "\t<url>\n";
707
+ $content .= "\t\t<loc>" . $_url . "</loc>\n";
708
709
+ // Keep it consistent. Only parse if $page_lastmod is true.
710
if ( $page_lastmod ) {
711
$args = array(
712
'numberposts' => 1,
717
'order' => 'DESC',
718
'offset' => 0,
719
);
720
+ $lastest_posts = \wp_get_recent_posts( $args, OBJECT );
721
+ $lastest_post = isset( $lastest_posts[0] ) ? $lastest_posts[0] : null;
722
$latest_post_published_gmt = isset( $lastest_post->post_date_gmt ) ? $lastest_post->post_date_gmt : '0000-00-00 00:00:00';
723
+ $page_for_posts_modified_gmt = $blog_page->post_modified_gmt;
724
725
if ( strtotime( $latest_post_published_gmt ) > strtotime( $page_for_posts_modified_gmt ) ) {
726
$page_modified_gmt = $latest_post_published_gmt;
735
$content .= "\t\t<priority>0.9</priority>\n";
736
$content .= "\t</url>\n";
737
}
738
+ }
739
740
+ //* Free memory.
741
+ unset( $latest_posts, $latest_post, $blog_page );
742
endif;
743
744
foreach ( $latest_pages as $page_id ) :
745
$page = \get_post( $page_id );
746
+ if ( empty( $page->ID ) || ! $this->is_post_included_in_sitemap( $page->ID ) )
747
+ continue;
748
749
+ $_url = $this->create_canonical_url( array( 'id' => $page->ID ) );
750
+ if ( ! $_url )
751
+ continue;
752
753
+ $content .= "\t<url>\n";
754
+ $content .= "\t\t<loc>" . $_url . "</loc>\n";
755
756
+ // Keep it consistent. Only parse if page_lastmod is true.
757
+ if ( $page_lastmod ) {
758
+ $page_modified_gmt = $page->post_modified_gmt;
759
760
+ if ( '0000-00-00 00:00:00' !== $page_modified_gmt )
761
+ $content .= "\t\t<lastmod>" . $this->gmt2date( $timestamp_format, $page_modified_gmt ) . "</lastmod>\n";
762
+ }
763
764
+ $content .= "\t\t<priority>0.9</priority>\n";
765
+ $content .= "\t</url>\n";
766
endforeach;
767
768
//* Free memory.
769
+ unset( $latest_pages, $page );
770
endif;
771
772
if ( $totalposts ) {
829
*/
830
foreach ( $latest_posts as $post_id ) :
831
$post = \get_post( $post_id );
832
+ if ( empty( $post->ID ) || ! $this->is_post_included_in_sitemap( $post->ID ) )
833
+ continue;
834
835
+ $_url = $this->create_canonical_url( array( 'id' => $post->ID ) );
836
+ if ( ! $_url )
837
+ continue;
838