本文整理汇总了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.");
}
示例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('…', '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;
}
}
示例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;
}
}