Remove Yoast SEO Comments - Version 3.0

Version Description

  • Cleaner, more lightweight and optimized coding.
  • New dashboard widget added.
  • Removed backup solutions.
  • Removed XML buffering.
Download this release

Release Info

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

Code changes from version 2.0.4 to 3.0

Files changed (2) hide show
  1. readme.txt +14 -12
  2. remove-yoast-seo-comments.php +77 -74
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.7
8
 
9
  Removes the Yoast SEO advertisement HTML comments from your front-end source code.
10
 
@@ -14,15 +14,13 @@ A light-weight plugin which will remove the advertisement HTML comments coming f
14
 
15
  `<!-- This site is optimized with the Yoast SEO plugin -->`
16
 
17
- RYSC also removes the HTML comments from XML pages generated by Yoast SEO.
18
-
19
  This is a must-have plugin if you have Yoast SEO installed.
20
 
21
  = Note: =
22
  This plugin requires [Yoast SEO](http://wordpress.org/plugins/wordpress-seo/).
23
 
24
  = Like this plugin? =
25
- If you like this plugin, make sure to rate it 5 stars. Also check out [Remove Google Analytics comments](https://wordpress.org/plugins/remove-google-analytics-comments/)!
26
 
27
  == Installation ==
28
 
@@ -32,26 +30,30 @@ If you like this plugin, make sure to rate it 5 stars. Also check out [Remove Go
32
 
33
  == Frequently Asked Questions ==
34
 
35
- = When Yoast SEO updates their plugin, will the HTML comments stay removed? =
 
 
36
 
37
- Yes, they will stay removed as long as Yoast SEO doesn't change its coding layout. If they do decide to change their coding layout for any reason, the RYSC backup solution will kick in and keep the comments removed.
38
 
39
  = Does this plugin add any configuration options? =
40
 
41
- No, activate the plugin and you are done! The Yoast SEO have now been removed from your source code.
42
 
43
  = Will this plugin modify any of my Yoast SEO plugin files? =
44
 
45
  No, this plugin will not modify any of your Yoast SEO plugin files.
46
 
47
- = My RYSC version is incompatible with Yoast SEO. What happened? =
48
-
49
- In most cases happens when Yoast SEO changes their coding layout. Please be patient while we make RYSC compatible again.
50
-
51
  == Changelog ==
52
 
 
 
 
 
 
 
53
  = 2.0.4 =
54
- * Fixes an issue regarding XML pages buffering
55
 
56
  = 2.0.3 =
57
  * Removes Yoast SEO comments from XML pages generated by Yoast SEO.
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.8
8
 
9
  Removes the Yoast SEO advertisement HTML comments from your front-end source code.
10
 
14
 
15
  `<!-- This site is optimized with the Yoast SEO plugin -->`
16
 
 
 
17
  This is a must-have plugin if you have Yoast SEO installed.
18
 
19
  = Note: =
20
  This plugin requires [Yoast SEO](http://wordpress.org/plugins/wordpress-seo/).
21
 
22
  = Like this plugin? =
23
+ If you like this plugin, make sure to rate it 5 stars or donate a small amount to fully support the development.
24
 
25
  == Installation ==
26
 
30
 
31
  == Frequently Asked Questions ==
32
 
33
+ = How do I know which version of Yoast SEO is compatible? =
34
+
35
+ It is recommended running a test installation of WordPress, also running Yoast SEO and RYSC. Check the compatibility status on the admin dashboard after Yoast SEO releases an update.
36
 
37
+ All Yoast SEO versions are compatible with RYSC, tested up to Yoast SEO 4.9.
38
 
39
  = Does this plugin add any configuration options? =
40
 
41
+ No, activate the plugin and you are done! No settings to configure.
42
 
43
  = Will this plugin modify any of my Yoast SEO plugin files? =
44
 
45
  No, this plugin will not modify any of your Yoast SEO plugin files.
46
 
 
 
 
 
47
  == Changelog ==
48
 
49
+ = 3.0 =
50
+ * Cleaner, more lightweight and optimized coding.
51
+ * New dashboard widget added.
52
+ * Removed backup solutions.
53
+ * Removed XML buffering.
54
+
55
  = 2.0.4 =
56
+ * Fixes an issue regarding XML pages buffering.
57
 
58
  = 2.0.3 =
59
  * Removes Yoast SEO comments from XML pages generated by Yoast SEO.
remove-yoast-seo-comments.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
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: 2.0.4
7
  * Author: Mitch
8
  * Author URI: https://profiles.wordpress.org/lowest
9
  * License: GPL-2.0+
@@ -29,90 +29,93 @@
29
 
30
  if ( ! defined( 'ABSPATH' ) ) { exit; }
31
 
32
- $GLOBALS['rysc_opts'] = get_option('rysc_options', array());
33
 
34
- function rysc_bundle() {
35
- if(defined( 'WPSEO_VERSION' ) && class_exists( 'WPSEO_Frontend' )) {
36
- if(method_exists( 'WPSEO_Frontend', 'debug_mark' ) && version_compare( WPSEO_VERSION, '4.4', '>=' )) { // for Yoast SEO 4.4 or later
37
- remove_action( 'wpseo_head', array( WPSEO_Frontend::get_instance(), 'debug_mark' ) , 2);
38
-
39
- remove_action( 'wp_head', array( WPSEO_Frontend::get_instance(), 'head' ) , 1);
40
- add_action( 'wp_head', 'rysc_rewrite_head' , 1);
41
-
42
- add_action( 'init', 'rysc_xml_parser', 999 );
43
- } elseif(method_exists( 'WPSEO_Frontend', 'debug_marker' ) && version_compare( WPSEO_VERSION, '4.3', '<=' )) { // for Yoast SEO 4.3 or earlier
44
- remove_action( 'wpseo_head', array( WPSEO_Frontend::get_instance(), 'debug_marker' ) , 2);
45
 
46
- remove_action( 'wp_head', array( WPSEO_Frontend::get_instance(), 'head' ) , 1);
47
- add_action( 'wp_head', 'rysc_rewrite_head' , 1);
 
 
48
 
49
- add_action( 'init', 'rysc_xml_parser', 999 );
50
- } else { // looks like we have no compatible solutions for now
51
- add_action( 'wp_head', 'rysc_parser', 999 );
 
 
52
 
53
- add_action( 'init', 'rysc_xml_parser', 999 );
54
  }
 
 
55
  }
56
- }
57
- add_action( 'init', 'rysc_bundle');
58
-
59
- function rysc_rewrite_head() {
60
- $rewrite = new ReflectionMethod( 'WPSEO_Frontend', 'head' );
61
-
62
- $filename = $rewrite->getFileName();
63
- $start_line = $rewrite->getStartLine();
64
- $end_line = $rewrite->getEndLine()-1;
65
-
66
- $length = $end_line - $start_line;
67
- $source = file($filename);
68
- $body = implode("", array_slice($source, $start_line, $length));
69
- $body = preg_replace( '/echo \'\<\!(.*?)\n/', '', $body);
70
-
71
- eval($body);
72
- }
73
-
74
- function rysc_xml_parser() {
75
- $ext = pathinfo($_SERVER['REQUEST_URI'], PATHINFO_EXTENSION);
76
-
77
- if($ext == 'xml') {
78
- $flush = ob_get_contents() ? ob_end_clean() : '';
79
-
80
- ob_start(function( $buffer ) {
81
- return preg_replace( '/\n?<.*?yoast.*?>/mi', '', $buffer ) . $flush;
82
- });
83
  }
84
- }
85
-
86
- function rysc_parser() {
87
- $current_cont = ob_get_contents();
88
 
89
- ob_clean();
90
-
91
- if(empty($GLOBALS['rysc_opts']['phrase_for_'.WPSEO_VERSION])){
92
- preg_match_all('/(\n|)\<\!\-\-(.*?)yoast seo(.*?)\-\-\>/i', $current_cont, $result);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
- if (!empty($result[0])) {
95
- if (!empty($result[0][0])) {
96
- $GLOBALS['rysc_opts']['phrase_for_'.WPSEO_VERSION]['line1'] = $first_line = $result[0][0];
97
- }
98
- if (!empty($result[0][1])) {
99
- $GLOBALS['rysc_opts']['phrase_for_'.WPSEO_VERSION]['line2'] = $second_line = $result[0][1];
100
- }
101
  }
102
-
103
- update_option('rysc_options', $GLOBALS['rysc_opts']);
104
- } else {
105
- $first_line = $GLOBALS['rysc_opts']['phrase_for_'.WPSEO_VERSION]['line1'];
106
- $second_line = $GLOBALS['rysc_opts']['phrase_for_'.WPSEO_VERSION]['line2'];
107
  }
 
 
 
 
 
 
 
108
 
109
- $current_cont = str_replace( $first_line, '', $current_cont );
110
- $current_cont = str_replace( $second_line, '', $current_cont );
 
 
111
 
112
- echo $current_cont;
 
 
 
 
 
 
 
113
  }
114
 
115
- function rysc_links( $link ) {
116
- return 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>') );
117
- }
118
- add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'rysc_links');
1
  <?php
2
  /*
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
7
  * Author: Mitch
8
  * Author URI: https://profiles.wordpress.org/lowest
9
  * License: GPL-2.0+
29
 
30
  if ( ! defined( 'ABSPATH' ) ) { exit; }
31
 
32
+ if ( ! defined( 'RYSC_VERSION' ) ) { define( 'RYSC_VERSION', '3.0' ); }
33
 
34
+ class RYSC {
35
+ private $debug_marker_removed = false;
36
+ private $head_marker_removed = false;
37
+
38
+ public function __construct() {
39
+ add_action( 'init', array( $this, 'bundle' ), 1);
40
+ }
41
+
42
+ public function bundle() {
43
+ if(defined( 'WPSEO_VERSION' )) {
44
+ $debug_marker = ( version_compare( WPSEO_VERSION, '4.4', '>=' ) ) ? 'debug_mark' : 'debug_marker';
45
 
46
+ if(class_exists( 'WPSEO_Frontend' ) && method_exists( 'WPSEO_Frontend', $debug_marker )) {
47
+ remove_action( 'wpseo_head', array( WPSEO_Frontend::get_instance(), $debug_marker ) , 2);
48
+ $this->debug_marker_removed = true;
49
+ }
50
 
51
+ if(class_exists( 'WPSEO_Frontend' ) && method_exists( 'WPSEO_Frontend', 'head' )) {
52
+ remove_action( 'wp_head', array( WPSEO_Frontend::get_instance(), 'head' ) , 1);
53
+ add_action( 'wp_head', array($this, 'rewrite'), 1);
54
+ $this->head_marker_removed = true;
55
+ }
56
 
57
+ add_action( 'wp_dashboard_setup', array( $this, 'dash_widget' ) );
58
  }
59
+
60
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_links' ) );
61
  }
62
+
63
+ public function operating_status() {
64
+ if($this->debug_marker_removed && $this->head_marker_removed) {
65
+ return 1;
66
+ } elseif(!$this->debug_marker_removed && $this->head_marker_removed || $this->debug_marker_removed && !$this->head_marker_removed) {
67
+ return 2;
68
+ } else {
69
+ return 3;
70
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  }
 
 
 
 
72
 
73
+ public function dash_widget() {
74
+ wp_add_dashboard_widget( 'dashboard_widget', 'Remove Yoast SEO Comments', array( $this, 'dash_widget_content' ) );
75
+ }
76
+
77
+ public function dash_widget_content() {
78
+ if($this->operating_status() == 1) {
79
+ $status = '<span style="color:#04B404;font-weight:bold">Fully supported</span>';
80
+ $content = '<p>Version ' . WPSEO_VERSION . ' of Yoast SEO is fully supported by RYSC ' . RYSC_VERSION . '. The HTML comments have been removed from your front-end source code.</p>';
81
+ $show_supported = false;
82
+ } elseif($this->operating_status() == 2) {
83
+ $status = '<span style="color:#FF8000;font-weight:bold">Not properly supported</span>';
84
+ $content = '<p>Version ' . WPSEO_VERSION . ' of Yoast SEO is not properly supported by RYSC ' . RYSC_VERSION . '. Some functions are not working. Please downgrade or wait for a plugin update.</p>';
85
+ $show_supported = true;
86
+ } elseif($this->operating_status() == 3) {
87
+ $status = '<span style="color:#DF0101;font-weight:bold">Not supported</span>';
88
+ $content = '<p>Version ' . WPSEO_VERSION . ' of Yoast SEO is not supported by RYSC ' . RYSC_VERSION . '. Please downgrade or wait for a plugin update.</p>';
89
+ $show_supported = true;
90
+ }
91
 
92
+ echo '<div class="activity-block"><h3><span class="dashicons dashicons-admin-plugins"></span> Yoast SEO ' . WPSEO_VERSION . ' Compatibility Status: ' . $status . '</h3></div>';
93
+ echo $content;
94
+ if($show_supported) {
95
+ 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 4.9">Yoast SEO 4.9</a> and earlier are tested and supported by RYSC.</p>';
 
 
 
96
  }
 
 
 
 
 
97
  }
98
+
99
+ public function rewrite() {
100
+ $rewrite = new ReflectionMethod( 'WPSEO_Frontend', 'head' );
101
+
102
+ $filename = $rewrite->getFileName();
103
+ $start_line = $rewrite->getStartLine();
104
+ $end_line = $rewrite->getEndLine()-1;
105
 
106
+ $length = $end_line - $start_line;
107
+ $source = file( $filename );
108
+ $body = implode( '', array_slice($source, $start_line, $length) );
109
+ $body = preg_replace( '/echo \'\<\!(.*?)\n/', '', $body);
110
 
111
+ eval($body);
112
+ }
113
+
114
+ public function plugin_links( $link ) {
115
+ $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>') );
116
+
117
+ return $plugin_links;
118
+ }
119
  }
120
 
121
+ $rysc = new RYSC();