Am I Ever False?!

This is a really great one, not because the code itself is bad, but because the logic of this is non existent.

The problem with this code is that the developer setup a conditional statement to determine if a filter should be applied or not, and then apply a different set of filters if the conditional is false, but . . . he used if( true ).

Why’s that a problem? Because it’s always true, no matter what. It is not possible for the other filters to ever get applied.

class regions {
    static function initialize()
    {
        // We need to process the_content as early as possible, to be sure that DOM tree identical to edited one
        // Also, function accept 2 arguments, so when needed we can supply exact regions to apply
        if ( !is_admin() ) { // We don't want to run this on the backend
            if (true) { // until apply_filter use current()/next()
                add_filter('the_content', array(self::instance(), 'content_split_join'), -99991, 2);
            } else {
                // Use split/join to proceed every piece independently
                add_filter('the_content', array(self::instance(), 'content_split'), -99991, 2);
                add_filter('the_content', array(self::instance(), 'content_join'), +99991);
            }
        }
    }
}

Submitted by Eric Mann.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s