Beispiel #1
0
 /**
  * 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.");
 }
Beispiel #2
0
 /**
  * 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;
     }
 }
Beispiel #3
0
 /**
  * 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;
     }
 }