wp/wp-includes/ms-settings.php
author ymh <ymh.work@gmail.com>
Mon, 08 Sep 2025 19:44:41 +0200
changeset 23 417f20492bf7
parent 22 8c2e4d02f4ef
permissions -rw-r--r--
Update Docker configuration and plugin versions - Upgrade MariaDB from 10.6 to 11 with auto-upgrade support - Add WordPress debug environment variable to FPM container - Update PHP-FPM Dockerfile base image - Update Include Mastodon Feed plugin with bug fixes and improvements - Update Portfolio plugin (v2.58) with latest translations and demo data enhancements - Remove old README.md from Mastodon Feed plugin 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Used to set up and fix common variables and include
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 * the Multisite procedural and class library.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * Allows for some configuration in wp-config.php (see ms-default-constants.php)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 * @subpackage Multisite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    13
// Don't load directly.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    14
if ( ! defined( 'ABSPATH' ) ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    15
	die( '-1' );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    16
}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    17
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    18
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    19
 * Objects representing the current network and current site.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    20
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    21
 * These may be populated through a custom `sunrise.php`. If not, then this
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    22
 * file will attempt to populate them based on the current request.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    23
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    24
 * @global WP_Network $current_site The current network.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    25
 * @global object     $current_blog The current site.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    26
 * @global string     $domain       Deprecated. The domain of the site found on load.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    27
 *                                  Use `get_site()->domain` instead.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    28
 * @global string     $path         Deprecated. The path of the site found on load.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    29
 *                                  Use `get_site()->path` instead.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    30
 * @global int        $site_id      Deprecated. The ID of the network found on load.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    31
 *                                  Use `get_current_network_id()` instead.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    32
 * @global bool       $public       Deprecated. Whether the site found on load is public.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    33
 *                                  Use `get_site()->public` instead.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    34
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    35
 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    36
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    37
global $current_site, $current_blog, $domain, $path, $site_id, $public;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    38
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    39
/** WP_Network class */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    40
require_once ABSPATH . WPINC . '/class-wp-network.php';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    41
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    42
/** WP_Site class */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    43
require_once ABSPATH . WPINC . '/class-wp-site.php';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    44
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    45
/** Multisite loader */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    46
require_once ABSPATH . WPINC . '/ms-load.php';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    47
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    48
/** Default Multisite constants */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    49
require_once ABSPATH . WPINC . '/ms-default-constants.php';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    51
if ( defined( 'SUNRISE' ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    52
	include_once WP_CONTENT_DIR . '/sunrise.php';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    53
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
/** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
ms_subdomain_constants();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    58
// This block will process a request if the current network or current site objects
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    59
// have not been populated in the global scope through something like `sunrise.php`.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    60
if ( ! isset( $current_site ) || ! isset( $current_blog ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
	$domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    63
	if ( str_ends_with( $domain, ':80' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    64
		$domain               = substr( $domain, 0, -3 );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    65
		$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    66
	} elseif ( str_ends_with( $domain, ':443' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    67
		$domain               = substr( $domain, 0, -4 );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    68
		$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    70
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
	$path = stripslashes( $_SERVER['REQUEST_URI'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    72
	if ( is_admin() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    73
		$path = preg_replace( '#(.*)/wp-admin/.*#', '$1/', $path );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    74
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    75
	list( $path ) = explode( '?', $path );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    76
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    77
	$bootstrap_result = ms_load_current_site_and_network( $domain, $path, is_subdomain_install() );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    78
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    79
	if ( true === $bootstrap_result ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    80
		// `$current_blog` and `$current_site are now populated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    81
	} elseif ( false === $bootstrap_result ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    82
		ms_not_installed( $domain, $path );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    83
	} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    84
		header( 'Location: ' . $bootstrap_result );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    85
		exit;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    87
	unset( $bootstrap_result );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	$blog_id = $current_blog->blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
	$public  = $current_blog->public;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    92
	if ( empty( $current_blog->site_id ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    93
		// This dates to [MU134] and shouldn't be relevant anymore,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    94
		// but it could be possible for arguments passed to insert_blog() etc.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
		$current_blog->site_id = 1;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    96
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    98
	$site_id = $current_blog->site_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    99
	wp_load_core_site_options( $site_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   101
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   102
$wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
$wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   104
$table_prefix       = $wpdb->get_blog_prefix();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
$_wp_switched_stack = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   106
$switched           = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   108
// Need to init cache again after blog_id is set.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
wp_start_object_cache();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   111
if ( ! $current_site instanceof WP_Network ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   112
	$current_site = new WP_Network( $current_site );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   113
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   114
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   115
if ( ! $current_blog instanceof WP_Site ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   116
	$current_blog = new WP_Site( $current_blog );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   117
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   118
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   119
// Define upload directory constants.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
ms_upload_constants();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   121
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   122
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   123
 * Fires after the current site and network have been detected and loaded
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   124
 * in multisite's bootstrap.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   125
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   126
 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   127
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   128
do_action( 'ms_loaded' );