• Resolved michaelm89

    (@michaelm89)


    hello,
    after activating rankmath on pages where woocommerce is turned off there is an error

    Fatal error: Uncaught Error: Call to undefined function is_cart()
    in public_html/wp-content/plugins/seo-by-rank-math/includes/class-post.php on line 176

    maybe you know how to solve it?
    thanks!

    • This topic was modified 5 years, 3 months ago by michaelm89.
    • This topic was modified 5 years, 3 months ago by michaelm89.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Jose Mortellaro

    (@giuse)

    Hi @michaelm89

    Probably RankMath checks if another plugin is active looking in the WordPress core option ‘active_plugins’. This is not the best way because another plugin (in this case Freesoul Deactivate Plugins) may filter the output of that option.
    It would be better to check if a plugin is active by checking if one of its classes or functions exists. Better checking the function that they are going to use in their code.

    In this case, it would be better they wrap their code in something that looks like:

    if( function_exists( ‘is_cart’ ) ){
    //their code
    }

    You should write to the support of Rank Math.

    You should ask if they can modify their code in a way that if a third plugin filters the output of the option ‘active_plugins’ their function that depends on third plugins doesn’t trigger any fatal error.

    Until they don’t check their code, you could add this code to solve the problem:

    if( !function_exists( 'is_cart' ) && defined( 'EOS_WOOCOMMERCE_ACTIVE' ) ){
      function is_cart(){
        return false;
      }
    }

    if the constant EOS_WOOCOMMERCE_ACTIVE is defined it means FDP has disabled WooCommerce on that page, and if is_cart doesn’t exist, your code will give that function returning false (if WooCommerce is not active it’s surely not a cart page).
    Put the code above in a functional plugin that is active on the page where you have problems, or in the functions.php of your child theme if any.

    Let me know if it helps. But please open a ticket also with RankMath, or if you prefer it, I can open it myself, because also other users may have the same problem.

    Thread Starter michaelm89

    (@michaelm89)

    I will be grateful if you can open it. you will certainly describe the problem better than I do.
    thank you for your quick answer πŸ™‚

    Plugin Author Jose Mortellaro

    (@giuse)

    You are welcome. I’ve created the thread, you can follow it here: https://ww.wp.xz.cn/support/topic/fatal-error-if-woocommerce-disabled-only-on-a-specific-page/

    Thread Starter michaelm89

    (@michaelm89)

    thanks!

    Plugin Author Jose Mortellaro

    (@giuse)

    You are welcome @michaelm89

    Do you confirm it works now? If so I will close this thread.

    Thread Starter michaelm89

    (@michaelm89)

    hello,
    still waiting for rankmath update πŸ™‚

    Plugin Author Jose Mortellaro

    (@giuse)

    Hi @michaelm89

    RankMath v 1.0.59 should solve the issue. Let me know if it works now.

    Thread Starter michaelm89

    (@michaelm89)

    hello,
    now everything works great, thank you for your support!

    Plugin Author Jose Mortellaro

    (@giuse)

    Hi @michaelm89
    You are welcome! Thank you very much for the confirmation!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Rankmath’ is closed to new replies.