Remove Yoast SEO Comments - Version 1.0

Version Description

  • Initial release
Download this release

Release Info

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

Version 1.0

Files changed (3) hide show
  1. functions.php +45 -0
  2. readme.txt +28 -0
  3. remove-yoast-seo-comments.php +32 -0
functions.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //**//
3
+ //**// Remove Yoast SEO Comments (RYSC)
4
+ //**// This file holds all the functions.
5
+ //**//
6
+
7
+ // Check if a plugin is active, in this case Yoast SEO
8
+ function rysc_active( $plugin ) {
9
+ $network_active = false;
10
+ if ( is_multisite() ) {
11
+ $plugins = get_site_option( 'active_sitewide_plugins' );
12
+ if ( isset( $plugins[$plugin] ) ) {
13
+ $network_active = true;
14
+ }
15
+ }
16
+ return in_array( $plugin, get_option( 'active_plugins' ) ) || $network_active;
17
+ }
18
+
19
+ // If Yoast SEO is not active, this is the message that will be shown.
20
+ function rysc_notice() {
21
+ echo '<div class="notice notice-error is-dismissible"><p>Cannot activate <strong>Remove Yoast SEO comments</strong>: Please activate <a href="http://wordpress.org/plugins/wordpress-seo/" target="_blank">Yoast SEO</a> plugin first before activating this plugin.</p></div>';
22
+ }
23
+
24
+ // Function to deactivate RYSC.
25
+ function rysc_deactivate() {
26
+ deactivate_plugins( plugin_basename( RYSC_FILE ) );
27
+ }
28
+
29
+ // And here we have the actual script which removes the Yoast SEO comments.
30
+ function rysc_do() {
31
+ add_action('get_header',function (){
32
+ ob_start(function ($o) {
33
+ return preg_replace('/\n?<.*?yoast.*?>/mi','',$o);
34
+ });
35
+ });
36
+ add_action('wp_head',function (){
37
+ ob_end_flush();
38
+ }, 999);
39
+ }
40
+
41
+ // Bundle the functions and execute if Yoast SEO is not active.
42
+ function rysc_noyoast() {
43
+ add_action( 'admin_notices', 'rysc_notice' );
44
+ add_action( 'admin_init', 'rysc_deactivate' );
45
+ }
readme.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Remove Yoast SEO comments ===
2
+ Contributors: lowest
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2VYPRGME8QELC
4
+ Tags: yoast seo, yoast, seo, remove comments, remove html, remove ads, remove debug code
5
+ Requires at least: 1.2.0
6
+ Stable tag: 1.2.0
7
+ Tested up to: 4.5
8
+
9
+ Removes all the Yoast SEO comments from your front-end source code.
10
+
11
+ == Description ==
12
+
13
+ Are you also annoyed by the HTML comments of the Yoast SEO plugin and do you simply want to get rid of them? This plugin is the perfect solution for you.
14
+
15
+ *Remove Yoast SEO comments* (in short: RYSC) removes all HTML comments coming from the Yoast SEO plugin. RYSC does not make any changes to your Yoast SEO plugin files.
16
+
17
+ Note: This plugin requires [Yoast SEO](http://wordpress.org/plugins/wordpress-seo/). If you do not have Yoast SEO activated, this plugin will not work.
18
+
19
+ == Installation ==
20
+
21
+ 1. Upload the 'remove-yoast-seo-comments' folder to the /wp-content/plugins/ directory
22
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
23
+ 3. All done! The HTML comments are now removed from your front-end source code.
24
+
25
+ == Changelog ==
26
+
27
+ = 1.0 =
28
+ * Initial release
remove-yoast-seo-comments.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Plugin Name: Remove Yoast SEO comments
4
+ * Plugin URI: https://wordpress.org/plugins/remove-yoast-seo-comments/
5
+ * Description: Removes all the Yoast SEO comments from your front-end source code.
6
+ * Version: 1.0
7
+ * Author: Mitch
8
+ * Author URI: https://profiles.wordpress.org/lowest
9
+ * License: GPL-2.0+
10
+ */
11
+
12
+ // Exit if accessed directly.
13
+ if ( ! defined( 'ABSPATH' ) ) { exit; }
14
+
15
+ // Define current path to RYSC.
16
+ if ( ! defined( 'RYSC_FILE' ) ) { define( 'RYSC_FILE', __FILE__ ); }
17
+
18
+ // Request all functions.
19
+ require_once( dirname( RYSC_FILE ) . '/functions.php' );
20
+
21
+ // Check if Yoast SEO is active. If so, then proceed.
22
+ // If not, show a error and deactivate RYSC.
23
+ if ( rysc_active( 'wordpress-seo/wp-seo.php' ) ) {
24
+ rysc_do();
25
+ } else {
26
+ rysc_noyoast();
27
+ }
28
+
29
+ // Add the donate button.
30
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), function($link) {
31
+ return array_merge( $link, array('<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2VYPRGME8QELC" target="_blank">Donate</a>') );
32
+ } );