예제 #1
0
파일: help.php 프로젝트: roelven/wp-cli
    private function general_help()
    {
        WP_CLI::line('Available commands:');
        foreach (WP_CLI::load_all_commands() as $command => $class) {
            if ('help' == $command) {
                continue;
            }
            $out = "    wp {$command}";
            $methods = WP_CLI_Command::get_subcommands($class);
            if (!empty($methods)) {
                $out .= ' [' . implode('|', $methods) . ']';
            }
            WP_CLI::line($out);
        }
        WP_CLI::line(<<<EOB

See 'wp help <command>' for more information on a specific command.

Global parameters:
    --user=<id|login>   set the current user
    --url=<url>         set the current URL
    --path=<path>       set the current path to the WP install
    --require=<path>    load a certain file before running the command
    --quiet             suppress informational messages
    --version           print wp-cli version
EOB
);
    }
예제 #2
0
파일: wp-cli.php 프로젝트: bytewang/wp-cli
    if (isset($GLOBALS['wp_query']) && isset($GLOBALS['wp'])) {
        $GLOBALS['wp']->parse_request();
        $GLOBALS['wp_query']->query($GLOBALS['wp']->query_vars);
    }
}
// Set the user
if (isset($assoc_args['user'])) {
    $user = $assoc_args['user'];
    if (is_numeric($user)) {
        $user_id = (int) $user;
    } else {
        $user_id = (int) username_exists($user);
    }
    if (!$user_id || !wp_set_current_user($user_id)) {
        WP_CLI::error(sprintf('Could not get a user_id for this user: %s', var_export($user, true)));
    }
    unset($user);
}
// Set filesystem method
add_filter('filesystem_method', function () {
    return 'direct';
}, 99);
// Handle --completions parameter
if (isset($assoc_args['completions'])) {
    WP_CLI::load_all_commands();
    foreach (WP_CLI::$commands as $name => $command) {
        WP_CLI::line($name . ' ' . implode(' ', WP_CLI_Command::get_subcommands($command)));
    }
    exit;
}
WP_CLI::run_command($arguments, $assoc_args);
예제 #3
0
 function get_subcommands()
 {
     return \WP_CLI::load_all_commands();
 }
예제 #4
0
파일: wp-cli.php 프로젝트: rpeterson/wp-cli
// Set filesystem method
add_filter('filesystem_method', function () {
    return 'direct';
}, 99);
// Handle --user parameter
if (isset($assoc_args['user'])) {
    $user = $assoc_args['user'];
    if (is_numeric($user)) {
        $user_id = (int) $user;
    } else {
        $user_id = (int) username_exists($user);
    }
    if (!$user_id || !wp_set_current_user($user_id)) {
        WP_CLI::error(sprintf('Could not get a user_id for this user: %s', var_export($user, true)));
    }
    unset($assoc_args['user'], $user);
}
// Handle --require parameter
if (isset($assoc_args['require'])) {
    require $assoc_args['require'];
    unset($assoc_args['require']);
}
// Generate strings for autocomplete
if (WP_CLI_AUTOCOMPLETE) {
    foreach (WP_CLI::load_all_commands() as $name => $command) {
        $subcommands = implode(' ', WP_CLI_Command::get_subcommands($command));
        WP_CLI::line($name . ' ' . $subcommands);
    }
    exit;
}
WP_CLI::run_command($arguments, $assoc_args);