Remove Yoast SEO Comments - Version 3.1

Version Description

  • All future Yoast SEO versions will be supported, even when Yoast SEO removes the functions we rely on.
  • Minor bug fixes.
Download this release

Release Info

Developer lowest
Plugin Icon wp plugin Remove Yoast SEO Comments
Version 3.1
Comparing to
See all releases

Code changes from version 3.0.3 to 3.1

Files changed (2) hide show
  1. readme.txt +9 -2
  2. remove-yoast-seo-comments.php +41 -14
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: yoast seo, yoast, seo, remove comments, remove html, remove ads, remove debug code, lightweight
5
  Requires at least: 1.2.0
6
  Stable tag: 1.2.0
7
- Tested up to: 4.9
8
 
9
  Removes the Yoast SEO advertisement HTML comments from your front-end source code.
10
 
@@ -46,8 +46,15 @@ No, this plugin will not modify any of your Yoast SEO plugin files.
46
 
47
  == Changelog ==
48
 
 
 
 
 
 
 
 
49
  = 3.0.3 =
50
- * Fixes conflicts with Yoast SEO 5.7.1
51
 
52
  = 3.0.2 =
53
  * Limited the RYSC dashboard widget to admin only.
4
  Tags: yoast seo, yoast, seo, remove comments, remove html, remove ads, remove debug code, lightweight
5
  Requires at least: 1.2.0
6
  Stable tag: 1.2.0
7
+ Tested up to: 4.9.1
8
 
9
  Removes the Yoast SEO advertisement HTML comments from your front-end source code.
10
 
46
 
47
  == Changelog ==
48
 
49
+ = 3.1 =
50
+ * All future Yoast SEO versions will be supported, even when Yoast SEO removes the functions we rely on.
51
+ * Minor bug fixes.
52
+
53
+ = 3.0.4 =
54
+ * Fixed issue with Yoast SEO head function not outputting.
55
+
56
  = 3.0.3 =
57
+ * Fixed conflicts with Yoast SEO 5.7.1
58
 
59
  = 3.0.2 =
60
  * Limited the RYSC dashboard widget to admin only.
remove-yoast-seo-comments.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Remove Yoast SEO Comments
4
  * Plugin URI: https://wordpress.org/plugins/remove-yoast-seo-comments/
5
  * Description: Removes the Yoast SEO advertisement HTML comments from your front-end source code.
6
- * Version: 3.0.3
7
  * Author: Mitch
8
  * Author URI: https://profiles.wordpress.org/lowest
9
  * License: GPL-2.0+
@@ -30,9 +30,10 @@
30
  if ( ! defined( 'ABSPATH' ) ) { exit; }
31
 
