Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
make_db_current_silent example
$switch
= false;
if
(
get_current_blog_id
(
)
!==
$site
->id
)
{
$switch
= true;
switch_to_blog
(
$site
->id
)
;
}
require_once
ABSPATH . 'wp-admin/includes/upgrade.php';
// Set up the database tables.
make_db_current_silent
(
'blog'
)
;
$home_scheme
= 'http';
$siteurl_scheme
= 'http';
if
(
!
is_subdomain_install
(
)
)
{
if
(
'https' ===
parse_url
(
get_home_url
(
$network
->site_id
)
, PHP_URL_SCHEME
)
)
{
$home_scheme
= 'https';
}
if
(
'https' ===
parse_url
(
get_network_option
(
$network
->id, 'siteurl'
)
, PHP_URL_SCHEME
)
)
{
$siteurl_scheme
= 'https';
}
}
require_once
ABSPATH . 'wp-admin/includes/upgrade.php';
$suppress
=
$wpdb
->
suppress_errors
(
)
;
if
(
$wpdb
->
get_results
(
"DESCRIBE {
$wpdb
->posts
}
"
)
)
{
die
(
'<h1>' .
__
(
'Already Installed'
)
. '</h1><p>' .
__
(
'You appear to have already installed WordPress. To reinstall please clear your old database tables first.'
)
. '</p></body></html>'
)
;
}
$wpdb
->
suppress_errors
(
$suppress
)
;
$url
=
get_blogaddress_by_id
(
$blog_id
)
;
// Set everything up.
make_db_current_silent
(
'blog'
)
;
populate_options
(
)
;
populate_roles
(
)
;
// populate_roles() clears previous role definitions so we start over.
$wp_roles
=
new
WP_Roles
(
)
;
$siteurl
=
$home
=
untrailingslashit
(
$url
)
;
if
(
!
is_subdomain_install
(
)
)
{
if
(
'https' ===
parse_url
(
get_site_option
(
'siteurl'
)
, PHP_URL_SCHEME
)
)
{
function
wp_install
(
$blog_title
,
$user_name
,
$user_email
,
$is_public
,
$deprecated
= '',
$user_password
= '',
$language
= ''
)
{
if
(
!
empty
(
$deprecated
)
)
{
_deprecated_argument
(
__FUNCTION__, '2.6.0'
)
;
}
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',
$is_public
)
;
// Freshness of site - in the future, this could get more specific about actions taken, perhaps.
update_option
(
'fresh_site', 1
)
;
if
(
$language
)
{