Disable Feeds - Version 1.2

Version Description

  • Added the option to allow the global post and comment feeds.
Download this release

Release Info

Developer solarissmoke
Plugin Icon wp plugin Disable Feeds
Version 1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.2

Files changed (3) hide show
  1. disable-feeds.php +13 -2
  2. readme.txt +9 -0
  3. uninstall.php +2 -1
disable-feeds.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Disable Feeds
4
  Plugin URI: http://wordpress.org/extend/plugins/disable-feeds/
5
  Description: Disable all RSS/Atom feeds on your WordPress site.
6
- Version: 1.1.1
7
  Author: Samir Shah
8
  Author URI: http://rayofsolaris.net/
9
  License: GPLv2 or later
@@ -26,11 +26,14 @@ class Disable_Feeds {
26
  function admin_setup() {
27
  add_settings_field( 'disable_feeds_redirect', 'Disable Feeds Plugin', array( $this, 'settings_field' ), 'reading' );
28
  register_setting( 'reading', 'disable_feeds_redirect' );
 
29
  }
30
 
31
  function settings_field() {
32
  $redirect = $this->redirect_status();
33
- echo '<p>The <em>Disable Feeds</em> plugin is active, and all feed are disabled. By default, all requests for feeds are redirected to the corresponding HTML content. If you want to issue a 404 (page not found) response instead, select the second option below.</p><p><input type="radio" name="disable_feeds_redirect" value="on" id="disable_feeds_redirect_yes" class="radio" ' . checked( $redirect, 'on', false ) . '/><label for="disable_feeds_redirect_yes"> Redirect feed requests to corresponding HTML content</label><br /><input type="radio" name="disable_feeds_redirect" value="off" id="disable_feeds_redirect_no" class="radio" ' . checked( $redirect, 'off', false ) . '/><label for="disable_feeds_redirect_no"> Issue a 404 (page not found) error for feed requests</label></p>';
 
 
34
  }
35
 
36
  function remove_links() {
@@ -42,6 +45,10 @@ class Disable_Feeds {
42
  if( !is_feed() )
43
  return;
44
 
 
 
 
 
45
  if( $this->redirect_status() == 'on' ) {
46
  if( isset( $_GET['feed'] ) ) {
47
  wp_redirect( remove_query_arg( 'feed' ), 301 );
@@ -67,6 +74,10 @@ class Disable_Feeds {
67
  }
68
  return $r;
69
  }
 
 
 
 
70
  }
71
 
72
  new Disable_Feeds();
3
  Plugin Name: Disable Feeds
4
  Plugin URI: http://wordpress.org/extend/plugins/disable-feeds/
5
  Description: Disable all RSS/Atom feeds on your WordPress site.
6
+ Version: 1.2
7
  Author: Samir Shah
8
  Author URI: http://rayofsolaris.net/
9
  License: GPLv2 or later
26
  function admin_setup() {
27
  add_settings_field( 'disable_feeds_redirect', 'Disable Feeds Plugin', array( $this, 'settings_field' ), 'reading' );
28
  register_setting( 'reading', 'disable_feeds_redirect' );
29
+ register_setting( 'reading', 'disable_feeds_allow_main' );
30
  }
31
 
32
  function settings_field() {
33
  $redirect = $this->redirect_status();
34
+ echo '<p>The <em>Disable Feeds</em> plugin is active, By default, all feeds are disabled, and all requests for feeds are redirected to the corresponding HTML content. You can tweak this behaviour below.</p>';
35
+ echo '<p><input type="radio" name="disable_feeds_redirect" value="on" id="disable_feeds_redirect_yes" class="radio" ' . checked( $redirect, 'on', false ) . '/><label for="disable_feeds_redirect_yes"> Redirect feed requests to corresponding HTML content</label><br /><input type="radio" name="disable_feeds_redirect" value="off" id="disable_feeds_redirect_no" class="radio" ' . checked( $redirect, 'off', false ) . '/><label for="disable_feeds_redirect_no"> Issue a Page Not Found (404) error for feed requests</label></p>';
36
+ echo '<p><input type="checkbox" name="disable_feeds_allow_main" value="on" id="disable_feeds_allow_main" ' . checked( $this->allow_main(), true, false ) . '/><label for="disable_feeds_allow_main"> Do not disable the <strong>global post feed</strong> and <strong>global comment feed</strong></label></p>';
37
  }
38
 
39
  function remove_links() {
45
  if( !is_feed() )
46
  return;
47
 
48
+ if( $this->allow_main()
49
+ && ! ( is_singular() || is_archive() || is_date() || is_author() || is_category() || is_tag() || is_tax() || is_search() ) )
50
+ return;
51
+
52
  if( $this->redirect_status() == 'on' ) {
53
  if( isset( $_GET['feed'] ) ) {
54
  wp_redirect( remove_query_arg( 'feed' ), 301 );
74
  }
75
  return $r;
76
  }
77
+
78
+ private function allow_main() {
79
+ return ( get_option( 'disable_feeds_allow_main', 'off' ) == 'on' );
80
+ }
81
  }
82
 
83
  new Disable_Feeds();
readme.txt CHANGED
@@ -11,6 +11,8 @@ Disables all RSS/Atom/RDF feeds on your WordPress site.
11
 
12
  This plugin disables all RSS/Atom/RDF feeds on your site. It is useful if you use WordPress purely as a content management system (and not for blogging). All requests for feeds will be redirected to the corresponding HTML content.
13
 
 
 
14
  If you come across any bugs or have suggestions, please use the plugin support forum or [email me](http://rayofsolaris.net/contact/). I can't fix it if I don't know it's broken! Please check the [FAQ](http://wordpress.org/extend/plugins/disable-feeds/faq/) for common issues.
15
 
16
  == Frequently Asked Questions ==
@@ -27,8 +29,15 @@ This plugin is only able to disable feeds themselves. The links to feeds are gen
27
 
28
  In `Settings -> Reading` you will find an option to turn off redirection and issue a 404 (page not found) response instead.
29
 
 
 
 
 
30
  == Changelog ==
31
 
 
 
 
32
  = 1.1.1 =
33
  * Bugfix: Redirect/404 setting in `Settings -> Reading` did not update properly.
34
 
11
 
12
  This plugin disables all RSS/Atom/RDF feeds on your site. It is useful if you use WordPress purely as a content management system (and not for blogging). All requests for feeds will be redirected to the corresponding HTML content.
13
 
14
+ There are a couple of options to tweak the plugin's behaviour - go to `Settings -> Reading` to see them.
15
+
16
  If you come across any bugs or have suggestions, please use the plugin support forum or [email me](http://rayofsolaris.net/contact/). I can't fix it if I don't know it's broken! Please check the [FAQ](http://wordpress.org/extend/plugins/disable-feeds/faq/) for common issues.
17
 
18
  == Frequently Asked Questions ==
29
 
30
  In `Settings -> Reading` you will find an option to turn off redirection and issue a 404 (page not found) response instead.
31
 
32
+ = What if I want to keep the main post/comment feeds but disable all other feeds? =
33
+
34
+ In `Settings -> Reading` you will find an option to allow global feeds. All other feeds (individual post comments, archives, search, category etc.) will still be disabled.
35
+
36
  == Changelog ==
37
 
38
+ = 1.2 =
39
+ * Added the option to allow the global post and comment feeds.
40
+
41
  = 1.1.1 =
42
  * Bugfix: Redirect/404 setting in `Settings -> Reading` did not update properly.
43
 
uninstall.php CHANGED
@@ -2,4 +2,5 @@
2
  if( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') )
3
  exit;
4
 
5
- delete_option( 'disable_feeds_redirect' );
 
2
  if( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') )
3
  exit;
4
 
5
+ delete_option( 'disable_feeds_redirect' );
6
+ delete_option( 'disable_feeds_allow_main' );