Version Description
- Bugfix: Missing global variable caused error when feed URL were set to 404.
Download this release
Release Info
| Developer | solarissmoke |
| Plugin | |
| Version | 1.3.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.2.1 to 1.3.1
- disable-feeds.php +20 -4
- readme.txt +6 -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
|
|
@@ -19,7 +19,7 @@ class Disable_Feeds {
|
|
| 19 |
}
|
| 20 |
else {
|
| 21 |
add_action( 'wp_loaded', array( $this, 'remove_links' ) );
|
| 22 |
-
|
| 23 |
}
|
| 24 |
}
|
| 25 |
|
|
@@ -41,8 +41,10 @@ class Disable_Feeds {
|
|
| 41 |
remove_action( 'wp_head', 'feed_links_extra', 3 );
|
| 42 |
}
|
| 43 |
|
| 44 |
-
function
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
return;
|
| 47 |
|
| 48 |
if( $this->allow_main()
|
|
@@ -57,7 +59,21 @@ class Disable_Feeds {
|
|
| 57 |
|
| 58 |
if( get_query_var( 'feed' ) !== 'old' ) // WP redirects these anyway, and removing the query var will confuse it thoroughly
|
| 59 |
set_query_var( 'feed', '' );
|
|
|
|
| 60 |
redirect_canonical(); // Let WP figure out the appropriate redirect URL.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
}
|
| 62 |
else {
|
| 63 |
$wp_query->is_feed = false;
|
| 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.3.1
|
| 7 |
Author: Samir Shah
|
| 8 |
Author URI: http://rayofsolaris.net/
|
| 9 |
License: GPLv2 or later
|
| 19 |
}
|
| 20 |
else {
|
| 21 |
add_action( 'wp_loaded', array( $this, 'remove_links' ) );
|
| 22 |
+
add_action( 'template_redirect', array( $this, 'filter_feeds' ), 1 );
|
| 23 |
}
|
| 24 |
}
|
| 25 |
|
| 41 |
remove_action( 'wp_head', 'feed_links_extra', 3 );
|
| 42 |
}
|
| 43 |
|
| 44 |
+
function filter_feeds() {
|
| 45 |
+
global $wp_rewrite, $wp_query;
|
| 46 |
+
|
| 47 |
+
if( !is_feed() || is_404() )
|
| 48 |
return;
|
| 49 |
|
| 50 |
if( $this->allow_main()
|
| 59 |
|
| 60 |
if( get_query_var( 'feed' ) !== 'old' ) // WP redirects these anyway, and removing the query var will confuse it thoroughly
|
| 61 |
set_query_var( 'feed', '' );
|
| 62 |
+
|
| 63 |
redirect_canonical(); // Let WP figure out the appropriate redirect URL.
|
| 64 |
+
|
| 65 |
+
// Still here? redirect_canonical failed to redirect, probably because of a filter. Try the hard way.
|
| 66 |
+
$struct = ( !is_singular() && is_comment_feed() ) ? $wp_rewrite->get_comment_feed_permastruct() : $wp_rewrite->get_feed_permastruct();
|
| 67 |
+
$struct = preg_quote( $struct, '#' );
|
| 68 |
+
$struct = str_replace( '%feed%', '(\w+)?', $struct );
|
| 69 |
+
$struct = preg_replace( '#/+#', '/', $struct );
|
| 70 |
+
$requested_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
| 71 |
+
$new_url = preg_replace( '#' . $struct . '/?$#', '', $requested_url );
|
| 72 |
+
|
| 73 |
+
if( $new_url != $requested_url ) {
|
| 74 |
+
wp_redirect( $new_url, 301 );
|
| 75 |
+
exit;
|
| 76 |
+
}
|
| 77 |
}
|
| 78 |
else {
|
| 79 |
$wp_query->is_feed = false;
|
readme.txt
CHANGED
|
@@ -35,6 +35,12 @@ In `Settings -> Reading` you will find an option to allow global feeds. All othe
|
|
| 35 |
|
| 36 |
== Changelog ==
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
= 1.2.1 =
|
| 39 |
* Bugfix: Old WordPress feed URLs were not being redirected.
|
| 40 |
|
| 35 |
|
| 36 |
== Changelog ==
|
| 37 |
|
| 38 |
+
= 1.3.1 =
|
| 39 |
+
* Bugfix: Missing global variable caused error when feed URL were set to 404.
|
| 40 |
+
|
| 41 |
+
= 1.3 =
|
| 42 |
+
* More robust feed redirection. In some rare cases, WordPress fails to automatically redirect the user to the parent content. If this happens, the plugin now attempts a redirect by parsing the URL and removing the feed portion manually. Most installations will not be affected.
|
| 43 |
+
|
| 44 |
= 1.2.1 =
|
| 45 |
* Bugfix: Old WordPress feed URLs were not being redirected.
|
| 46 |
|
