當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。