Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: ms-site.php
*/
[500] Fix | Delete
do_action( 'wp_validate_site_data', $errors, $data, $old_site );
[501] Fix | Delete
[502] Fix | Delete
if ( ! empty( $errors->errors ) ) {
[503] Fix | Delete
return $errors;
[504] Fix | Delete
}
[505] Fix | Delete
[506] Fix | Delete
// Prepare for database.
[507] Fix | Delete
$data['site_id'] = $data['network_id'];
[508] Fix | Delete
unset( $data['network_id'] );
[509] Fix | Delete
[510] Fix | Delete
return $data;
[511] Fix | Delete
}
[512] Fix | Delete
[513] Fix | Delete
/**
[514] Fix | Delete
* Normalizes data for a site prior to inserting or updating in the database.
[515] Fix | Delete
*
[516] Fix | Delete
* @since 5.1.0
[517] Fix | Delete
*
[518] Fix | Delete
* @param array $data Associative array of site data passed to the respective function.
[519] Fix | Delete
* See {@see wp_insert_site()} for the possibly included data.
[520] Fix | Delete
* @return array Normalized site data.
[521] Fix | Delete
*/
[522] Fix | Delete
function wp_normalize_site_data( $data ) {
[523] Fix | Delete
// Sanitize domain if passed.
[524] Fix | Delete
if ( array_key_exists( 'domain', $data ) ) {
[525] Fix | Delete
$data['domain'] = preg_replace( '/[^a-z0-9\-.:]+/i', '', $data['domain'] );
[526] Fix | Delete
}
[527] Fix | Delete
[528] Fix | Delete
// Sanitize path if passed.
[529] Fix | Delete
if ( array_key_exists( 'path', $data ) ) {
[530] Fix | Delete
$data['path'] = trailingslashit( '/' . trim( $data['path'], '/' ) );
[531] Fix | Delete
}
[532] Fix | Delete
[533] Fix | Delete
// Sanitize network ID if passed.
[534] Fix | Delete
if ( array_key_exists( 'network_id', $data ) ) {
[535] Fix | Delete
$data['network_id'] = (int) $data['network_id'];
[536] Fix | Delete
}
[537] Fix | Delete
[538] Fix | Delete
// Sanitize status fields if passed.
[539] Fix | Delete
$status_fields = array( 'public', 'archived', 'mature', 'spam', 'deleted' );
[540] Fix | Delete
foreach ( $status_fields as $status_field ) {
[541] Fix | Delete
if ( array_key_exists( $status_field, $data ) ) {
[542] Fix | Delete
$data[ $status_field ] = (int) $data[ $status_field ];
[543] Fix | Delete
}
[544] Fix | Delete
}
[545] Fix | Delete
[546] Fix | Delete
// Strip date fields if empty.
[547] Fix | Delete
$date_fields = array( 'registered', 'last_updated' );
[548] Fix | Delete
foreach ( $date_fields as $date_field ) {
[549] Fix | Delete
if ( ! array_key_exists( $date_field, $data ) ) {
[550] Fix | Delete
continue;
[551] Fix | Delete
}
[552] Fix | Delete
[553] Fix | Delete
if ( empty( $data[ $date_field ] ) || '0000-00-00 00:00:00' === $data[ $date_field ] ) {
[554] Fix | Delete
unset( $data[ $date_field ] );
[555] Fix | Delete
}
[556] Fix | Delete
}
[557] Fix | Delete
[558] Fix | Delete
return $data;
[559] Fix | Delete
}
[560] Fix | Delete
[561] Fix | Delete
/**
[562] Fix | Delete
* Validates data for a site prior to inserting or updating in the database.
[563] Fix | Delete
*
[564] Fix | Delete
* @since 5.1.0
[565] Fix | Delete
*
[566] Fix | Delete
* @param WP_Error $errors Error object, passed by reference. Will contain validation errors if
[567] Fix | Delete
* any occurred.
[568] Fix | Delete
* @param array $data Associative array of complete site data. See {@see wp_insert_site()}
[569] Fix | Delete
* for the included data.
[570] Fix | Delete
* @param WP_Site|null $old_site The old site object if the data belongs to a site being updated,
[571] Fix | Delete
* or null if it is a new site being inserted.
[572] Fix | Delete
*/
[573] Fix | Delete
function wp_validate_site_data( $errors, $data, $old_site = null ) {
[574] Fix | Delete
// A domain must always be present.
[575] Fix | Delete
if ( empty( $data['domain'] ) ) {
[576] Fix | Delete
$errors->add( 'site_empty_domain', __( 'Site domain must not be empty.' ) );
[577] Fix | Delete
}
[578] Fix | Delete
[579] Fix | Delete
// A path must always be present.
[580] Fix | Delete
if ( empty( $data['path'] ) ) {
[581] Fix | Delete
$errors->add( 'site_empty_path', __( 'Site path must not be empty.' ) );
[582] Fix | Delete
}
[583] Fix | Delete
[584] Fix | Delete
// A network ID must always be present.
[585] Fix | Delete
if ( empty( $data['network_id'] ) ) {
[586] Fix | Delete
$errors->add( 'site_empty_network_id', __( 'Site network ID must be provided.' ) );
[587] Fix | Delete
}
[588] Fix | Delete
[589] Fix | Delete
// Both registration and last updated dates must always be present and valid.
[590] Fix | Delete
$date_fields = array( 'registered', 'last_updated' );
[591] Fix | Delete
foreach ( $date_fields as $date_field ) {
[592] Fix | Delete
if ( empty( $data[ $date_field ] ) ) {
[593] Fix | Delete
$errors->add( 'site_empty_' . $date_field, __( 'Both registration and last updated dates must be provided.' ) );
[594] Fix | Delete
break;
[595] Fix | Delete
}
[596] Fix | Delete
[597] Fix | Delete
// Allow '0000-00-00 00:00:00', although it be stripped out at this point.
[598] Fix | Delete
if ( '0000-00-00 00:00:00' !== $data[ $date_field ] ) {
[599] Fix | Delete
$month = substr( $data[ $date_field ], 5, 2 );
[600] Fix | Delete
$day = substr( $data[ $date_field ], 8, 2 );
[601] Fix | Delete
$year = substr( $data[ $date_field ], 0, 4 );
[602] Fix | Delete
$valid_date = wp_checkdate( $month, $day, $year, $data[ $date_field ] );
[603] Fix | Delete
if ( ! $valid_date ) {
[604] Fix | Delete
$errors->add( 'site_invalid_' . $date_field, __( 'Both registration and last updated dates must be valid dates.' ) );
[605] Fix | Delete
break;
[606] Fix | Delete
}
[607] Fix | Delete
}
[608] Fix | Delete
}
[609] Fix | Delete
[610] Fix | Delete
if ( ! empty( $errors->errors ) ) {
[611] Fix | Delete
return;
[612] Fix | Delete
}
[613] Fix | Delete
[614] Fix | Delete
// If a new site, or domain/path/network ID have changed, ensure uniqueness.
[615] Fix | Delete
if ( ! $old_site
[616] Fix | Delete
|| $data['domain'] !== $old_site->domain
[617] Fix | Delete
|| $data['path'] !== $old_site->path
[618] Fix | Delete
|| $data['network_id'] !== $old_site->network_id
[619] Fix | Delete
) {
[620] Fix | Delete
if ( domain_exists( $data['domain'], $data['path'], $data['network_id'] ) ) {
[621] Fix | Delete
$errors->add( 'site_taken', __( 'Sorry, that site already exists!' ) );
[622] Fix | Delete
}
[623] Fix | Delete
}
[624] Fix | Delete
}
[625] Fix | Delete
[626] Fix | Delete
/**
[627] Fix | Delete
* Runs the initialization routine for a given site.
[628] Fix | Delete
*
[629] Fix | Delete
* This process includes creating the site's database tables and
[630] Fix | Delete
* populating them with defaults.
[631] Fix | Delete
*
[632] Fix | Delete
* @since 5.1.0
[633] Fix | Delete
*
[634] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[635] Fix | Delete
* @global WP_Roles $wp_roles WordPress role management object.
[636] Fix | Delete
*
[637] Fix | Delete
* @param int|WP_Site $site_id Site ID or object.
[638] Fix | Delete
* @param array $args {
[639] Fix | Delete
* Optional. Arguments to modify the initialization behavior.
[640] Fix | Delete
*
[641] Fix | Delete
* @type int $user_id Required. User ID for the site administrator.
[642] Fix | Delete
* @type string $title Site title. Default is 'Site %d' where %d is the
[643] Fix | Delete
* site ID.
[644] Fix | Delete
* @type array $options Custom option $key => $value pairs to use. Default
[645] Fix | Delete
* empty array.
[646] Fix | Delete
* @type array $meta Custom site metadata $key => $value pairs to use.
[647] Fix | Delete
* Default empty array.
[648] Fix | Delete
* }
[649] Fix | Delete
* @return true|WP_Error True on success, or error object on failure.
[650] Fix | Delete
*/
[651] Fix | Delete
function wp_initialize_site( $site_id, array $args = array() ) {
[652] Fix | Delete
global $wpdb, $wp_roles;
[653] Fix | Delete
[654] Fix | Delete
if ( empty( $site_id ) ) {
[655] Fix | Delete
return new WP_Error( 'site_empty_id', __( 'Site ID must not be empty.' ) );
[656] Fix | Delete
}
[657] Fix | Delete
[658] Fix | Delete
$site = get_site( $site_id );
[659] Fix | Delete
if ( ! $site ) {
[660] Fix | Delete
return new WP_Error( 'site_invalid_id', __( 'Site with the ID does not exist.' ) );
[661] Fix | Delete
}
[662] Fix | Delete
[663] Fix | Delete
if ( wp_is_site_initialized( $site ) ) {
[664] Fix | Delete
return new WP_Error( 'site_already_initialized', __( 'The site appears to be already initialized.' ) );
[665] Fix | Delete
}
[666] Fix | Delete
[667] Fix | Delete
$network = get_network( $site->network_id );
[668] Fix | Delete
if ( ! $network ) {
[669] Fix | Delete
$network = get_network();
[670] Fix | Delete
}
[671] Fix | Delete
[672] Fix | Delete
$args = wp_parse_args(
[673] Fix | Delete
$args,
[674] Fix | Delete
array(
[675] Fix | Delete
'user_id' => 0,
[676] Fix | Delete
/* translators: %d: Site ID. */
[677] Fix | Delete
'title' => sprintf( __( 'Site %d' ), $site->id ),
[678] Fix | Delete
'options' => array(),
[679] Fix | Delete
'meta' => array(),
[680] Fix | Delete
)
[681] Fix | Delete
);
[682] Fix | Delete
[683] Fix | Delete
/**
[684] Fix | Delete
* Filters the arguments for initializing a site.
[685] Fix | Delete
*
[686] Fix | Delete
* @since 5.1.0
[687] Fix | Delete
*
[688] Fix | Delete
* @param array $args Arguments to modify the initialization behavior.
[689] Fix | Delete
* @param WP_Site $site Site that is being initialized.
[690] Fix | Delete
* @param WP_Network $network Network that the site belongs to.
[691] Fix | Delete
*/
[692] Fix | Delete
$args = apply_filters( 'wp_initialize_site_args', $args, $site, $network );
[693] Fix | Delete
[694] Fix | Delete
$orig_installing = wp_installing();
[695] Fix | Delete
if ( ! $orig_installing ) {
[696] Fix | Delete
wp_installing( true );
[697] Fix | Delete
}
[698] Fix | Delete
[699] Fix | Delete
$switch = false;
[700] Fix | Delete
if ( get_current_blog_id() !== $site->id ) {
[701] Fix | Delete
$switch = true;
[702] Fix | Delete
switch_to_blog( $site->id );
[703] Fix | Delete
}
[704] Fix | Delete
[705] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
[706] Fix | Delete
[707] Fix | Delete
// Set up the database tables.
[708] Fix | Delete
make_db_current_silent( 'blog' );
[709] Fix | Delete
[710] Fix | Delete
$home_scheme = 'http';
[711] Fix | Delete
$siteurl_scheme = 'http';
[712] Fix | Delete
if ( ! is_subdomain_install() ) {
[713] Fix | Delete
if ( 'https' === parse_url( get_home_url( $network->site_id ), PHP_URL_SCHEME ) ) {
[714] Fix | Delete
$home_scheme = 'https';
[715] Fix | Delete
}
[716] Fix | Delete
if ( 'https' === parse_url( get_network_option( $network->id, 'siteurl' ), PHP_URL_SCHEME ) ) {
[717] Fix | Delete
$siteurl_scheme = 'https';
[718] Fix | Delete
}
[719] Fix | Delete
}
[720] Fix | Delete
[721] Fix | Delete
// Populate the site's options.
[722] Fix | Delete
populate_options(
[723] Fix | Delete
array_merge(
[724] Fix | Delete
array(
[725] Fix | Delete
'home' => untrailingslashit( $home_scheme . '://' . $site->domain . $site->path ),
[726] Fix | Delete
'siteurl' => untrailingslashit( $siteurl_scheme . '://' . $site->domain . $site->path ),
[727] Fix | Delete
'blogname' => wp_unslash( $args['title'] ),
[728] Fix | Delete
'admin_email' => '',
[729] Fix | Delete
'upload_path' => get_network_option( $network->id, 'ms_files_rewriting' ) ? UPLOADBLOGSDIR . "/{$site->id}/files" : get_blog_option( $network->site_id, 'upload_path' ),
[730] Fix | Delete
'blog_public' => (int) $site->public,
[731] Fix | Delete
'WPLANG' => get_network_option( $network->id, 'WPLANG' ),
[732] Fix | Delete
),
[733] Fix | Delete
$args['options']
[734] Fix | Delete
)
[735] Fix | Delete
);
[736] Fix | Delete
[737] Fix | Delete
// Clean blog cache after populating options.
[738] Fix | Delete
clean_blog_cache( $site );
[739] Fix | Delete
[740] Fix | Delete
// Populate the site's roles.
[741] Fix | Delete
populate_roles();
[742] Fix | Delete
$wp_roles = new WP_Roles();
[743] Fix | Delete
[744] Fix | Delete
// Populate metadata for the site.
[745] Fix | Delete
populate_site_meta( $site->id, $args['meta'] );
[746] Fix | Delete
[747] Fix | Delete
// Remove all permissions that may exist for the site.
[748] Fix | Delete
$table_prefix = $wpdb->get_blog_prefix();
[749] Fix | Delete
delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // Delete all.
[750] Fix | Delete
delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // Delete all.
[751] Fix | Delete
[752] Fix | Delete
// Install default site content.
[753] Fix | Delete
wp_install_defaults( $args['user_id'] );
[754] Fix | Delete
[755] Fix | Delete
// Set the site administrator.
[756] Fix | Delete
add_user_to_blog( $site->id, $args['user_id'], 'administrator' );
[757] Fix | Delete
if ( ! user_can( $args['user_id'], 'manage_network' ) && ! get_user_meta( $args['user_id'], 'primary_blog', true ) ) {
[758] Fix | Delete
update_user_meta( $args['user_id'], 'primary_blog', $site->id );
[759] Fix | Delete
}
[760] Fix | Delete
[761] Fix | Delete
if ( $switch ) {
[762] Fix | Delete
restore_current_blog();
[763] Fix | Delete
}
[764] Fix | Delete
[765] Fix | Delete
wp_installing( $orig_installing );
[766] Fix | Delete
[767] Fix | Delete
return true;
[768] Fix | Delete
}
[769] Fix | Delete
[770] Fix | Delete
/**
[771] Fix | Delete
* Runs the uninitialization routine for a given site.
[772] Fix | Delete
*
[773] Fix | Delete
* This process includes dropping the site's database tables and deleting its uploads directory.
[774] Fix | Delete
*
[775] Fix | Delete
* @since 5.1.0
[776] Fix | Delete
*
[777] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[778] Fix | Delete
*
[779] Fix | Delete
* @param int|WP_Site $site_id Site ID or object.
[780] Fix | Delete
* @return true|WP_Error True on success, or error object on failure.
[781] Fix | Delete
*/
[782] Fix | Delete
function wp_uninitialize_site( $site_id ) {
[783] Fix | Delete
global $wpdb;
[784] Fix | Delete
[785] Fix | Delete
if ( empty( $site_id ) ) {
[786] Fix | Delete
return new WP_Error( 'site_empty_id', __( 'Site ID must not be empty.' ) );
[787] Fix | Delete
}
[788] Fix | Delete
[789] Fix | Delete
$site = get_site( $site_id );
[790] Fix | Delete
if ( ! $site ) {
[791] Fix | Delete
return new WP_Error( 'site_invalid_id', __( 'Site with the ID does not exist.' ) );
[792] Fix | Delete
}
[793] Fix | Delete
[794] Fix | Delete
if ( ! wp_is_site_initialized( $site ) ) {
[795] Fix | Delete
return new WP_Error( 'site_already_uninitialized', __( 'The site appears to be already uninitialized.' ) );
[796] Fix | Delete
}
[797] Fix | Delete
[798] Fix | Delete
$users = get_users(
[799] Fix | Delete
array(
[800] Fix | Delete
'blog_id' => $site->id,
[801] Fix | Delete
'fields' => 'ids',
[802] Fix | Delete
)
[803] Fix | Delete
);
[804] Fix | Delete
[805] Fix | Delete
// Remove users from the site.
[806] Fix | Delete
if ( ! empty( $users ) ) {
[807] Fix | Delete
foreach ( $users as $user_id ) {
[808] Fix | Delete
remove_user_from_blog( $user_id, $site->id );
[809] Fix | Delete
}
[810] Fix | Delete
}
[811] Fix | Delete
[812] Fix | Delete
$switch = false;
[813] Fix | Delete
if ( get_current_blog_id() !== $site->id ) {
[814] Fix | Delete
$switch = true;
[815] Fix | Delete
switch_to_blog( $site->id );
[816] Fix | Delete
}
[817] Fix | Delete
[818] Fix | Delete
$uploads = wp_get_upload_dir();
[819] Fix | Delete
[820] Fix | Delete
$tables = $wpdb->tables( 'blog' );
[821] Fix | Delete
[822] Fix | Delete
/**
[823] Fix | Delete
* Filters the tables to drop when the site is deleted.
[824] Fix | Delete
*
[825] Fix | Delete
* @since MU (3.0.0)
[826] Fix | Delete
*
[827] Fix | Delete
* @param string[] $tables Array of names of the site tables to be dropped.
[828] Fix | Delete
* @param int $site_id The ID of the site to drop tables for.
[829] Fix | Delete
*/
[830] Fix | Delete
$drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $site->id );
[831] Fix | Delete
[832] Fix | Delete
foreach ( (array) $drop_tables as $table ) {
[833] Fix | Delete
$wpdb->query( "DROP TABLE IF EXISTS `$table`" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
[834] Fix | Delete
}
[835] Fix | Delete
[836] Fix | Delete
/**
[837] Fix | Delete
* Filters the upload base directory to delete when the site is deleted.
[838] Fix | Delete
*
[839] Fix | Delete
* @since MU (3.0.0)
[840] Fix | Delete
*
[841] Fix | Delete
* @param string $basedir Uploads path without subdirectory. See {@see wp_upload_dir()}.
[842] Fix | Delete
* @param int $site_id The site ID.
[843] Fix | Delete
*/
[844] Fix | Delete
$dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $site->id );
[845] Fix | Delete
$dir = rtrim( $dir, DIRECTORY_SEPARATOR );
[846] Fix | Delete
$top_dir = $dir;
[847] Fix | Delete
$stack = array( $dir );
[848] Fix | Delete
$index = 0;
[849] Fix | Delete
[850] Fix | Delete
while ( $index < count( $stack ) ) {
[851] Fix | Delete
// Get indexed directory from stack.
[852] Fix | Delete
$dir = $stack[ $index ];
[853] Fix | Delete
[854] Fix | Delete
// phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged
[855] Fix | Delete
$dh = @opendir( $dir );
[856] Fix | Delete
if ( $dh ) {
[857] Fix | Delete
$file = @readdir( $dh );
[858] Fix | Delete
while ( false !== $file ) {
[859] Fix | Delete
if ( '.' === $file || '..' === $file ) {
[860] Fix | Delete
$file = @readdir( $dh );
[861] Fix | Delete
continue;
[862] Fix | Delete
}
[863] Fix | Delete
[864] Fix | Delete
if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
[865] Fix | Delete
$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
[866] Fix | Delete
} elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) {
[867] Fix | Delete
@unlink( $dir . DIRECTORY_SEPARATOR . $file );
[868] Fix | Delete
}
[869] Fix | Delete
[870] Fix | Delete
$file = @readdir( $dh );
[871] Fix | Delete
}
[872] Fix | Delete
@closedir( $dh );
[873] Fix | Delete
}
[874] Fix | Delete
++$index;
[875] Fix | Delete
}
[876] Fix | Delete
[877] Fix | Delete
$stack = array_reverse( $stack ); // Last added directories are deepest.
[878] Fix | Delete
foreach ( (array) $stack as $dir ) {
[879] Fix | Delete
if ( $dir !== $top_dir ) {
[880] Fix | Delete
@rmdir( $dir );
[881] Fix | Delete
}
[882] Fix | Delete
}
[883] Fix | Delete
[884] Fix | Delete
// phpcs:enable WordPress.PHP.NoSilencedErrors.Discouraged
[885] Fix | Delete
if ( $switch ) {
[886] Fix | Delete
restore_current_blog();
[887] Fix | Delete
}
[888] Fix | Delete
[889] Fix | Delete
return true;
[890] Fix | Delete
}
[891] Fix | Delete
[892] Fix | Delete
/**
[893] Fix | Delete
* Checks whether a site is initialized.
[894] Fix | Delete
*
[895] Fix | Delete
* A site is considered initialized when its database tables are present.
[896] Fix | Delete
*
[897] Fix | Delete
* @since 5.1.0
[898] Fix | Delete
*
[899] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[900] Fix | Delete
*
[901] Fix | Delete
* @param int|WP_Site $site_id Site ID or object.
[902] Fix | Delete
* @return bool True if the site is initialized, false otherwise.
[903] Fix | Delete
*/
[904] Fix | Delete
function wp_is_site_initialized( $site_id ) {
[905] Fix | Delete
global $wpdb;
[906] Fix | Delete
[907] Fix | Delete
if ( is_object( $site_id ) ) {
[908] Fix | Delete
$site_id = $site_id->blog_id;
[909] Fix | Delete
}
[910] Fix | Delete
$site_id = (int) $site_id;
[911] Fix | Delete
[912] Fix | Delete
/**
[913] Fix | Delete
* Filters the check for whether a site is initialized before the database is accessed.
[914] Fix | Delete
*
[915] Fix | Delete
* Returning a non-null value will effectively short-circuit the function, returning
[916] Fix | Delete
* that value instead.
[917] Fix | Delete
*
[918] Fix | Delete
* @since 5.1.0
[919] Fix | Delete
*
[920] Fix | Delete
* @param bool|null $pre The value to return instead. Default null
[921] Fix | Delete
* to continue with the check.
[922] Fix | Delete
* @param int $site_id The site ID that is being checked.
[923] Fix | Delete
*/
[924] Fix | Delete
$pre = apply_filters( 'pre_wp_is_site_initialized', null, $site_id );
[925] Fix | Delete
if ( null !== $pre ) {
[926] Fix | Delete
return (bool) $pre;
[927] Fix | Delete
}
[928] Fix | Delete
[929] Fix | Delete
$switch = false;
[930] Fix | Delete
if ( get_current_blog_id() !== $site_id ) {
[931] Fix | Delete
$switch = true;
[932] Fix | Delete
remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 );
[933] Fix | Delete
switch_to_blog( $site_id );
[934] Fix | Delete
}
[935] Fix | Delete
[936] Fix | Delete
$suppress = $wpdb->suppress_errors();
[937] Fix | Delete
$result = (bool) $wpdb->get_results( "DESCRIBE {$wpdb->posts}" );
[938] Fix | Delete
$wpdb->suppress_errors( $suppress );
[939] Fix | Delete
[940] Fix | Delete
if ( $switch ) {
[941] Fix | Delete
restore_current_blog();
[942] Fix | Delete
add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 );
[943] Fix | Delete
}
[944] Fix | Delete
[945] Fix | Delete
return $result;
[946] Fix | Delete
}
[947] Fix | Delete
[948] Fix | Delete
/**
[949] Fix | Delete
* Clean the blog cache
[950] Fix | Delete
*
[951] Fix | Delete
* @since 3.5.0
[952] Fix | Delete
*
[953] Fix | Delete
* @global bool $_wp_suspend_cache_invalidation
[954] Fix | Delete
*
[955] Fix | Delete
* @param WP_Site|int $blog The site object or ID to be cleared from cache.
[956] Fix | Delete
*/
[957] Fix | Delete
function clean_blog_cache( $blog ) {
[958] Fix | Delete
global $_wp_suspend_cache_invalidation;
[959] Fix | Delete
[960] Fix | Delete
if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
[961] Fix | Delete
return;
[962] Fix | Delete
}
[963] Fix | Delete
[964] Fix | Delete
if ( empty( $blog ) ) {
[965] Fix | Delete
return;
[966] Fix | Delete
}
[967] Fix | Delete
[968] Fix | Delete
$blog_id = $blog;
[969] Fix | Delete
$blog = get_site( $blog_id );
[970] Fix | Delete
if ( ! $blog ) {
[971] Fix | Delete
if ( ! is_numeric( $blog_id ) ) {
[972] Fix | Delete
return;
[973] Fix | Delete
}
[974] Fix | Delete
[975] Fix | Delete
// Make sure a WP_Site object exists even when the site has been deleted.
[976] Fix | Delete
$blog = new WP_Site(
[977] Fix | Delete
(object) array(
[978] Fix | Delete
'blog_id' => $blog_id,
[979] Fix | Delete
'domain' => null,
[980] Fix | Delete
'path' => null,
[981] Fix | Delete
)
[982] Fix | Delete
);
[983] Fix | Delete
}
[984] Fix | Delete
[985] Fix | Delete
$blog_id = $blog->blog_id;
[986] Fix | Delete
$domain_path_key = md5( $blog->domain . $blog->path );
[987] Fix | Delete
[988] Fix | Delete
wp_cache_delete( $blog_id, 'sites' );
[989] Fix | Delete
wp_cache_delete( $blog_id, 'site-details' );
[990] Fix | Delete
wp_cache_delete( $blog_id, 'blog-details' );
[991] Fix | Delete
wp_cache_delete( $blog_id . 'short', 'blog-details' );
[992] Fix | Delete
wp_cache_delete( $domain_path_key, 'blog-lookup' );
[993] Fix | Delete
wp_cache_delete( $domain_path_key, 'blog-id-cache' );
[994] Fix | Delete
wp_cache_delete( $blog_id, 'blog_meta' );
[995] Fix | Delete
[996] Fix | Delete
/**
[997] Fix | Delete
* Fires immediately after a site has been removed from the object cache.
[998] Fix | Delete
*
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function