• Resolved Kevin Burkholder

    (@kevinburkholder)


    Call to undefined method WP_CONSENT_API_COOKIE_INFO::has_cookie_info()

    When calling wp_set_cookie(),
    – wp_set_cookie calls wp_has_cookie_info(),
    – wp_has_cookie_info calls WP_CONSENT_API::$cookie_info->has_cookie_info()

    WP_CONSENT_API::$cookie_info->has_cookie_info() DOES NOT EXIST.

    Secondly, WP_CONSENT_API isn’t instantiated until ‘plugins_loaded’ making it unusable until then.

    add_action( ‘plugins_loaded’, array( WP_CONSENT_API::class, ‘get_instance’ ), 9 );

    Why not instantiate when it loads? (there may well be a good reason)

    Thanks for you attention and help!

Viewing 1 replies (of 1 total)
  • Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    @kevinburkholder sorry for my late response, vacation came in the way.

    In general I think it’s best to call WordPress functionality on a WordPress hook: that ensures that all functions are loaded. So in this case, you could run your code on an ‘init’ or ‘plugins_loaded’ hook, which should solve your issue.

    For this reason I always hook the instantiation of my code into the plugins_loaded hook. Using priority 9 ensures that if any code runs on the plugins_loaded hook with default priority (10), everything is already loaded. It also ensures that the WP Consent API in turn also can call all WordPress functions, as we may assume it’s all loaded now.

    Hope this explains!

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.