本文整理汇总了PHP中WP_CLI::check_required_args方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::check_required_args方法的具体用法?PHP WP_CLI::check_required_args怎么用?PHP WP_CLI::check_required_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_CLI
的用法示例。
在下文中一共展示了WP_CLI::check_required_args方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
if (!is_readable(WP_ROOT . 'wp-load.php')) {
WP_CLI::error('This does not seem to be a WordPress install. Pass --path=`path/to/wordpress` or run `wp core download`.');
}
if (array('core', 'config') == $arguments) {
WP_CLI::run_command($arguments, $assoc_args);
exit;
}
// The db commands don't need any WP files
if (array('db') == array_slice($arguments, 0, 1)) {
WP_CLI::load_wp_config();
WP_CLI::run_command($arguments, $assoc_args);
exit;
}
// Set installer flag before loading any WP files
if (array('core', 'install') == $arguments) {
WP_CLI::check_required_args(array('url', 'title', 'admin_email', 'admin_password'), $assoc_args);
define('WP_INSTALLING', true);
}
// Load WordPress
require WP_ROOT . 'wp-load.php';
// Fix memory limit. See http://core.trac.wordpress.org/ticket/14889
@ini_set('memory_limit', -1);
require ABSPATH . 'wp-admin/includes/admin.php';
// Load the right info into the global wp_query
if (!defined('WP_INSTALLING') && isset($assoc_args['url'])) {
if (isset($GLOBALS['wp_query']) && isset($GLOBALS['wp'])) {
$GLOBALS['wp']->parse_request();
$GLOBALS['wp_query']->query($GLOBALS['wp']->query_vars);
}
}
// Set filesystem method
示例2: install_network
public function install_network($args, $assoc_args)
{
if (is_multisite()) {
WP_CLI::error('This already is a multisite install.');
}
global $wpdb;
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
// need to register the multisite tables manually for some reason
foreach ($wpdb->tables('ms_global') as $table => $prefixed_table) {
$wpdb->{$table} = $prefixed_table;
}
WP_CLI::check_required_args(array('title'), $assoc_args);
extract(wp_parse_args($assoc_args, array('base' => '/')));
$hostname = self::get_clean_basedomain();
$subdomain_install = isset($assoc_args['subdomains']);
install_network();
$result = populate_network(1, $hostname, get_option('admin_email'), $assoc_args['title'], $base, $subdomain_install);
if (is_wp_error($result)) {
WP_CLI::error($result);
}
ob_start();
?>
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', <?php
echo $subdomain_install ? 'true' : 'false';
?>
);
$base = '<?php
echo $base;
?>
';
define('DOMAIN_CURRENT_SITE', '<?php
echo $hostname;
?>
');
define('PATH_CURRENT_SITE', '<?php
echo $base;
?>
');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
<?php
$ms_config = ob_get_clean();
$wp_config_path = WP_CLI::locate_wp_config();
$token = "/* That's all, stop editing!";
list($before, $after) = explode($token, file_get_contents($wp_config_path));
file_put_contents($wp_config_path, $before . $ms_config . $token . $after);
wp_mkdir_p(WP_CONTENT_DIR . '/blogs.dir');
WP_CLI::success("Network installed. Don't forget to set up rewrite rules.");
}