本文整理汇总了PHP中wp_install_defaults函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_install_defaults函数的具体用法?PHP wp_install_defaults怎么用?PHP wp_install_defaults使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_install_defaults函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_install
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '')
{
global $wp_rewrite;
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$guessurl = wp_guess_url();
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
if (!$user_id) {
$random_password = wp_generate_password();
$user_id = wp_create_user($user_name, $random_password, $user_email);
} else {
$random_password = __('User already exists. Password inherited.');
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
$wp_rewrite->flush_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
}
示例2: wp_install
/**
* Installs the blog
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param string $blog_title Blog title.
* @param string $user_name User's username.
* @param string $user_email User's email.
* @param bool $public Whether blog is public.
* @param string $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Will default to a random password.
* @param string $language Optional. Language chosen.
* @return array Array keys 'url', 'user_id', 'password', 'password_message'.
*/
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '')
{
if (!empty($deprecated)) {
_deprecated_argument(__FUNCTION__, '2.6');
}
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
if ($language) {
update_option('WPLANG', $language);
}
$guessurl = wp_guess_url();
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
/*
* Create default user. If the user already exists, the user tables are
* being shared among blogs. Just set the role in that case.
*/
$user_id = username_exists($user_name);
$user_password = trim($user_password);
$email_password = false;
if (!$user_id && empty($user_password)) {
$user_password = wp_generate_password(12, false);
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
$user_id = wp_create_user($user_name, $user_password, $user_email);
update_user_option($user_id, 'default_password_nag', true, true);
$email_password = true;
} else {
if (!$user_id) {
// Password has been provided
$message = '<em>' . __('Your chosen password.') . '</em>';
$user_id = wp_create_user($user_name, $user_password, $user_email);
} else {
$message = __('User already exists. Password inherited.');
}
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
flush_rewrite_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
wp_cache_flush();
/**
* Fires after a site is fully installed.
*
* @since 3.9.0
*
* @param WP_User $user The site owner.
*/
do_action('wp_install', $user);
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
示例3: wp_install
function wp_install($blog_title, $user_name, $user_email, $public, $meta = '')
{
global $wp_rewrite;
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$schema = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://';
$guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
if (!$user_id) {
$random_password = substr(md5(uniqid(microtime())), 0, 6);
$user_id = wp_create_user($user_name, $random_password, $user_email);
} else {
$random_password = __('User already exists. Password inherited.');
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
$wp_rewrite->flush_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
}
示例4: wp_install
/**
* Installs the blog
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param string $blog_title Blog title.
* @param string $user_name User's username.
* @param string $user_email User's email.
* @param bool $public Whether blog is public.
* @param null $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Will default to a random password.
* @return array Array keys 'url', 'user_id', 'password', 'password_message'.
*/
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
if (!empty($deprecated)) {
_deprecated_argument(__FUNCTION__, '2.6');
}
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
if (!is_file(ABSPATH . 'wp-admin/install.sql')) {
//[ysd]如果有install.sql不设置默认options数据
populate_options();
} else {
validate_active_plugins();
//[ysd] 禁用 不可用的插件
}
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$guessurl = isset($_SERVER['HTTP_APPNAME']) ? 'http://' . substr($_SERVER['HTTP_APPNAME'], 5) . '.1kapp.com' : wp_guess_url();
//[ysd] 固定了guessurl
update_option('siteurl', $guessurl);
update_option('home', $guessurl);
get_option('siteurl');
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
$user_password = trim($user_password);
$email_password = false;
if (!$user_id && empty($user_password)) {
$user_password = wp_generate_password(12, false);
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
$user_id = wp_create_user($user_name, $user_password, $user_email);
update_user_option($user_id, 'default_password_nag', true, true);
$email_password = true;
} else {
if (!$user_id) {
// Password has been provided
$message = '<em>' . __('Your chosen password.') . '</em>';
$user_id = wp_create_user($user_name, $user_password, $user_email);
} else {
$message = __('User already exists. Password inherited.');
}
}
$user = new WP_User($user_id);
$user->set_role('administrator');
if (!file_exists(ABSPATH . 'wp-admin/without_default')) {
wp_install_defaults($user_id);
}
//[ysd],如果打包时设置了默认数据,才会设置默认数据
flush_rewrite_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
示例5: wp_install
/**
* This function overrides wp_install() in wp-admin/includes/upgrade.php
*/
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
if (!empty($deprecated)) {
_deprecated_argument(__FUNCTION__, '2.6');
}
wp_check_mysql_version();
wp_cache_flush();
/* changes */
require_once PDODIR . 'schema.php';
make_db_sqlite();
/* changes */
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$guessurl = wp_guess_url();
update_option('siteurl', $guessurl);
if (!$public) {
update_option('default_pingback_flag', 0);
}
$user_id = username_exists($user_name);
$user_password = trim($user_password);
$email_password = false;
if (!$user_id && empty($user_password)) {
$user_password = wp_generate_password(12, false);
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
$user_id = wp_create_user($user_name, $user_password, $user_email);
update_user_option($user_id, 'default_password_nag', true, true);
$email_password = true;
} else {
if (!$user_id) {
$message = '<em>' . __('Your chosen password.') . '</em>';
$user_id = wp_create_user($user_name, $user_password, $user_email);
}
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
flush_rewrite_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
wp_cache_flush();
if (isset($_SERVER['SERVER_SOFTWARE']) && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false || isset($_SERVER['SERVER_SIGNATURE']) && stripos($_SERVER['SERVER_SIGNATURE'], 'apache') !== false) {
// Your server is Apache. Nothing to do more.
} else {
$server_message = sprintf('Your webserver doesn\'t seem to be Apache. So the database directory access restriction by the .htaccess file may not function. We strongly recommend that you should restrict the access to the directory %s in some other way.', FQDBDIR);
echo '<div style="position: absolute; margin-top: 350px; width: 700px; border: .5px dashed rgb(0, 0, 0);"><p style="margin: 10px;">';
echo $server_message;
echo '</p></div>';
}
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
示例6: wp_install
/**
* this function overrides the built in wordpress variant
*
* @param object $blog_title
* @param object $user_name
* @param object $user_email
* @param object $public
* @param object $deprecated [optional]
* @return
*/
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '')
{
global $wp_rewrite, $wpdb;
//wp_check_mysql_version();
wp_cache_flush();
/**** changes start here ***/
switch (DB_TYPE) {
case 'sqlite':
require PDODIR . '/driver_sqlite/schema.php';
installdb();
break;
case 'mysql':
make_db_current_silent();
break;
}
/**** changes end ***/
$wpdb->suppress_errors();
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$guessurl = wp_guess_url();
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.
if (!$public) {
update_option('default_pingback_flag', 0);
}
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
if (!$user_id) {
$random_password = wp_generate_password();
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.<br><br>���' . $random_password);
$user_id = wp_create_user($user_name, $random_password, $user_email);
update_usermeta($user_id, 'default_password_nag', true);
} else {
$random_password = '';
$message = __('User already exists. Password inherited.');
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
$wp_rewrite->flush_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password, 'password_message' => $message);
}
示例7: wp_install
/**
* This function overrides wp_install() in wp-admin/includes/upgrade.php
*/
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
if (!empty($deprecated)) {
_deprecated_argument(__FUNCTION__, '2.6');
}
wp_check_mysql_version();
wp_cache_flush();
/* changes */
require_once PDODIR . 'schema.php';
make_db_sqlite();
/* changes */
populate_options();
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$guessurl = wp_guess_url();
update_option('siteurl', $guessurl);
if (!$public) {
update_option('default_pingback_flag', 0);
}
$user_id = username_exists($user_name);
$user_password = trim($user_password);
$email_password = false;
if (!$user_id && empty($user_password)) {
$user_password = wp_generate_password(12, false);
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
$user_id = wp_create_user($user_name, $user_password, $user_email);
update_user_option($user_id, 'default_password_nag', true, true);
$email_password = true;
} else {
if (!$user_id) {
$message = '<em>' . __('Your chosen password.') . '</em>';
$user_id = wp_create_user($user_name, $user_password, $user_email);
}
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
flush_rewrite_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
wp_cache_flush();
if (isset($_SERVER['SERVER_SOFTWARE']) && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false || isset($_SERVER['SERVER_SIGNATURE']) && stripos($_SERVER['SERVER_SIGNATURE'], 'apache') !== false) {
// Your server is Apache. Nothing to do more.
}
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
示例8: install_blog_defaults
/**
* Set blog defaults.
*
* This function creates a row in the wp_blogs table.
*
* @since MU
* @deprecated MU
* @deprecated Use wp_install_defaults()
* @uses wp_install_defaults()
*
* @param int $blog_id Ignored in this function.
* @param int $user_id
*/
function install_blog_defaults($blog_id, $user_id)
{
global $wpdb;
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
$wpdb->suppress_errors();
wp_install_defaults($user_id);
$wpdb->suppress_errors(false);
}
示例9: xpress_oninstall_base
//.........这里部分代码省略.........
$views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_views';
$charset_collate = '';
if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
}
if (!empty($wpdb->collate)) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
}
$views_queries = "CREATE TABLE {$views_table} (\n \t\tblog_id bigint(20) unsigned NOT NULL default '0',\n \t\tpost_id bigint(20) unsigned NOT NULL default '0',\n \t\tpost_views bigint(20) unsigned NOT NULL default '0',\n \t\tKEY post_id (post_id)\n\t\t){$charset_collate};";
dbDelta($views_queries);
$ret[] = "{$views_table} table of XPressME was made.<br />";
$d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_d3forum_link';
$views_queries = "CREATE TABLE {$d3forum_link} (\n \t\tcomment_ID bigint(20) unsigned NOT NULL default '0',\n \t\tpost_id int(10) unsigned NOT NULL default '0' ,\n \t\twp_post_ID bigint(20) unsigned NOT NULL default '0',\n \t\tforum_id bigint(20) unsigned NOT NULL default '0',\n \t\tblog_id bigint(20) unsigned NOT NULL default '0',\n \t\tKEY post_id (post_id)\n\t\t){$charset_collate};";
dbDelta($views_queries);
$ret[] = "{$d3forum_link} table of XPressME was made.<br />";
$group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_group_role';
$views_queries = "CREATE TABLE {$group_role} (\n \t\tgroupid smallint(5) unsigned NOT NULL default '0',\n \t\tblog_id bigint(20) unsigned NOT NULL default '0',\n \t\tname varchar(50) NOT NULL default '' ,\n \t\tdescription text NOT NULL default '',\n \t\tgroup_type varchar(50) NOT NULL default '' ,\n\t\trole varchar(20) NOT NULL default '' ,\n\t\tlogin_all smallint(5) unsigned NOT NULL default '0' ,\n \t\tKEY groupid (groupid)\n\t\t){$charset_collate};";
dbDelta($views_queries);
$ret[] = "{$group_role} table of XPressME was made.<br />";
$notify_reserve = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_notify_reserve';
$queries = "CREATE TABLE {$notify_reserve} (\n \t\tnotify_reserve_id bigint(20) NOT NULL AUTO_INCREMENT ,\n \t\tnotify_reserve_status varchar(20) NOT NULL default '' ,\n \t\tcategory text NOT NULL default '',\n \t\titem_id bigint(20) unsigned NOT NULL default '0',\n\t\tevent varchar(20) NOT NULL default '',\n\t\textra_tags_arry longtext NOT NULL default '' ,\n\t\tuser_list_arry longtext NOT NULL default '' ,\n \t\tmodule_id smallint(5) unsigned NOT NULL default '0' ,\n \t\tomit_user_id varchar(20) NOT NULL default '' ,\n \t\tKEY notify_reserve_id (notify_reserve_id)\n\t\t)ENGINE=MyISAM";
dbDelta($queries);
$ret[] = "{$notify_reserve} table of XPressME was made.<br />";
$sql = "INSERT INTO {$group_role} (groupid, role) VALUES (1, 'administrator')";
$wpdb->query($sql);
// make templates
include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php';
$t_mess = xpress_templates_make($mid, $mydirname);
// Admin User Data write
// Change uid field
$wpdb->query("ALTER TABLE {$wpdb->posts} CHANGE `post_author` `post_author` mediumint(8) NOT NULL DEFAULT '0'");
$user_name = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("uname") : 'admin';
$email = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("email") : 'foo@exsample.com';
$pass_md5 = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("pass") : '';
add_filter('sanitize_user', "sanitize_user_multibyte", 10, 3);
if (!function_exists('username_exists')) {
require_once $mydirpath . '/wp-includes/registration-functions.php';
}
$user_id = username_exists($user_name);
if (!$user_id) {
$random_password = 'admin';
$user_id = wp_create_user($user_name, $random_password, $email);
} else {
$random_password = __('User already exists. Password inherited.');
}
$user = new WP_User($user_id);
$user->set_role('administrator');
'User ' . $user_name . ' of the administrator was made.';
// over write xoops md5 password
$sql = "UPDATE {$wpdb->users} SET user_pass ='{$pass_md5}' WHERE ID = {$user_id}";
$wpdb->query($sql);
$ret[] = 'The password of XOOPS was copied.<br />';
// Set Default data
// make WordPress Default data
if (function_exists('wp_install_defaults')) {
wp_install_defaults($user_id);
} else {
wp_install_old_defaults($user_id);
}
$ret[] = 'The first sample post & comment was written.<br />';
// Rewrite Option for Xpress
$xoops_config_tbl = XOOPS_DB_PREFIX . '_config';
$sql = "SELECT conf_value FROM {$xoops_config_tbl} WHERE `conf_name` = 'default_TZ'";
$xoops_default_TZ = $wpdb->get_var($sql);
update_option('gmt_offset', $xoops_default_TZ);
if (WPLANG == 'ja_EUC') {
$setup_charset = 'EUC-JP';
} elseif (WPLANG == 'ja_SJIS') {
$setup_charset = 'Shift_JIS';
} else {
$setup_charset = 'UTF-8';
}
update_option("blog_charset", $setup_charset);
update_option('blogname', $site_name);
update_option('blogdescription', 'WordPress for XOOPS');
update_option("admin_email", $GLOBALS["xoopsConfig"]['adminmail']);
update_option("ping_sites", "http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/");
update_option("home", $site_url);
update_option("siteurl", $site_url);
update_option("what_to_show", "posts");
update_option('default_pingback_flag', 0);
$ret[] = 'The initial data was written in the data base of wordpress.<br />';
update_option("template", "xpress_default");
update_option("stylesheet", "xpress_default");
$ret[] = 'The default theme of wordpress was set to xpress_default.<br />';
// update_option('uploads_use_yearmonth_folders', 1);
update_option('upload_path', 'wp-content/uploads');
// activate the xpressme plugin
require_once dirname(__FILE__) . '/xpress_active_plugin.php';
if (xpress_pulugin_activation('xpressme/xpressme.php')) {
$ret[] = 'The xpressme plug-in was activated.<br />';
} else {
$GLOBALS["err_log"][] = '<span style="color:#ff0000;">failed in the activation of xpressme plug-in.</span><br />';
return false;
}
$ret = array_merge($ret, $t_mess);
return true;
}