32
  class RYSC {
33
- private $version = '3.0.3';
34
  private $debug_marker_removed = false;
35
  private $head_marker_removed = false;
 
36
 
37
  public function __construct() {
38
  add_action( 'init', array( $this, 'bundle' ), 1);
@@ -41,18 +42,37 @@ class RYSC {
41
  public function bundle() {
42
  if(defined( 'WPSEO_VERSION' )) {
43
  $debug_marker = ( version_compare( WPSEO_VERSION, '4.4', '>=' ) ) ? 'debug_mark' : 'debug_marker';
44
-
 
45
  if(class_exists( 'WPSEO_Frontend' ) && method_exists( 'WPSEO_Frontend', $debug_marker )) {
46
  remove_action( 'wpseo_head', array( WPSEO_Frontend::get_instance(), $debug_marker ) , 2);
 
47
  $this->debug_marker_removed = true;
 
 
 
48
  }
49
 
50
- if(class_exists( 'WPSEO_Frontend' ) && method_exists( 'WPSEO_Frontend', 'head' )) {
 
51
  remove_action( 'wp_head', array( WPSEO_Frontend::get_instance(), 'head' ) , 1);
52
- if(WPSEO_VERSION < '5.8') add_action( 'wp_head', array($this, 'rewrite'), 1);
 
 
 
 
 
 
 
53
  $this->head_marker_removed = true;
54
  }
55
 
 
 
 
 
 
 
56
  if(current_user_can('manage_options')) add_action( 'wp_dashboard_setup', array( $this, 'dash_widget' ) );
57
  }
58
 
@@ -77,24 +97,19 @@ class RYSC {
77
  if($this->operating_status() == 1) {
78
  $status = '<span style="color:#04B404;font-weight:bold">Fully supported</span>';
79
  $content = '<p>Version ' . WPSEO_VERSION . ' of Yoast SEO is fully supported by RYSC ' . $this->version . '. The HTML comments have been removed from your front-end source code.</p>';
80
- $show_supported = false;
81
  } elseif($this->operating_status() == 2) {
82
- $status = '<span style="color:#FF8000;font-weight:bold">Not properly supported</span>';
83
- $content = '<p>Version ' . WPSEO_VERSION . ' of Yoast SEO is not properly supported by RYSC ' . $this->version . '. Some functions are not working. Please downgrade or wait for a plugin update.</p>';
84
- $show_supported = true;
85
  } elseif($this->operating_status() == 3) {
86
  $status = '<span style="color:#DF0101;font-weight:bold">Not supported</span>';
87
- $content = '<p>Version ' . WPSEO_VERSION . ' of Yoast SEO is not supported by RYSC ' . $this->version . '. Please downgrade or wait for a plugin update.</p>';
88
- $show_supported = true;
89
  }
90
 
91
  echo '<div class="activity-block"><h3><span class="dashicons dashicons-admin-plugins"></span> Yoast SEO ' . WPSEO_VERSION . ' Compatibility Status: ' . $status . '</h3></div>';
92
  echo $content;
93
- if($show_supported) {
94
- echo '<p style="color:#808080"><span class="dashicons dashicons-lightbulb"></span> Want to downgrade? <a href="https://downloads.wordpress.org/plugin/wordpress-seo.4.9.zip" title="Download Yoast SEO 5.7.1">Yoast SEO 5.7.1</a> and earlier are tested and supported by RYSC.</p>';
95
- }
96
  }
97
 
 
98
  public function rewrite() {
99
  $rewrite = new ReflectionMethod( 'WPSEO_Frontend', 'head' );
100
 
@@ -110,6 +125,18 @@ class RYSC {
110
  eval($body);
111
  }
112
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  public function plugin_links( $link ) {
114
  $plugin_links = array_merge( $link, array('<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2VYPRGME8QELC" target="_blank" rel="noopener noreferrer">' . __('Donate') . '</a>') );
115
 
3
  * Plugin Name: Remove Yoast SEO Comments
4
  * Plugin URI: https://wordpress.org/plugins/remove-yoast-seo-comments/
5
  * Description: Removes the Yoast SEO advertisement HTML comments from your front-end source code.
6
+ * Version: 3.1
7
  * Author: Mitch
8
  * Author URI: https://profiles.wordpress.org/lowest
9
  * License: GPL-2.0+
30
  if ( ! defined( 'ABSPATH' ) ) { exit; }
31
 
32
  class RYSC {
33
+ private $version = '3.1';
34
  private $debug_marker_removed = false;
35
  private $head_marker_removed = false;
36
+ private $backup_plan_active = false;
37
 
38
  public function __construct() {
39
  add_action( 'init', array( $this, 'bundle' ), 1);
42
  public function bundle() {
43
  if(defined( 'WPSEO_VERSION' )) {
44
  $debug_marker = ( version_compare( WPSEO_VERSION, '4.4', '>=' ) ) ? 'debug_mark' : 'debug_marker';
45
+
46
+ // main function to unhook the debug msg
47
  if(class_exists( 'WPSEO_Frontend' ) && method_exists( 'WPSEO_Frontend', $debug_marker )) {
48
  remove_action( 'wpseo_head', array( WPSEO_Frontend::get_instance(), $debug_marker ) , 2);
49
+
50
  $this->debug_marker_removed = true;
51
+
52
+ // also removes the end debug msg as of 5.9
53
+ if(version_compare( WPSEO_VERSION, '5.9', '>=' )) $this->head_marker_removed = true;
54
  }
55
 
56
+ // compatible solution for everything below 5.8
57
+ if(class_exists( 'WPSEO_Frontend' ) && method_exists( 'WPSEO_Frontend', 'head' ) && version_compare( WPSEO_VERSION, '5.8', '<' )) {
58
  remove_action( 'wp_head', array( WPSEO_Frontend::get_instance(), 'head' ) , 1);
59
+ add_action( 'wp_head', array($this, 'rewrite'), 1);
60
+ $this->head_marker_removed = true;
61
+ }
62
+
63
+ // temp solution for all installations on 5.8
64
+ if(version_compare( WPSEO_VERSION, '5.8', '==' )) {
65
+ add_action('get_header', array( $this, 'buffer_header' ));
66
+ add_action('wp_head', array( $this, 'buffer_head' ), 999);
67
  $this->head_marker_removed = true;
68
  }
69
 
70
+ // backup solution
71
+ if($this->operating_status() == 2) {
72
+ add_action('get_header', array( $this, 'buffer_header' ));
73
+ add_action('wp_head', array( $this, 'buffer_head' ), 999);
74
+ }
75
+
76
  if(current_user_can('manage_options')) add_action( 'wp_dashboard_setup', array( $this, 'dash_widget' ) );
77
  }
78
 
97
  if($this->operating_status() == 1) {
98
  $status = '<span style="color:#04B404;font-weight:bold">Fully supported</span>';
99
  $content = '<p>Version ' . WPSEO_VERSION . ' of Yoast SEO is fully supported by RYSC ' . $this->version . '. The HTML comments have been removed from your front-end source code.</p>';
 
100
  } elseif($this->operating_status() == 2) {
101
+ $status = '<span style="color:#FF8000;font-weight:bold">Partially supported</span>';
102
+ $content = '<p>Version ' . WPSEO_VERSION . ' of Yoast SEO is not properly supported by RYSC ' . $this->version . '. Some functions are not working. A backup solution has been enabled to keep the HTML comments removed.</p>';
 
103
  } elseif($this->operating_status() == 3) {
104
  $status = '<span style="color:#DF0101;font-weight:bold">Not supported</span>';
105
+ $content = '<p>Version ' . WPSEO_VERSION . ' of Yoast SEO is not supported by RYSC ' . $this->version . '. A backup solution has been enabled to keep the HTML comments removed.</p>';
 
106
  }
107
 
108
  echo '<div class="activity-block"><h3><span class="dashicons dashicons-admin-plugins"></span> Yoast SEO ' . WPSEO_VERSION . ' Compatibility Status: ' . $status . '</h3></div>';
109
  echo $content;
 
 
 
110
  }
111
 
112
+ // compatible solution for everything below 5.8
113
  public function rewrite() {
114
  $rewrite = new ReflectionMethod( 'WPSEO_Frontend', 'head' );
115
 
125
  eval($body);
126
  }
127
 
128
+ // temp solution for all installations on 5.8, and also the backup solution in the future
129
+ public function buffer_header() {
130
+ ob_start(function ($o) {
131
+ return preg_replace('/\n?<.*?yoast.*?>/mi','',$o);
132
+ });
133
+ }
134
+
135
+ public function buffer_head() {
136
+ ob_end_flush();
137
+ }
138
+
139
+ // add plugin links to plugin page
140
  public function plugin_links( $link ) {
141
  $plugin_links = array_merge( $link, array('<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2VYPRGME8QELC" target="_blank" rel="noopener noreferrer">' . __('Donate') . '</a>') );
142