本文整理汇总了PHP中wp_install函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_install函数的具体用法?PHP wp_install怎么用?PHP wp_install使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_install函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: installWordPress
/**
* Create a new WordPress website from scratch
*
* @Given /^\w+ have a vanilla wordpress installation$/
*/
public function installWordPress(TableNode $table = null)
{
global $wp_rewrite;
$name = "admin";
$email = "[email protected]";
$password = "test";
$username = "admin";
if ($table) {
$hash = $table->getHash();
$row = $hash[0];
$name = $row["name"];
$username = $row["username"];
$email = $row["email"];
$password = $row["password"];
}
$mysqli = new \Mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$value = $mysqli->multi_query(implode("\n", array("DROP DATABASE IF EXISTS " . DB_NAME . ";", "CREATE DATABASE " . DB_NAME . ";")));
\PHPUnit_Framework_Assert::assertTrue($value);
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
wp_install($name, $username, $email, true, '', $password);
//This is a bit of a hack, we don't care about the notification e-mails here so clear the inbox
//we run the risk of deleting stuff we want!
$this->inboxFactory->getInbox($email)->clearInbox();
$wp_rewrite->init();
$wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
}
开发者ID:stephenharris,项目名称:WordPressBehatExtension,代码行数:31,代码来源:WordPressContext.php
示例2: install
/**
* Run wp_install. Assumes that wp-config.php is already in place.
*/
public function install($args, $assoc_args)
{
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
if (is_blog_installed()) {
WP_CLI::error('WordPress is already installed.');
}
extract(wp_parse_args($assoc_args, array('site_url' => defined('WP_SITEURL') ? WP_SITEURL : '', 'site_title' => '', 'admin_name' => 'admin', 'admin_email' => '', 'admin_password' => '')), EXTR_SKIP);
$missing = false;
foreach (array('site_url', 'site_title', 'admin_email', 'admin_password') as $required_arg) {
if (empty(${$required_arg})) {
WP_CLI::warning("missing --{$required_arg} parameter");
$missing = true;
}
}
if ($site_url) {
WP_CLI::set_url_params($site_url);
}
if ($missing) {
exit(1);
}
$public = true;
$result = wp_install($site_title, $admin_name, $admin_email, $public, '', $admin_password);
if (is_wp_error($result)) {
WP_CLI::error('Installation failed (' . WP_CLI::errorToString($result) . ').');
} else {
WP_CLI::success('WordPress installed successfully.');
}
}
开发者ID:bytewang,项目名称:wp-cli,代码行数:31,代码来源:core.php
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$env = Validators::validateEnv($input->getOption('env'));
$_SERVER['DOCUMENT_ROOT'] = getcwd();
$_SERVER['SERVER_PROTOCOL'] = 'http';
$_SERVER['HTTP_HOST'] = $this->skeleton->get('deploy.%s.web.host', $env);
define('WP_ROOT', $this->skeleton->getWebRoot() . '/');
define('WP_INSTALLING', true);
require WP_ROOT . 'wp-load.php';
require WP_ROOT . 'wp-admin/includes/admin.php';
require WP_ROOT . 'wp-admin/includes/upgrade.php';
if (is_blog_installed()) {
$output->writeln('<error>Already installed.</error>');
return 1;
}
$output->write('Installing...');
$result = wp_install($this->skeleton->get('name'), $this->skeleton->get('wordpress.%s.admin.user', $env), $this->skeleton->get('wordpress.%s.admin.email', $env), true, '', $this->skeleton->get('wordpress.%s.admin.password', $env));
if (is_wp_error($result)) {
throw new \Exception($result);
}
update_option('db_version', $wp_db_version);
update_option('db_upgraded', true);
$output->writeln('<info>DONE</info>');
$output->writeln(sprintf("\nLogin as <info>%s</info> with the password <info>%s</info>", $this->skeleton->get('wordpress.%s.admin.user', $env), $this->skeleton->get('wordpress.%s.admin.password', $env)));
}
开发者ID:ericclemmons,项目名称:wordpress-generator,代码行数:25,代码来源:InstallWordPressCommand.php
示例4: installDatabase
public static function installDatabase(array $data, $directory, ConsoleLogger $logger)
{
// need for wordpress database functionality
global $wpdb;
if (!isset($data['blog_title'])) {
$logger->log(LogLevel::NOTICE, 'Skipping step due to missing blog configuration');
return true;
}
define('WP_INSTALLING', true);
require_once self::path($directory, 'wp-config.php');
// require_once self::path($directory, 'includes', 'wp-db.php';
require_once self::path($directory, 'wp-admin', 'upgrade-functions.php');
if (!function_exists('wp_install')) {
$logger->log(LogLevel::WARNING, 'Could not find function "wp_install" in file "' . self::path($directory, 'wp-admin', 'includes', 'upgrade.php"'));
}
if (isset($data['password'])) {
$logger->log(LogLevel::INFO, 'Using password: ' . $data['password']);
$result = wp_install($data['blog_title'], $data['admin'], $data['admin_email'], true, '', $data['password']);
} else {
$result = wp_install($data['blog_title'], $data['admin'], $data['admin_email'], true);
}
if ($result) {
$logger->log(LogLevel::INFO, 'Wordpress successfully installed. Password is ' . $result['password']);
} else {
$logger->log(LogLevel::WARNING, 'Unexpected error occured during this step');
}
return $result;
}
开发者ID:secondtruth,项目名称:builder,代码行数:28,代码来源:WordpressInstaller.php
示例5: admin_init
/**
* admin_init action hook operations
* Checks for wordpress_reset post value and if there deletes all wp tables
* and performs an install, populating the users previous password also
*/
public function admin_init()
{
global $current_user;
$wordpress_reset = isset($_POST['wordpress_reset']) && $_POST['wordpress_reset'] == 'true' ? true : false;
$wordpress_reset_confirm = isset($_POST['wordpress_reset_confirm']) && $_POST['wordpress_reset_confirm'] == 'reset' ? true : false;
$valid_nonce = isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'wordpress_reset') ? true : false;
if ($wordpress_reset && $wordpress_reset_confirm && $valid_nonce) {
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
$blogname = get_option('blogname');
$admin_email = get_option('admin_email');
$blog_public = get_option('blog_public');
if ($current_user->user_login != 'admin') {
$user = get_user_by('login', 'admin');
}
if (empty($user->user_level) || $user->user_level < 10) {
$user = $current_user;
}
global $wpdb, $reactivate_wp_reset_additional;
$prefix = str_replace('_', '\\_', $wpdb->prefix);
$tables = $wpdb->get_col("SHOW TABLES LIKE '{$prefix}%'");
foreach ($tables as $table) {
$wpdb->query("DROP TABLE {$table}");
}
$result = wp_install($blogname, $user->user_login, $user->user_email, $blog_public);
extract($result, EXTR_SKIP);
$query = $wpdb->prepare("UPDATE {$wpdb->users} SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $user->user_pass, $user_id);
$wpdb->query($query);
$get_user_meta = function_exists('get_user_meta') ? 'get_user_meta' : 'get_usermeta';
$update_user_meta = function_exists('update_user_meta') ? 'update_user_meta' : 'update_usermeta';
if ($get_user_meta($user_id, 'default_password_nag')) {
$update_user_meta($user_id, 'default_password_nag', false);
}
if ($get_user_meta($user_id, $wpdb->prefix . 'default_password_nag')) {
$update_user_meta($user_id, $wpdb->prefix . 'default_password_nag', false);
}
if (defined('REACTIVATE_WP_RESET') && REACTIVATE_WP_RESET === true) {
activate_plugin(plugin_basename(__FILE__));
}
if (!empty($reactivate_wp_reset_additional)) {
foreach ($reactivate_wp_reset_additional as $plugin) {
$plugin = plugin_basename($plugin);
if (!is_wp_error(validate_plugin($plugin))) {
activate_plugin($plugin);
}
}
}
wp_clear_auth_cookie();
wp_set_auth_cookie($user_id);
wp_redirect(admin_url() . '?reset');
exit;
}
if (array_key_exists('reset', $_GET) && stristr($_SERVER['HTTP_REFERER'], 'wordpress-reset')) {
add_action('admin_notices', array(&$this, 'reset_notice'));
}
}
开发者ID:sdxlgc,项目名称:net-wp_sdgcxl-htdocs,代码行数:60,代码来源:wordpress-reset.php
示例6: wp_reset_init
/**
* Handles the admin page functionality
*
* @access public
* @uses wp_install Located in includes/upgrade.php (line 22)
*/
function wp_reset_init()
{
global $wpdb, $current_user, $pagenow;
// Grab the WordPress database tables
$this->_wp_tables = $wpdb->tables();
// Check for valid input - goes ahead and drops / resets tables
if (isset($_POST['wp-random-value'], $_POST['wp-reset-input']) && $_POST['wp-random-value'] == $_POST['wp-reset-input'] && check_admin_referer('wp-nonce-submit', $this->_nonce)) {
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
// No tables were selected
if (!isset($_POST['tables']) && empty($_POST['tables'])) {
wp_redirect(admin_url($pagenow) . '?page=wp-reset&reset=no-select');
exit;
}
// Get current options
$blog_title = get_option('blogname');
$public = get_option('blog_public');
$admin_user = get_user_by('login', 'admin');
$user = !$admin_user || !user_can($admin_user->ID, 'update_core') ? $current_user : $admin_user;
// Get the selected tables
$tables = isset($_POST['tables']) ? array_flip($_POST['tables']) : array();
// Compare the selected tables against the ones in the database
$this->_tables = array_diff_key($this->_wp_tables, $tables);
// Preserve the data from the tables that are unique
if (0 < count($this->_tables)) {
$backup_tables = $this->_backup_tables($this->_tables);
}
// Grab the currently active plugins
if (isset($_POST['wp-reset-check']) && 'true' == $_POST['wp-reset-check']) {
$active_plugins = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM {$wpdb->options} WHERE option_name = %s", 'active_plugins'));
}
// Run through the database columns, drop all the tables and
// install wp with previous settings
if ($db_tables = $wpdb->get_col("SHOW TABLES LIKE '{$wpdb->prefix}%'")) {
foreach ($db_tables as $db_table) {
$wpdb->query("DROP TABLE {$db_table}");
}
$keys = wp_install($blog_title, $user->user_login, $user->user_email, $public);
$this->_wp_update_user($user, $keys);
}
// Delete and replace tables with the backed up table data
if ($backup_tables) {
foreach ($this->_tables as $table) {
$wpdb->query("DELETE FROM " . $table);
}
$this->_backup_tables($backup_tables, 'reset');
}
if (!empty($active_plugins)) {
$wpdb->update($wpdb->options, array('option_value' => $active_plugins), array('option_name' => 'active_plugins'));
wp_redirect(admin_url($pagenow) . '?page=wp-reset&reset=success');
exit;
}
wp_redirect(admin_url());
exit;
}
}
开发者ID:sangpena,项目名称:appflex.mobi,代码行数:61,代码来源:wp-reset.php
示例7: install
/**
* Run wp_install. Assumes that wp-config.php is already in place.
*/
public function install($args, $assoc_args)
{
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
if (is_blog_installed()) {
WP_CLI::error('WordPress is already installed.');
}
extract(wp_parse_args($assoc_args, array('title' => '', 'admin_name' => 'admin', 'admin_email' => '', 'admin_password' => '')), EXTR_SKIP);
$public = true;
$result = wp_install($title, $admin_name, $admin_email, $public, '', $admin_password);
if (is_wp_error($result)) {
WP_CLI::error('Installation failed (' . WP_CLI::error_to_string($result) . ').');
} else {
WP_CLI::success('WordPress installed successfully.');
}
}
开发者ID:rpeterson,项目名称:wp-cli,代码行数:18,代码来源:core.php
示例8: ctl_wp_install
/** preforms default wordpress install, which create database tables and add default values */
function ctl_wp_install()
{
define('WP_INSTALLING', true);
$blog_title = BLOG_TITLE;
$admin_name = CTL_USER;
$admin_email = ADM_EMAIL;
$public = true;
$deprecated = '';
$admin_password = ADM_CREDS;
$language = '';
wp_install($blog_title, $admin_name, $admin_email, (int) $public, $deprecated, $CTLUserData['password'], $language);
update_option('template', WP_DEFAULT_THEME);
update_option('stylesheet', WP_DEFAULT_THEME);
define('WP_INSTALLING', false);
}
开发者ID:CenturyLinkCloud,项目名称:wp-CloudWordPressTemplate,代码行数:16,代码来源:CTL-Check.php
示例9: installWordPress
/**
* Create a new WordPress website from scratch
*
* @Given /^\w+ have|has a vanilla wordpress installation$/
*/
public function installWordPress(TableNode $table = null)
{
$name = "admin";
$email = "[email protected]";
$password = "test";
$username = "admin";
if ($table) {
$row = $table->getHash()[0];
$name = $row["name"];
$username = $row["username"];
$email = $row["email"];
$password = $row["password"];
}
$mysqli = new \Mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$value = $mysqli->multi_query(implode("\n", array("DROP DATABASE IF EXISTS " . DB_NAME . ";", "CREATE DATABASE " . DB_NAME . ";")));
assertTrue($value);
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
wp_install($name, $username, $email, true, '', $password);
}
开发者ID:mackensen,项目名称:WordPressExtension,代码行数:24,代码来源:WordPressContext.php
示例10: installWordPress
/**
* Create a new WordPress website from scratch
*
* @Given /^\w+ have|has a vanilla wordpress installation$/
*/
public function installWordPress(TableNode $table = null)
{
global $wp_rewrite;
$name = "admin";
$email = "[email protected]";
$password = "test";
$username = "admin";
if ($table) {
$hash = $table->getHash();
$row = $hash[0];
$name = $row["name"];
$username = $row["username"];
$email = $row["email"];
$password = $row["password"];
}
$mysqli = new \Mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$value = $mysqli->multi_query(implode("\n", array("DROP DATABASE IF EXISTS " . DB_NAME . ";", "CREATE DATABASE " . DB_NAME . ";")));
assertTrue($value);
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
wp_install($name, $username, $email, true, '', $password);
$wp_rewrite->init();
$wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
}
开发者ID:kwaters12,项目名称:WordPressBehatExtension,代码行数:28,代码来源:WordPressContext.php
示例11: resetwp
/**
* reset wp learn from plugin wordpress-reset
* @param $args
* @param $assoc_args
*/
public function resetwp($args, $assoc_args)
{
global $current_user, $user_id;
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
$blogname = get_option('blogname');
$admin_email = get_option('admin_email');
$blog_public = get_option('blog_public');
if ($current_user->user_login != 'admin') {
$user = get_user_by('login', 'admin');
}
if (empty($user->user_level) || $user->user_level < 10) {
$user = $current_user;
}
global $wpdb, $reactivate_wp_reset_additional;
$prefix = str_replace('_', '\\_', $wpdb->prefix);
$tables = $wpdb->get_col("SHOW TABLES LIKE '{$prefix}%'");
foreach ($tables as $table) {
$wpdb->query("DROP TABLE {$table}");
}
$result = wp_install($blogname, $user->user_login, $user->user_email, $blog_public);
extract($result, EXTR_SKIP);
$query = $wpdb->prepare("UPDATE {$wpdb->users} SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $user->user_pass, $user_id);
$wpdb->query($query);
$get_user_meta = function_exists('get_user_meta') ? 'get_user_meta' : 'get_usermeta';
$update_user_meta = function_exists('update_user_meta') ? 'update_user_meta' : 'update_usermeta';
if ($get_user_meta($user_id, 'default_password_nag')) {
$update_user_meta($user_id, 'default_password_nag', false);
}
if ($get_user_meta($user_id, $wpdb->prefix . 'default_password_nag')) {
$update_user_meta($user_id, $wpdb->prefix . 'default_password_nag', false);
}
if (defined('REACTIVATE_WP_RESET') && REACTIVATE_WP_RESET === true) {
@activate_plugin(plugin_basename(__FILE__));
}
if (!empty($reactivate_wp_reset_additional)) {
foreach ($reactivate_wp_reset_additional as $plugin) {
$plugin = plugin_basename($plugin);
if (!is_wp_error(validate_plugin($plugin))) {
@activate_plugin($plugin);
}
}
}
wp_clear_auth_cookie();
wp_set_auth_cookie($user_id);
wp_redirect(admin_url() . '?reset');
//exit();
$this->result('Reset WP successful.');
}
开发者ID:hoangsoft90,项目名称:hw-hoangweb-plugin,代码行数:53,代码来源:module-cli.php
示例12: gd_quicksetup_reset_db
/**
* Reset the database back to pristine condition
* Reset the blog name / privacy setting
* Reactivate our plugin, and whatever other plugins are caught in the filter
* Save the db salts (to prevent loggint he user out)
* Save the users (all non-subscribers)
* Remove the default password nag (it isn't the default pw, it's just a clean DB)
* Log the user back in
* @filter gd_quick_setup_reactivate_plugins
* @global mixed $wpdb
* @global mixed $current_user
*/
function gd_quicksetup_reset_db()
{
global $wpdb, $current_user;
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
// Uncache
wp_cache_flush();
if (function_exists('wp_cache_init')) {
$GLOBALS['__wp_object_cache'] = $GLOBALS['wp_object_cache'];
$GLOBALS['wp_object_cache'] = new GD_QuickSetup_ObjectCache();
}
// Don't send out the "your new WordPress site" e-mail
add_filter('wp_mail', 'gd_quicksetup_cancel_new_site_email');
// Save the blog options
$blogname = get_option('blogname');
$blog_public = get_option('blog_public');
// Save the plugins
$active_plugins = apply_filters('gd_quick_setup_reactivate_plugins', array());
$tmp = array();
foreach ($active_plugins as $plugin) {
if (is_plugin_active($plugin)) {
$tmp[] = $plugin;
}
}
$active_plugins = $tmp;
// Save the salts
$logged_in_salt = get_site_option('logged_in_salt');
$auth_salt = get_site_option('auth_salt');
// Save the admin user
if ($current_user->user_login != 'admin') {
$user = get_user_by('login', 'admin');
}
if (!isset($user) || $user->user_level < 10) {
$user = $current_user;
}
// Save additional users
$users = array();
foreach (get_users() as $_user) {
if ($_user->ID == $user->ID) {
continue;
}
if (user_can($_user, 'edit_posts')) {
$users[] = $_user;
}
}
// Nuke the DB
$prefix = str_replace('_', '\\_', $wpdb->prefix);
$tables = $wpdb->get_col("SHOW TABLES LIKE '{$prefix}%'");
foreach ($tables as $table) {
$wpdb->query("DROP TABLE {$table}");
}
// Reinstall
$result = wp_install($blogname, $user->user_login, $user->user_email, $blog_public);
extract($result, EXTR_SKIP);
// Re-insert the admin user
$query = $wpdb->prepare("UPDATE {$wpdb->users} SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $user->user_pass, $user->ID);
$wpdb->query($query);
// Reset the salts
update_site_option('logged_in_salt', $logged_in_salt);
update_site_option('auth_salt', $auth_salt);
// Disable the "you're using the default password" message
if (get_user_meta($user->ID, 'default_password_nag')) {
update_user_meta($user->ID, 'default_password_nag', false);
}
if (get_user_meta($user->ID, $wpdb->prefix . 'default_password_nag')) {
update_user_meta($user->ID, $wpdb->prefix . 'default_password_nag', false);
}
// Re-insert the other users && disable the "you're using the default password" message
foreach ($users as $_user) {
$_user_id = wp_insert_user(array('user_login' => $_user->user_login, 'user_pass' => $_user->user_pass, 'user_email' => $_user->user_email));
if (is_wp_error($_user_id)) {
continue;
}
$query = $wpdb->prepare("UPDATE {$wpdb->users} SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $_user->user_pass, $_user_id);
$wpdb->query($query);
update_user_meta($_user_id, $wpdb->prefix . 'capabilities', $_user->caps);
update_user_meta($_user_id, $wpdb->prefix . 'user_level', gd_quicksetup_translate_role_level($_user));
if (get_user_meta($_user_id, 'default_password_nag')) {
update_user_meta($_user_id, 'default_password_nag', false);
}
if (get_user_meta($_user_id, $wpdb->prefix . 'default_password_nag')) {
update_user_meta($_user_id, $wpdb->prefix . 'default_password_nag', false);
}
}
// Reset the salts
update_site_option('logged_in_salt', $logged_in_salt);
update_site_option('auth_salt', $auth_salt);
// Remove sample content
wp_delete_comment(1, true);
//.........这里部分代码省略.........
开发者ID:IDOAgency,项目名称:PAHClinic,代码行数:101,代码来源:reset-db.php
示例13: _install
private function _install($assoc_args)
{
if (is_blog_installed()) {
return false;
}
if (true === \WP_CLI\Utils\get_flag_value($assoc_args, 'skip-email') && !function_exists('wp_new_blog_notification')) {
function wp_new_blog_notification()
{
// Silence is golden
}
}
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
extract(wp_parse_args($assoc_args, array('title' => '', 'admin_user' => '', 'admin_email' => '', 'admin_password' => '')), EXTR_SKIP);
// Support prompting for the `--url=<url>`,
// which is normally a runtime argument
if (isset($assoc_args['url'])) {
WP_CLI::set_url($assoc_args['url']);
}
$public = true;
// @codingStandardsIgnoreStart
if (!is_email($admin_email)) {
WP_CLI::error("The '{$admin_email}' email address is invalid.");
}
$result = wp_install($title, $admin_user, $admin_email, $public, '', $admin_password);
if (is_wp_error($result)) {
WP_CLI::error('Installation failed (' . WP_CLI::error_to_string($result) . ').');
}
// @codingStandardsIgnoreEnd
if (!empty($GLOBALS['wpdb']->last_error)) {
WP_CLI::error('Installation produced database errors, and may have partially or completely failed.');
}
// Confirm the uploads directory exists
$upload_dir = wp_upload_dir();
if (!empty($upload_dir['error'])) {
WP_CLI::warning($upload_dir['error']);
}
return true;
}
开发者ID:Faisalawanisee,项目名称:wp-cli,代码行数:38,代码来源:core.php
示例14: define
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
require_once ABSPATH . '/wp-includes/wp-db.php';
define('WP_TESTS_VERSION_FILE', ABSPATH . '.wp-tests-version');
$wpdb->suppress_errors();
$wpdb->hide_errors();
$installed = $wpdb->get_var("SELECT option_value FROM {$wpdb->options} WHERE option_name = 'siteurl'");
if ($installed && file_exists(WP_TESTS_VERSION_FILE)) {
$installed_version_hash = file_get_contents(WP_TESTS_VERSION_FILE);
if ($installed_version_hash == test_version_check_hash()) {
return;
}
}
$wpdb->query('SET storage_engine = INNODB;');
$wpdb->query('DROP DATABASE IF EXISTS ' . DB_NAME . ";");
$wpdb->query('CREATE DATABASE ' . DB_NAME . ";");
$wpdb->select(DB_NAME, $wpdb->dbh);
echo "Installing Awesome Support…" . PHP_EOL;
wp_install(WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, '', 'a');
if (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE) {
echo "Installing network…" . PHP_EOL;
define('WP_INSTALLING_NETWORK', true);
//wp_set_wpdb_vars();
// We need to create references to ms global tables to enable Network.
foreach ($wpdb->tables('ms_global') as $table => $prefixed_table) {
$wpdb->{$table} = $prefixed_table;
}
install_network();
$result = populate_network(1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, WP_TESTS_NETWORK_TITLE, '/', WP_TESTS_SUBDOMAIN_INSTALL);
system(WP_PHP_BINARY . ' ' . escapeshellarg(dirname(__FILE__) . '/ms-install.php') . ' ' . escapeshellarg($config_file_path));
}
file_put_contents(WP_TESTS_VERSION_FILE, test_version_check_hash());
开发者ID:f4bsch,项目名称:Awesome-Support,代码行数:31,代码来源:install.php
示例15: _install
function _install()
{
define('WP_INSTALLING', true);
$this->load_wp_core();
$result = wp_install($this->data["config"]["site_title"], $this->data["config"]["username"], $this->data["config"]["email"], (int) $this->data["config"]["blog_public"], "", $this->data["config"]["password"]);
if (!$result['password']) {
$this->error[] = $result['password_message'];
return;
}
}
开发者ID:pravdomil,项目名称:WP-Quick-Install,代码行数:10,代码来源:wp-quick-install.php
示例16: wp_reset_init
/**
* Handles the admin page functionality
*
* @access public
* @uses wp_install Located in includes/upgrade.php (line 22)
*/
function wp_reset_init() {
global $wpdb, $current_user, $pagenow;
// Grab the WordPress database tables
$this->_wp_tables = $wpdb->tables();
// Check for valid input - goes ahead and drops / resets tables
if ( isset( $_POST['wp-random-value'], $_POST['wp-reset-input'] ) && $_POST['wp-random-value'] == $_POST['wp-reset-input']
&& check_admin_referer( 'wp-nonce-submit', $this->_nonce ) ) {
require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
// No tables were selected
if ( empty( $_POST['tables'] ) ) {
wp_redirect( admin_url( $pagenow ) . '?page=wp-reset&reset=no-select' );
exit();
}
// Get current options
$blog_title = get_option( 'blogname' );
$public = get_option( 'blog_public' );
$admin_user = get_user_by( 'login', 'admin' );
$user = ( ! $admin_user || ! user_can( $admin_user->ID, 'update_core' ) ) ? $current_user : $admin_user;
// Get the selected tables
$tables = ( isset( $_POST['tables'] ) ) ? array_flip( $_POST['tables'] ) : array();
// Compare the selected tables against the ones in the database
$this->_tables = array_diff_key( $this->_wp_tables, $tables );
// Preserve the data from the tables that are unique
if ( 0 < count( $this->_tables ) ) {
$backup_tables = $this->_back_up_tables( $this->_tables );
}
// Grab the currently active plugins and theme
if ( ! empty($_POST['wp-reset-check']) ) {
$current_data = array(
'active-plugins' => get_option( 'active_plugins' ),
'current-theme' => get_option( 'current_theme' ),
'template' => get_option( 'template' ),
'stylesheet' => get_option( 'stylesheet' )
);
}
// Run through the database columns, drop all the tables and
// install wp with previous settings
if ( ! empty( $this->_wp_tables ) ) {
foreach ( $this->_wp_tables as $wp_table ) {
$wpdb->query( "DROP TABLE {$wp_table}" );
}
$keys = wp_install( $blog_title, $user->user_login, $user->user_email, $public );
$this->_wp_update_user( $user, $keys );
}
// Delete and replace tables with the backed up table data
if ( ! empty( $backup_tables ) ) {
foreach ( $this->_tables as $table ) {
$wpdb->query( "DELETE FROM " . $table );
}
$this->_restore_tables( $backup_tables );
}
if ( get_user_meta( $current_user->ID, 'session_tokens' ) ) {
delete_user_meta( $current_user->ID, 'session_tokens' );
}
wp_clear_auth_cookie();
wp_set_auth_cookie( $current_user->ID );
if ( ! empty( $current_data ) ) {
update_option( 'active_plugins', $current_data['active-plugins'] );
if ( ! empty( $current_data['current-theme'] ) ) {
update_option( 'current_theme', $current_data['current-theme'] );
}
update_option( 'template', $current_data['template'] );
update_option( 'stylesheet', $current_data['stylesheet'] );
wp_redirect( admin_url( $pagenow ) . '?page=wp-reset&reset=success' );
exit();
}
wp_redirect( admin_url() );
exit();
}
}
开发者ID:acutedeveloper,项目名称:carepoint-development,代码行数:95,代码来源:wp-reset.php
示例17: wp_install_wp
/**
* Instale et configure WordPress sur le serveur local dans le dossier courant
*
* @param mixed[] $opts informations d'inscription du compte admin Wordpress
*
* @return bool true|false
*/
public function wp_install_wp($opts)
{
define('WP_INSTALLING', true);
require_once 'wp-load.php';
require_once 'wp-admin/includes/upgrade.php';
require_once 'wp-includes/wp-db.php';
// WordPress installation
wp_install($opts['weblog_title'], $opts['user_login'], $opts['admin_email'], (int) $opts['blog_public'], '', $opts['admin_password']);
// We update the options with the right siteurl et homeurl value
$newurl = 'http://' . $_SERVER['SERVER_NAME'] . rtrim(dirname($_SERVER['REQUEST_URI']), '/');
update_option('siteurl', $newurl);
update_option('home', $newurl);
update_option('permalink_structure', '/%postname%/');
return TRUE;
}
开发者ID:Aigleblanc,项目名称:wp-migration-url,代码行数:22,代码来源:migration.php
示例18: display_setup_form
display_setup_form(__('Your passwords do not match. Please try again.'));
$error = true;
} else {
if (empty($admin_email)) {
// TODO: poka-yoke
display_setup_form(__('You must provide an email address.'));
$error = true;
} elseif (!is_email($admin_email)) {
// TODO: poka-yoke
display_setup_form(__('Sorry, that isn’t a valid email address. Email addresses look like <code>[email protected]</code>.'));
$error = true;
}
}
if ($error === false) {
$wpdb->show_errors();
$result = wp_install($weblog_title, $user_name, $admin_email, $public, '', wp_slash($admin_password), $loaded_language);
?>
<h1><?php
_e('Success!');
?>
</h1>
<p><?php
_e('WordPress has been installed. Were you expecting more steps? Sorry to disappoint.');
?>
</p>
<table class="form-table install-success">
<tr>
<th><?php
开发者ID:Didox,项目名称:beminfinito,代码行数:31,代码来源:install.php
示例19: _install
private function _install($assoc_args)
{
if (is_blog_installed()) {
return false;
}
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
extract(wp_parse_args($assoc_args, array('title' => '', 'admin_user' => '', 'admin_email' => '', 'admin_password' => '')), EXTR_SKIP);
// Support prompting for the `--url=<url>`,
// which is normally a runtime argument
if (isset($assoc_args['url'])) {
$url_parts = WP_CLI::set_url($assoc_args['url']);
}
$public = true;
// @codingStandardsIgnoreStart
if (!is_email($admin_email)) {
WP_CLI::error("The '{$admin_email}' email address is invalid.");
}
$result = wp_install($title, $admin_user, $admin_email, $public, '', $admin_password);
if (is_wp_error($result)) {
WP_CLI::error('Installation failed (' . WP_CLI::error_to_string($result) . ').');
}
// @codingStandardsIgnoreEnd
// Confirm the uploads directory exists
$upload_dir = wp_upload_dir();
if (!empty($upload_dir['error'])) {
WP_CLI::warning($upload_dir['error']);
}
return true;
}
开发者ID:wturrell,项目名称:wp-cli,代码行数:29,代码来源:core.php
示例20: foreach
foreach ( $wpdb->tables() as $table => $prefixed_table ) {
$wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
}
foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) {
$wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
// We need to create references to ms global tables.
if ( $multisite )
$wpdb->$table = $prefixed_table;
}
// Prefill a permalink structure so that WP doesn't try to determine one itself.
add_action( 'populate_options', '_set_default_permalink_structure_for_tests' );
wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' );
// Delete dummy permalink structure, as prefilled above.
if ( ! is_multisite() ) {
delete_option( 'permalink_structure' );
}
remove_action( 'populate_options', '_set_default_permalink_structure_for_tests' );
if ( $multisite ) {
echo "Installing network..." . PHP_EOL;
define( 'WP_INSTALLING_NETWORK', true );
$title = WP_TESTS_TITLE . ' Network';
$subdomain_install = false;
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:30,代码来源:install.php
注:本文中的wp_install函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论