Version Description
- Added the option to disable redirection of feed requests (and issue a 404 instead)
Download this release
Release Info
Developer | solarissmoke |
Plugin | Disable Feeds |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.1
- disable-feeds.php +33 -10
- readme.txt +11 -0
- uninstall.php +5 -0
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.
|
7 |
Author: Samir Shah
|
8 |
Author URI: http://rayofsolaris.net/
|
9 |
License: GPLv2 or later
|
@@ -14,28 +14,51 @@ if( !defined( 'ABSPATH' ) )
|
|
14 |
|
15 |
class Disable_Feeds {
|
16 |
function __construct() {
|
17 |
-
if(
|
|
|
|
|
|
|
18 |
add_action( 'wp_loaded', array( $this, 'remove_links' ) );
|
19 |
-
add_filter( '
|
20 |
}
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
function remove_links() {
|
24 |
remove_action( 'wp_head', 'feed_links', 2 );
|
25 |
remove_action( 'wp_head', 'feed_links_extra', 3 );
|
26 |
}
|
27 |
|
28 |
-
function filter_query() {
|
29 |
if( !is_feed() )
|
30 |
return;
|
31 |
|
32 |
-
if(
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
36 |
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
}
|
41 |
|
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
|
7 |
Author: Samir Shah
|
8 |
Author URI: http://rayofsolaris.net/
|
9 |
License: GPLv2 or later
|
14 |
|
15 |
class Disable_Feeds {
|
16 |
function __construct() {
|
17 |
+
if( is_admin() ) {
|
18 |
+
add_action( 'admin_init', array( $this, 'admin_setup' ) );
|
19 |
+
}
|
20 |
+
else {
|
21 |
add_action( 'wp_loaded', array( $this, 'remove_links' ) );
|
22 |
+
add_filter( 'parse_query', array( $this, 'filter_query' ) );
|
23 |
}
|
24 |
}
|
25 |
|
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', array( $this, 'sanitize_settings' ) );
|
29 |
+
}
|
30 |
+
|
31 |
+
function sanitize_settings( $val ) {
|
32 |
+
return (bool) $val;
|
33 |
+
}
|
34 |
+
|
35 |
+
function settings_field() {
|
36 |
+
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, uncheck the box below.</p><p><input type="checkbox" name="disable_feeds_redirect" id="disable_feeds_redirect" class="checkbox" ' . checked( get_option( 'disable_feeds_redirect', true ), true, false ) . '/><label for="disable_feeds_redirect"> Redirect feed requests to corresponding HTML content</label></p>';
|
37 |
+
}
|
38 |
+
|
39 |
function remove_links() {
|
40 |
remove_action( 'wp_head', 'feed_links', 2 );
|
41 |
remove_action( 'wp_head', 'feed_links_extra', 3 );
|
42 |
}
|
43 |
|
44 |
+
function filter_query( $wp_query ) {
|
45 |
if( !is_feed() )
|
46 |
return;
|
47 |
|
48 |
+
if( get_option( 'disable_feeds_redirect', true ) ) {
|
49 |
+
if( isset( $_GET['feed'] ) ) {
|
50 |
+
wp_redirect( remove_query_arg( 'feed' ), 301 );
|
51 |
+
exit;
|
52 |
+
}
|
53 |
|
54 |
+
set_query_var( 'feed', '' ); // redirect_canonical will do the rest
|
55 |
+
redirect_canonical();
|
56 |
+
}
|
57 |
+
else {
|
58 |
+
$wp_query->is_feed = false;
|
59 |
+
$wp_query->set_404();
|
60 |
+
status_header( 404 );
|
61 |
+
}
|
62 |
}
|
63 |
}
|
64 |
|
readme.txt
CHANGED
@@ -19,8 +19,19 @@ If you come across any bugs or have suggestions, please use the plugin support f
|
|
19 |
|
20 |
Feeds are useful if you have regularly updated content (blog posts, comments) on your site, and you want people to be able to subscribe to those updates. If you have static pages, then they aren't, and just add overhead to your site.
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
== Changelog ==
|
23 |
|
|
|
|
|
|
|
24 |
= 1.0 =
|
25 |
* First public release.
|
26 |
|
19 |
|
20 |
Feeds are useful if you have regularly updated content (blog posts, comments) on your site, and you want people to be able to subscribe to those updates. If you have static pages, then they aren't, and just add overhead to your site.
|
21 |
|
22 |
+
= There are still RSS links on my site! =
|
23 |
+
|
24 |
+
This plugin is only able to disable feeds themselves. The links to feeds are generated by your theme, and you will have to edit your theme (or remove the related widgets) to remove those links.
|
25 |
+
|
26 |
+
= What if I don't want to redirect feed requests? =
|
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 =
|
33 |
+
* Added the option to disable redirection of feed requests (and issue a 404 instead)
|
34 |
+
|
35 |
= 1.0 =
|
36 |
* First public release.
|
37 |
|
uninstall.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') )
|
3 |
+
exit;
|
4 |
+
|
5 |
+
delete_option( 'disable_feeds_redirect' );
|