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

Access wordpress on Console #819

Open
ancient-spirit opened this issue Jul 17, 2021 · 0 comments
Open

Access wordpress on Console #819

ancient-spirit opened this issue Jul 17, 2021 · 0 comments
Labels

Comments

@ancient-spirit
Copy link

Hi @jlambe ,

I think we can make a console that load wordpress if we explicit inherit the class.
The example below is perfect combined with the console stub generator by @tipytechnique on the PR with small adjustment

The parent class that load wordpress:

<?php

namespace Themosis\Core\Console;

use Illuminate\Console\Command;

class WordPress extends Command
{
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
        require_once web_path('cms/wp-load.php');
    }
}

And our custom command:

<?php

namespace App\Console\Commands\WordPress;

use Themosis\Core\Console\WordPress;

class PullProduct extends WordPress
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $signature = 'wordpress:pull-product';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'pull published product from erp';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        dd(get_users());
        return 0;
    }
}

Originally posted by @oxyrealm-dev in #706 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant