Skip to content

Commit

Permalink
Add filter for feed_links_show_comments_feed introduced in WP 4.4. Fixes
Browse files Browse the repository at this point in the history
 #11.
  • Loading branch information
solarissmoke committed Apr 29, 2016
1 parent 92cac30 commit ad6c86e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions disable-comments-mu.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Disable Comments (Must Use version)
Plugin URI: https://github.com/solarissmoke/disable-comments-mu
Description: Disables all WordPress comment functionality on the entire network.
Version: 1.1.1
Version: 1.1.2
Author: Samir Shah
Author URI: http://rayofsolaris.net/
License: GPL2
Expand Down Expand Up @@ -61,6 +61,9 @@ function setup_filters(){
// remove comment count from feed
add_filter('get_comments_number', '__return_false', 10, 2);

// Remove feed link from header
add_filter( 'feed_links_show_comments_feed', '__return_false' );

// run when wp_head executes
add_action('wp_head', array( $this, 'before_wp_head' ), 0 );
}
Expand Down Expand Up @@ -152,14 +155,16 @@ function disable_rc_widget() {

function before_wp_head( $args = array() ) {
// if wp_head feed_links has not been tampered with (WP 4.1.1)
if (has_action('wp_head', 'feed_links') == 2) {
// In WP > 4.4 the feed_links_show_comments_feed filter is used instead.
if ( version_compare( $GLOBALS['wp_version'], '4.4', '<' ) && has_action( 'wp_head', 'feed_links' ) == 2 ) {
// replace it with a modified version
remove_action( 'wp_head', 'feed_links', 2 );
add_action( 'wp_head', array( $this, 'feed_links' ) );
}
}

// replaces feed_links function, WP 4.1.1
// Not required after WP 4.4
function feed_links( $args = array() ) {
if ( !current_theme_supports('automatic-feed-links') )
return;
Expand Down

0 comments on commit ad6c86e

Please sign in to comment.