• Hi,
    This plugin is still working for me and I find it very useful, to say the least. I wish it would stay alive for as long as a similar functionality hasn’t been added to the WordPress core. So here’s my (humble) contribution. I’m assuming this is the best place to post it. If not, anyone feel free to move it.

    I’ve been checking a new site on debug mode lately, and my local server (WampServer Version 2.5, on PHP 5.5.12) sent me three notices related to Smarter Navigation. Here they are:

    Strict standards: Non-static method Smarter_Navigation::read_cookie() should not be called statically in C:\wamp\www\wp-content\plugins\smarter-navigation\main.php on line 30

    Strict standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Smarter_Navigation::manage_cookie() should not be called statically in C:\wamp\www\wp-includes\plugin.php on line 496

    Strict standards: Non-static method Smarter_Navigation::init() should not be called statically in C:\wamp\www\wp-content\plugins\smarter-navigation\main.php on line 240

    Please note that these are notices, not fatal errors, and it won’t stop the plugin from working. I supose that depending on the version of PHP you are currently using, it’s possible that you don’t see them at all. If you do however, it could cause some problems in the future, as well as interfere with some setups. Long story short: it’s not too good.

    Here are the fixes I figured out to get rid of the warnings. I’m not terribly good with PHP and I can’t guarantee this is best way to go about it. I just hope that’s a reasonably clean way.

    Change:

    function manage_cookie() {
    		// Default conditions
    		$clear_condition = false;
    		$read_condition = is_singular();
    		$set_condition = !is_404();
    
    		if ( apply_filters( 'smarter_nav_clear', $clear_condition ) )
    			self::clear_cookie();
    		elseif ( apply_filters( 'smarter_nav_read', $read_condition ) )
    			self::read_cookie();
    		elseif ( apply_filters( 'smarter_nav_set', $set_condition ) )
    			self::set_cookie();
    	}

    to:

    public static function manage_cookie() {
    		// Default conditions
    		$clear_condition = false;
    		$read_condition = is_singular();
    		$set_condition = !is_404();
    		$var = new self();
    
    		if ( apply_filters( 'smarter_nav_clear', $clear_condition ) )
    			$var->clear_cookie();
    		elseif ( apply_filters( 'smarter_nav_read', $read_condition ) )
    			$var->read_cookie();
    		elseif ( apply_filters( 'smarter_nav_set', $set_condition ) )
    			$var->set_cookie();
    	}

    And then Change:

    Smarter_Navigation::init();

    to:

    $var = new Smarter_Navigation();
    $var->init();

    That’s all folks!

    https://wordpress.org/plugins/smarter-navigation/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Non-static method should not be called statically’ is closed to new replies.