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


PHP WP_CLI::compose_args方法代码示例

本文整理汇总了PHP中WP_CLI::compose_args方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::compose_args方法的具体用法?PHP WP_CLI::compose_args怎么用?PHP WP_CLI::compose_args使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_CLI的用法示例。


在下文中一共展示了WP_CLI::compose_args方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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) {
             $command = array('wp', 'post', 'generate');
             $assoc_args = array('post_type' => $ptype);
             WP_CLI::launch(WP_CLI::compose_args($command, $assoc_args));
         }
     }
     $count = $this->_generate_c($ctype);
     WP_CLI::success("Created {$count} connections.");
 }
开发者ID:hscale,项目名称:webento,代码行数:23,代码来源:command.php

示例2: install

 /**
  * Install a new plugin
  *
  * @param array $args
  * @param array $assoc_args
  */
 function install($args, $assoc_args)
 {
     if (empty($args)) {
         WP_CLI::line("usage: wp plugin install <plugin-name>");
         exit;
     }
     $name = $args[0];
     // Force WordPress to update the plugin list
     wp_update_plugins();
     // Get plugin info from the WordPress servers
     $api = plugins_api('plugin_information', array('slug' => stripslashes($name)));
     if (!$api) {
         WP_CLI::error('Can\'t find the plugin in the WordPress.org plugins repository.');
         exit;
     }
     $status = install_plugin_install_status($api);
     WP_CLI::line('Installing ' . $api->name . ' (' . $api->version . ')');
     // Check what to do
     switch ($status['status']) {
         case 'update_available':
         case 'install':
             if (!class_exists('Plugin_Upgrader')) {
                 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
             }
             // Install the plugin
             ob_start('strip_tags');
             $upgrader = new Plugin_Upgrader(new CLI_Upgrader_Skin());
             $result = $upgrader->install($api->download_link);
             $feedback = ob_get_clean();
             if ($result) {
                 WP_CLI::line();
                 WP_CLI::line(strip_tags(str_replace(array('&#8230;', 'Plugin installed successfully.'), array("...\n", ''), html_entity_decode($feedback))));
                 WP_CLI::success('The plugin is successfully installed');
                 if (isset($assoc_args['activate'])) {
                     system("wp plugin activate " . WP_CLI::compose_args($args, $assoc_args));
                 }
             }
             break;
         case 'newer_installed':
             WP_CLI::error(sprintf('Newer version ( %s ) installed', $status['version']));
             break;
         case 'latest_installed':
             WP_CLI::error('Latest version already installed');
             break;
     }
 }
开发者ID:netconstructor,项目名称:wp-cli,代码行数:52,代码来源:plugin.php

示例3: install

 /**
  * Install a new plugin
  *
  * @param array $args
  * @param array $assoc_args
  */
 function install($args, $assoc_args)
 {
     if (empty($args)) {
         WP_CLI::line("usage: wp plugin install <plugin-name>");
         exit;
     }
     $slug = stripslashes($args[0]);
     // Force WordPress to update the plugin list
     wp_update_plugins();
     $api = plugins_api('plugin_information', array('slug' => $slug));
     if (!$api) {
         WP_CLI::error('Can\'t find the plugin in the WordPress.org plugins repository.');
         exit;
     }
     if (isset($assoc_args['dev'])) {
         list($link) = explode($slug, $api->download_link);
         $api->download_link = $link . $slug . '.zip';
         $api->version = 'Development Version';
     }
     $status = install_plugin_install_status($api);
     WP_CLI::line(sprintf('Installing %s (%s)', $api->name, $api->version));
     switch ($status['status']) {
         case 'update_available':
         case 'install':
             $upgrader = WP_CLI::get_upgrader('Plugin_Upgrader');
             $result = $upgrader->install($api->download_link);
             if ($result) {
                 if (isset($assoc_args['activate'])) {
                     system("wp plugin activate " . WP_CLI::compose_args($args, $assoc_args));
                 }
             }
             break;
         case 'newer_installed':
             WP_CLI::error(sprintf('Newer version (%s) installed', $status['version']));
             break;
         case 'latest_installed':
             WP_CLI::error('Latest version already installed');
             break;
     }
 }
开发者ID:bytewang,项目名称:wp-cli,代码行数:46,代码来源:plugin.php


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