I see no way to fix this other than to modify the code. The offending call to is_feed() is done right when the plugin class is created. That’s why just activating the plugin creates the error. Obviously I can remove that check for is_feed(). I’m sure that won’t negatively impact the plugin, but it will call the minification utility for each hit to the RSS feed.
There has to be a better way to filter on when the minification should occur, but I’ve not written plugins like this to have a good suggestion. Other than the generic suggestion to go ahead and add the init and wp_footer actions, but then check for is_feed() in those functions and bail out. I’m not 100% sure is_feed() can be called in init, though, without literally testing it.
function WPMinify() {
// initialize common functions
$this->c = new WPMinifyCommon($this);
// load translation
$this->c->load_text_domain();
// register admin scripts
add_action('admin_init', array($this->c, 'a_register_scripts'));
add_action('admin_init', array($this->c, 'a_register_styles'));
// check wp version
add_action('admin_head', array($this->c, 'a_check_version'));
// load admin menu
add_action('admin_menu', array($this, 'a_menu'));
// register ajax handler
add_action('wp_ajax_wpm', array($this, 'a_ajax_handler'));
// No need to minify admin stuff
if (!is_admin() && !is_feed() && !defined('XMLRPC_REQUEST')) {
// Don't minify if if user passes wp-minify-off=1 in GET parameter
if (!(isset($_GET['wp-minify-off']) && $_GET['wp-minify-off'])) {
add_action('init', array($this, 'pre_content'), 99999);
add_action('wp_footer', array($this, 'post_content'), 99999);
}
// advertise hook
add_action('wp_footer', array($this, 'advertise'));
}
}
Ok, that works perfectly. It would be great if you could update the plugin. Get rid of the call to is_feed() where it is. TRN are my initials, so this is how I “mod mark” adds and deletes
// No need to minify admin stuff
//TRN:DEL if (!is_admin() && !is_feed() && !defined('XMLRPC_REQUEST')) {
if (!is_admin() && !defined('XMLRPC_REQUEST')) { //TRN:ADD
Then add the check in function pre_content() and post_content() like this:
function pre_content() {
if ( is_feed() ) return; //TRN:ADD
$wpm_options = get_option($this->name);
if ($wpm_options['uri_exclude'] && count($wpm_options['uri_exclude'])) {
foreach ($wpm_options['uri_exclude'] as $exclude_pat) {
$exclude_pat = trim($exclude_pat);
if (strlen($exclude_pat) > 0 && strpos($_SERVER['REQUEST_URI'], $exclude_pat) !== false) {
return;
}
}
}
function post_content() {
if ( is_feed() ) return; //TRN:ADD
// sanity checking
if ($this->buffer_started) {
ob_end_flush();
}
}
I’m surprised this error doesn’t happen for everyone using the plugin. I guess maybe most people don’t have a test site or don’t have errors turned on.