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