• Resolved Kyle Taylor

    (@kyletaylored)


    There is a function in the plugin.php __construct method for check_if_blocksy_is_activated(), and at the top of that function is a check to see if the request is coming from WPCLI:

    public function check_if_blocksy_is_activated() {
      if (defined('WP_CLI') && WP_CLI) {
        return false;
      }

    When coming from WPCLI, the check fails, which then fails to run the following init hook, which includes the loading of the WPCLI commands:

    // Fails here, does not continue.
    if (! $this->check_if_blocksy_is_activated()) {
      return;
    }
    
    $this->early_init_with_blocksy_theme();
    
    // This init loads the WPCLI commands, but is never reached.
    add_action('init', [$this, 'init'], 0);

    Commenting out the if (defined('WP_CLI')... code then allows the WP CLI commands to be registered and available to use. I would recommend this snippet get removed, and then also add annotations for how the WP CLI commands work.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author creativethemeshq

    (@creativethemeshq)

    Hi Kyle,

    Appreciate your input!

    Sure thing, we will get this fixed in the next update. It certainly wasn’t our intention to get the CLI commands to not get registered at all.

    At the moment, the main commands are the wp blocksy demo * commands, which allow you to install a starter site using the WP CLI. We will certainly add more instructions on how to use them.

    In a few words, you have to run them in a specific order (I know there’s no way you could have known that from our instructions) but we deliberately made it this way. We made it work like this because each next step in the process depends on the previous one being executed & its output being loaded in the current env (download & activate a plugin, for example). Doing that in one simple command is not so easy, unless we involve dispatching sub-processes so that with each step the WP gets booted anew.

    We will do our best to make it as explicit as possible.

    Are you trying to automate something?

    Thanks again!

    Kind regards,
    Andrei

    Thread Starter Kyle Taylor

    (@kyletaylored)

    Actually, yes! ?? I did figure out the order, at least something that seems to successfully run. I work as a sales engineer, and part of that is running demos or building proof-of-concepts, so sometimes I need to spin up a quick WordPress demo with more content than just the default install. Right now, I pass wpcli commands through a PHP script (could also use a CI/CD system) to install the demo. This is just an abstract, but gets the point across.

    // Choose demo and builder. For Gutenberg, leave $builder empty.
    $demo_name = 'Tasty';
    $builder = 'elementor';
    
    // Import data into WordPress
    echo "Importing demo template...\n";
    $demo = $demo_name . ' ' . $builder;
    echo "Installing demo: " . $demo . "\n";
    passthru("wp blocksy demo clean");
    passthru("wp blocksy demo import:start " . $demo);
    passthru("wp blocksy demo import:plugins " . $demo);
    passthru("wp blocksy demo import:options " . $demo);
    passthru("wp blocksy demo import:widgets " . $demo);
    passthru("wp blocksy demo import:content " . $demo);
    passthru("wp blocksy demo import:finish");
    echo "Import complete.\n";

    Ideally it would be just one command like wp blocksy demo import --demo-name="Tasty" --builder="elementor"

    Plugin Author creativethemeshq

    (@creativethemeshq)

    Yes, that’s the order of the steps pretty much!

    Seems like the WP_CLI::runcommand() is exactly what we need to compose this — it runs the separate commands in sub-processes, which is exactly what we’re looking for (hopefully this is cross-platform too).

    Will try to play with it and hopefully we’ll release a combined command too. Watch out for our changelog please, we’ll make sure to reference it there as soon as it’s ready. With or without the combined command, the update from this week will have the above described fix for the theme check.

    Thanks again for your feedback!

    Thread Starter Kyle Taylor

    (@kyletaylored)

    Awesome! I’d love to contribute if there’s an easy way for me to do that. I dove into the CLI class the other day, so I could probably help get those annotations added, and test combining the WPCLI commands. Feel free to reach out directly if there’s a developer repo somewhere outside of SVN.

    Plugin Author creativethemeshq

    (@creativethemeshq)

    We pushed out yesterday a new update with the fix for the WP CLI check and also some better readme annotations for the available commands.
    In the next one we’ll be aiming for pushing the combined command for installing a starter site.

    We’ll be reaching out to you for give you a way to beta test what we’re building.

    Thanks again for bringing this up!

    I am using version 2.0.47 and still WP does not work.

    I want to be able to activate the plugin using command line and install a theme how should I do?

    Plugin Author creativethemeshq

    (@creativethemeshq)

    @martinkst please let us know what WP CLI commands you are trying to execute and what error you are getting and we will make sure to check everything and provide relevant fixes where needed.

    Plugin Author creativethemeshq

    (@creativethemeshq)

    Hi @martinkst, this is a friendly reminder ??

    Please get back to us with more details so we could be able to understand your problem and provide a solution.

    Have a good day!

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