本文整理匯總了PHP中WP_CLI::get_root_command方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_CLI::get_root_command方法的具體用法?PHP WP_CLI::get_root_command怎麽用?PHP WP_CLI::get_root_command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WP_CLI
的用法示例。
在下文中一共展示了WP_CLI::get_root_command方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: completions
/**
* Generate tab completion strings.
*/
function completions()
{
foreach (WP_CLI::get_root_command()->get_subcommands() as $name => $command) {
$subcommands = $command->get_subcommands();
WP_CLI::line($name . ' ' . implode(' ', array_keys($subcommands)));
}
}
示例2: find_subcommand
private static function find_subcommand($args)
{
$command = \WP_CLI::get_root_command();
while (!empty($args) && $command && $command->can_have_subcommands()) {
$command = $command->find_subcommand($args);
}
return $command;
}
示例3: find_command_to_run
/**
* Given positional arguments, find the command to execute.
*
* @param array $args
* @return array|string Command, args, and path on success; error message on failure
*/
public function find_command_to_run($args)
{
$command = \WP_CLI::get_root_command();
$cmd_path = array();
while (!empty($args) && $command->can_have_subcommands()) {
$cmd_path[] = $args[0];
$full_name = implode(' ', $cmd_path);
$subcommand = $command->find_subcommand($args);
if (!$subcommand) {
return sprintf("'%s' is not a registered wp command. See 'wp help'.", $full_name);
}
if ($this->is_command_disabled($subcommand)) {
return sprintf("The '%s' command has been disabled from the config file.", $full_name);
}
$command = $subcommand;
}
return array($command, $args, $cmd_path);
}
示例4: cmd_dump
/**
* Dump the list of installed commands, as JSON.
*
* @subcommand cmd-dump
*/
public function cmd_dump()
{
echo json_encode(self::command_to_array(WP_CLI::get_root_command()));
}