1. Go to this page and download the library: Download highliuk/wordpress-command library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
highliuk / wordpress-command example snippets
use Highliuk\WordPressCommand\Command;
/**
* Greets the blog with its name.
*/
class HelloBlog extends Command
{
protected function handle(): void
{
$name = get_bloginfo('name');
$this->line("Hello, $name!");
}
}
use Highliuk\WordPressCommand\Application;
$app = Application::getInstance();
$app->add(new HelloBlog());
use Highliuk\WordPressCommand\Command;
class HelloBlog extends Command
{
protected $name = 'greet:blog';
protected $description = 'Greets the blog with its name.';
protected function handle(): void
{
$name = get_bloginfo('name');
$this->line("Hello, $name!");
}
}
use Highliuk\WordPressCommand\Command;
class HelloBlog extends Command
{
protected function configure(): void
{
$this->setName('greet:blog');
}
protected function handle(): void
{
$name = get_bloginfo('name');
$this->line("Hello, $name!");
}
}
use Highliuk\WordPressCommand\Command;
use Symfony\Component\Console\Input\InputArgument;
class GreetUser extends Command
{
protected function configure(): void
{
$this
->addArgument('user', InputArgument::REQUIRED, 'The user to greet')
->addOption('uppercase', 'u', 'Whether to uppercase the user name');
}
protected function handle(string $user, bool $uppercase): void
{
if ($uppercase) {
$user = strtoupper($user);
}
$this->line("Hello, $user!");
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.