当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_CLI::launch方法代码示例

本文整理汇总了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.');
 }
开发者ID:rpeterson,项目名称:wp-cli,代码行数:31,代码来源:core.php

示例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}"));
     }
 }
开发者ID:navitronic,项目名称:wp-cli-1,代码行数:7,代码来源:help.php

示例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']));
 }
开发者ID:humanmade,项目名称:hm-dev,代码行数:30,代码来源:hm-dev.wp-cli.import.php

示例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}"));
         }
     }
 }
开发者ID:netcon-source,项目名称:wp-cli,代码行数:10,代码来源:help.php

示例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);
     }
 }
开发者ID:pixline,项目名称:wp-cli-php-devtools,代码行数:26,代码来源:phpdoc-command.php

示例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);
     }
 }
开发者ID:pixline,项目名称:wp-cli-php-devtools,代码行数:10,代码来源:phpunit-command.php

示例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);
 }
开发者ID:phillprice,项目名称:wp-cli-environment,代码行数:22,代码来源:CommandArguments.php

示例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');
     }
 }
开发者ID:pixline,项目名称:wp-cli-php-devtools,代码行数:12,代码来源:phpdcd-command.php

示例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.');
     }
 }
开发者ID:pixline,项目名称:wp-cli-php-devtools,代码行数:17,代码来源:phpcs-command.php

示例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}"));
         }
     }
 }
开发者ID:nunomorgadinho,项目名称:wp-cli,代码行数:12,代码来源:help.php

示例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));
 }
开发者ID:ptahdunbar,项目名称:wp-cli,代码行数:13,代码来源:core.php

示例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);
         }
     }
 }
开发者ID:livsi,项目名称:wp-deploy-flow,代码行数:13,代码来源:command.php

示例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;
 }
开发者ID:humanmade,项目名称:hm-dev,代码行数:14,代码来源:hm-dev.wp-cli.test.php

示例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);
 }
开发者ID:pixline,项目名称:wp-cli-php-devtools,代码行数:15,代码来源:phpreport-command.php

示例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.");
 }
开发者ID:Olaw2jr,项目名称:wp-posts-to-posts,代码行数:22,代码来源:command.php


注:本文中的WP_CLI::launch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。