當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_CLI::load_all_commands方法代碼示例

本文整理匯總了PHP中WP_CLI::load_all_commands方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_CLI::load_all_commands方法的具體用法?PHP WP_CLI::load_all_commands怎麽用?PHP WP_CLI::load_all_commands使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WP_CLI的用法示例。


在下文中一共展示了WP_CLI::load_all_commands方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: general_help

    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
);
    }
開發者ID:roelven,項目名稱:wp-cli,代碼行數:28,代碼來源:help.php

示例2: username_exists

    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);
開發者ID:bytewang,項目名稱:wp-cli,代碼行數:31,代碼來源:wp-cli.php

示例3: get_subcommands

 function get_subcommands()
 {
     return \WP_CLI::load_all_commands();
 }
開發者ID:nunomorgadinho,項目名稱:wp-cli,代碼行數:4,代碼來源:dispatcher.php

示例4: add_filter

// 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);
開發者ID:rpeterson,項目名稱:wp-cli,代碼行數:31,代碼來源:wp-cli.php


注:本文中的WP_CLI::load_all_commands方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。