Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP CLI Xcloner_cli.php #289

Open
dbccomm opened this issue Aug 7, 2023 · 0 comments
Open

WP CLI Xcloner_cli.php #289

dbccomm opened this issue Aug 7, 2023 · 0 comments

Comments

@dbccomm
Copy link

dbccomm commented Aug 7, 2023

Running wp cli throws a lot of warning that wp-config.php's defines are already defined..

I added at the top of the wp-config.ini to check who loaded the config again.

if ( defined( 'WP_CLI' ) && WP_CLI ) {
    echo "Loading wp-config.php\n";
    debug_print_backtrace();
}

in the function load_wordpress() it requires wp-load.php

        $wp_load_path = XCLONER_PLUGIN_DIR . '/../../../wp-load.php';
        if (!file_exists($wp_load_path)) {
            throw new Exception('Can\'t find WordPress load file (wp-load.php)');
        }

        require_once($wp_load_path);

So I just added a check if wordpress is already loaded and I stoped having these warnings


    /**
     * @throws Exception
     */
    private function load_wordpress()
    {

        // Check if WordPress is already loaded
        if (defined('ABSPATH')) {
            return;
        }

        $wp_load_path = XCLONER_PLUGIN_DIR . '/../../../wp-load.php';
        if (!file_exists($wp_load_path)) {
            throw new Exception('Can\'t find WordPress load file (wp-load.php)');
        }

        require_once($wp_load_path);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant