• Resolved agualtierimdn

    (@agualtierimdn)


    Hello,
    I encountered a fatal error while using the ghl-wizard plugin on WordPress.
    The issue happens because the plugin loads several files (including contacts.php) directly from apis.php during plugin initialization.

    This results in the following fatal error:

    PHP Fatal error: Uncaught Error: Call to a member function using_index_permalinks() on null
    in /wp-includes/rest-api.php

    The require_once calls inside apis.php are executed too early, before WordPress finishes initializing $wp_rewrite and the REST API. This breaks functions like get_rest_url() when called during wp_head().

    I resolved the issue by wrapping the require_once calls inside an init action, like this:

    add_action(‘init’, function() {
    require_once DIR . ‘/get-token.php’;
    require_once DIR . ‘/get-tags.php’;
    require_once DIR . ‘/get-campaigns.php’;
    require_once DIR . ‘/get-workflows.php’;
    require_once DIR . ‘/contacts.php’;
    require_once DIR . ‘/get-custom-values.php’;
    require_once DIR . ‘/get-custom-fields.php’;
    });

    This ensures the plugin files are only loaded after WordPress is fully initialized, preventing the fatal error.

    Could you please update the plugin code accordingly in the next release, so that other users don’t run into the same issue?

    Thanks for your support

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor betterwizard

    (@betterwizard)

    Hi @agualtierimdn,
    Thank you for noticing this, we will update it soon.

    Thread Starter agualtierimdn

    (@agualtierimdn)

    I installed version 1.2.20, but the bug is still there.
    You need to use __DIR__, otherwise it won’t work in most cases.
    This is how you do it:

    add_action(‘init’, function() {

    require_once __DIR__ . ‘/get-token.php’;

    require_once __DIR__ . ‘/get-tags.php’;

    require_once __DIR__ . ‘/get-campaigns.php’;

    require_once __DIR__ . ‘/get-workflows.php’;

    require_once __DIR__ . ‘/contacts.php’;

    require_once __DIR__ . ‘/get-custom-values.php’;

    require_once __DIR__ . ‘/get-custom-fields.php’;

    });

    Plugin Contributor betterwizard

    (@betterwizard)

    Hi @agualtierimdn
    Thank you so much! We’ve updated it. It’s a real pleasure to receive fixes from people like you.

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

The topic ‘BUG’ is closed to new replies.