本文整理汇总了PHP中WP_CLI::launch方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::launch方法的具体用法?PHP WP_CLI::launch怎么用?PHP WP_CLI::launch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_CLI
的用法示例。
在下文中一共展示了WP_CLI::launch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: download
/**
* Download the core files from wordpress.org
*/
public function download($args, $assoc_args)
{
if (is_readable(WP_ROOT . 'wp-load.php')) {
WP_CLI::error('WordPress files seem to already be present here.');
}
if (isset($assoc_args['path'])) {
$docroot = $assoc_args['path'];
} else {
$docroot = './';
}
if (isset($assoc_args['locale'])) {
exec('curl -s ' . escapeshellarg('https://api.wordpress.org/core/version-check/1.5/?locale=' . $assoc_args['locale']), $lines, $r);
if ($r) {
exit($r);
}
$download_url = str_replace('.zip', '.tar.gz', $lines[2]);
WP_CLI::line(sprintf('Downloading WordPress %s (%s)...', $lines[3], $lines[4]));
} elseif (isset($assoc_args['version'])) {
$download_url = 'https://wordpress.org/wordpress-' . $assoc_args['version'] . '.tar.gz';
WP_CLI::line(sprintf('Downloading WordPress %s (%s)...', $assoc_args['version'], 'en_US'));
} else {
$download_url = 'https://wordpress.org/latest.tar.gz';
WP_CLI::line(sprintf('Downloading latest WordPress (%s)...', 'en_US'));
}
WP_CLI::launch('curl -f' . (WP_CLI_QUIET ? ' --silent ' : ' ') . escapeshellarg($download_url) . ' | tar xz');
WP_CLI::launch('mv wordpress/* . && rm -rf wordpress');
WP_CLI::success('WordPress downloaded.');
}
示例2: maybe_load_man_page
private static function maybe_load_man_page($args)
{
$man_file = \WP_CLI\Man\get_path($args);
if (is_readable($man_file)) {
exit(WP_CLI::launch("man {$man_file}"));
}
}
示例3: uploads
public function uploads($command = array(), $args = array())
{
if (count($command) == 1 && reset($command) == 'help') {
return $this->uploads_help();
}
$dir = wp_upload_dir();
$defaults = array('ssh_host' => defined('IMPORT_UPLOADS_SSH_HOST') ? IMPORT_UPLOADS_SSH_HOST : '', 'ssh_user' => defined('IMPORT_UPLOADS_SSH_USER') ? IMPORT_UPLOADS_SSH_USER : '', 'remote_path' => defined('IMPORT_UPLOADS_REMOTE_PATH') ? IMPORT_UPLOADS_REMOTE_PATH : '', 'uploads_dir' => '', 'local_path' => $dir['basedir']);
$args = wp_parse_args($args, $defaults);
if ($args['uploads_dir']) {
$args['remote_path'] = $args['remote_path'] ? trailingslashit($args['remote_path']) . trailingslashit(ltrim($args['uploads_dir'], '/')) : '';
$args['local_path'] = trailingslashit($args['local_path']) . untrailingslashit(ltrim($args['uploads_dir'], '/'));
} else {
$args['remote_path'] = $args['remote_path'] ? trailingslashit($args['remote_path']) : '';
$args['local_path'] = untrailingslashit($args['local_path']);
}
if (empty($args['remote_path'])) {
WP_CLI::error('You must specify a remote path. Use --remote_path=~/foo/bar');
return;
}
if (empty($args['ssh_host'])) {
WP_CLI::error('You must specify a ssh host. Use --ssh_host=example.com');
return;
}
if (empty($args['ssh_user'])) {
WP_CLI::error('You must specify a ssh user. Use --ssh_user=root');
return;
}
WP_CLI::line(sprintf('Running rsync from %s:%s to %s', $args['ssh_host'], $args['remote_path'], $args['local_path']));
WP_CLI::launch(sprintf("rsync -avz -e ssh %s@%s:%s %s --exclude 'cache' --exclude '*backup*'", $args['ssh_user'], $args['ssh_host'], $args['remote_path'], $args['local_path']));
}
示例4: maybe_load_man_page
private static function maybe_load_man_page($args)
{
$man_file = \WP_CLI\Man\get_file_name($args);
foreach (\WP_CLI::get_man_dirs() as $dest_dir => $_) {
$man_path = $dest_dir . $man_file;
if (is_readable($man_path)) {
exit(WP_CLI::launch("man {$man_path}"));
}
}
}
示例5: run
/**
* Run PHP Documentor
*
* ## OPTIONS
*
* <folder>
* : Folder to generate
*
* ## EXAMPLES
*
* wp phpdoc run folder/
*
* @synopsis <folder>
*
* @since 0.1.0
*/
public function run($args = null, $assoc_args = null)
{
#print_r($assoc_args);
if (null === $args[0]) {
WP_CLI::error('Usage: wp phpdoc run <folder>');
} else {
$cmd = 'phpdoc.php list';
WP_CLI::launch($cmd);
}
}
示例6: _do_plugin
private function _do_plugin($slug, $tests)
{
WP_CLI::line('Doing Plugin ' . $slug);
$plugin_dir = WP_PLUGIN_DIR . '/' . $slug;
if (is_dir($plugin_dir)) {
WP_CLI::launch('export WP_TESTS_DIR=' . $tests . '; cd ' . $plugin_dir . '; phpunit -c phpunit.xml ');
} else {
WP_CLI::error('Can\'t find plugin folder: ' . $plugin_dir);
}
}
示例7: __invoke
/**
* Execute WP-CLI against configuration for a given environment
*
* <core>
*
* <download>
*
*
* @when before_wp_load
*/
public function __invoke($args, $assoc_args)
{
global $argv;
try {
$environment = new \ViewOne\WPCLIEnvironment\Environment();
$environment->run($argv[1]);
} catch (Exception $e) {
\WP_CLI::error($e->getMessage());
}
$command = \ViewOne\WPCLIEnvironment\Command::getCommand($args, $assoc_args);
WP_CLI::launch($command);
}
示例8: _run_phpdcd
private function _run_phpdcd($slug, $flags)
{
$plugin_path = WP_PLUGIN_DIR . '/' . $slug;
$theme_path = WP_CONTENT_DIR . '/themes/' . $slug;
if (is_dir($theme_path) && false === is_dir($plugin_path)) {
WP_CLI::launch('phpdcd ' . $flags . $theme_path);
} elseif (is_dir($plugin_path) && false === is_dir($theme_path)) {
WP_CLI::launch('phpdcd ' . $flags . $plugin_path);
} else {
WP_CLI::error('Plugin/theme not found');
}
}
示例9: _run_phpcs
/**
* Verify plugin or theme path, run phpcs when found
*
* @since 0.2.1
*/
private function _run_phpcs($slug, $flags)
{
$plugin_path = WP_PLUGIN_DIR . '/' . $slug;
$theme_path = WP_CONTENT_DIR . '/themes/' . $slug;
if (is_dir($theme_path) && false === is_dir($plugin_path)) {
WP_CLI::launch('phpcs ' . $flags . $theme_path);
} elseif (is_dir($plugin_path) && false === is_dir($theme_path)) {
WP_CLI::launch('phpcs ' . $flags . $plugin_path);
} else {
WP_CLI::error('No theme or plugin with that slug.');
}
}
示例10: maybe_load_man_page
private static function maybe_load_man_page($args)
{
$man_dir = WP_CLI_ROOT . "../../../man/";
if (!is_dir($man_dir)) {
WP_CLI::warning("man pages do not seem to be installed.");
} else {
$man_file = $man_dir . implode('-', $args) . '.1';
if (is_readable($man_file)) {
exit(WP_CLI::launch("man {$man_file}"));
}
}
}
示例11: _extract
private static function _extract($tarball, $dest)
{
if (!class_exists('PharData')) {
$cmd = "tar xz --strip-components=1 --directory=%s -f {$tarball}";
WP_CLI::launch(Utils\esc_cmd($cmd, $dest));
return;
}
$phar = new PharData($tarball);
$tempdir = implode(DIRECTORY_SEPARATOR, array(dirname($tarball), basename($tarball, '.tar.gz'), $phar->getFileName()));
$phar->extractTo(dirname($tempdir), null, true);
self::_copy_overwrite_files($tempdir, $dest);
self::_rmdir(dirname($tempdir));
}
示例12: _execute_commands
protected function _execute_commands($commands)
{
if ($this->flags['dry-run']) {
WP_CLI::line('DRY RUN....');
}
foreach ($commands as $command_info) {
list($command, $exit_on_error) = $command_info;
WP_CLI::line($command);
if (!$this->flags['dry-run']) {
WP_CLI::launch($command, $exit_on_error);
}
}
}
示例13: test_for_phpunit
private function test_for_phpunit()
{
if (!@(require_once 'PHPUnit/Autoload.php')) {
WP_CLI::line('%RPHPUnit not found%n, you need to install PHPUnit to use the test command, see https://github.com/humanmade/hm-dev');
WP_CLI::line('Attempting to auto install PHPUnit...');
WP_CLI::launch('pear config-set auto_discover 1');
WP_CLI::launch('sudo pear install pear.phpunit.de/PHPUnit');
if (file_exists(trailingslashit(substr(get_include_path(), 2)) . 'PHPUnit/Autoload.php')) {
WP_CLI::line('%GPHPUnit was auto installed%n, You\'ll need to run the command again.');
}
return false;
}
return true;
}
示例14: _do_commands
private function _do_commands($slug, $path)
{
WP_CLI::success('PHP Copy/Paste Detector: ' . $args[0]);
WP_CLI::launch('wp phpcpd ' . $slug);
WP_CLI::success('PHP CodeSniffer: ' . $args[0]);
WP_CLI::launch('wp phpcs ' . $slug);
WP_CLI::success('PHP Dead Code Detector: ' . $args[0]);
WP_CLI::launch('wp phpdcd ' . $slug);
WP_CLI::success('PHP Lines of Code: ' . $args[0]);
WP_CLI::launch('wp phploc ' . $slug);
WP_CLI::success('PHP Mess Detector: ' . $args[0]);
WP_CLI::launch('wp phpmd ' . $slug);
WP_CLI::success('PHPunit: ' . $args[0]);
WP_CLI::launch('wp phpunit --plugin=' . $slug);
}
示例15: generate_connections
/**
* Generate connections for a specific connection type.
*
* @subcommand generate-connections
* @synopsis <connection-type> [--items]
*/
function generate_connections($args, $assoc_args)
{
list($connection_type) = $args;
$ctype = p2p_type($connection_type);
if (!$ctype) {
WP_CLI::error("'{$connection_type}' is not a registered connection type.");
}
if (isset($assoc_args['items'])) {
foreach (_p2p_extract_post_types($ctype->side) as $ptype) {
$assoc_args = array('post_type' => $ptype);
WP_CLI::launch('wp post generate' . \WP_CLI\Utils\assoc_args_to_str($assoc_args));
}
}
$count = $this->_generate_c($ctype);
WP_CLI::success("Created {$count} connections.");
}