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/wp-inclu...
File: ms-functions.php
$site_mimes[ $ext_pattern ] = $mime;
[2000] Fix | Delete
}
[2001] Fix | Delete
}
[2002] Fix | Delete
}
[2003] Fix | Delete
return $site_mimes;
[2004] Fix | Delete
}
[2005] Fix | Delete
[2006] Fix | Delete
/**
[2007] Fix | Delete
* Updates a blog's post count.
[2008] Fix | Delete
*
[2009] Fix | Delete
* WordPress MS stores a blog's post count as an option so as
[2010] Fix | Delete
* to avoid extraneous COUNTs when a blog's details are fetched
[2011] Fix | Delete
* with get_site(). This function is called when posts are published
[2012] Fix | Delete
* or unpublished to make sure the count stays current.
[2013] Fix | Delete
*
[2014] Fix | Delete
* @since MU (3.0.0)
[2015] Fix | Delete
*
[2016] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2017] Fix | Delete
*
[2018] Fix | Delete
* @param string $deprecated Not used.
[2019] Fix | Delete
*/
[2020] Fix | Delete
function update_posts_count( $deprecated = '' ) {
[2021] Fix | Delete
global $wpdb;
[2022] Fix | Delete
update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );
[2023] Fix | Delete
}
[2024] Fix | Delete
[2025] Fix | Delete
/**
[2026] Fix | Delete
* Logs the user email, IP, and registration date of a new site.
[2027] Fix | Delete
*
[2028] Fix | Delete
* @since MU (3.0.0)
[2029] Fix | Delete
* @since 5.1.0 Parameters now support input from the {@see 'wp_initialize_site'} action.
[2030] Fix | Delete
*
[2031] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2032] Fix | Delete
*
[2033] Fix | Delete
* @param WP_Site|int $blog_id The new site's object or ID.
[2034] Fix | Delete
* @param int|array $user_id User ID, or array of arguments including 'user_id'.
[2035] Fix | Delete
*/
[2036] Fix | Delete
function wpmu_log_new_registrations( $blog_id, $user_id ) {
[2037] Fix | Delete
global $wpdb;
[2038] Fix | Delete
[2039] Fix | Delete
if ( is_object( $blog_id ) ) {
[2040] Fix | Delete
$blog_id = $blog_id->blog_id;
[2041] Fix | Delete
}
[2042] Fix | Delete
[2043] Fix | Delete
if ( is_array( $user_id ) ) {
[2044] Fix | Delete
$user_id = ! empty( $user_id['user_id'] ) ? $user_id['user_id'] : 0;
[2045] Fix | Delete
}
[2046] Fix | Delete
[2047] Fix | Delete
$user = get_userdata( (int) $user_id );
[2048] Fix | Delete
if ( $user ) {
[2049] Fix | Delete
$wpdb->insert(
[2050] Fix | Delete
$wpdb->registration_log,
[2051] Fix | Delete
array(
[2052] Fix | Delete
'email' => $user->user_email,
[2053] Fix | Delete
'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ),
[2054] Fix | Delete
'blog_id' => $blog_id,
[2055] Fix | Delete
'date_registered' => current_time( 'mysql' ),
[2056] Fix | Delete
)
[2057] Fix | Delete
);
[2058] Fix | Delete
}
[2059] Fix | Delete
}
[2060] Fix | Delete
[2061] Fix | Delete
/**
[2062] Fix | Delete
* Ensures that the current site's domain is listed in the allowed redirect host list.
[2063] Fix | Delete
*
[2064] Fix | Delete
* @see wp_validate_redirect()
[2065] Fix | Delete
* @since MU (3.0.0)
[2066] Fix | Delete
*
[2067] Fix | Delete
* @param array|string $deprecated Not used.
[2068] Fix | Delete
* @return string[] {
[2069] Fix | Delete
* An array containing the current site's domain.
[2070] Fix | Delete
*
[2071] Fix | Delete
* @type string $0 The current site's domain.
[2072] Fix | Delete
* }
[2073] Fix | Delete
*/
[2074] Fix | Delete
function redirect_this_site( $deprecated = '' ) {
[2075] Fix | Delete
return array( get_network()->domain );
[2076] Fix | Delete
}
[2077] Fix | Delete
[2078] Fix | Delete
/**
[2079] Fix | Delete
* Checks whether an upload is too big.
[2080] Fix | Delete
*
[2081] Fix | Delete
* @since MU (3.0.0)
[2082] Fix | Delete
*
[2083] Fix | Delete
* @param array $upload An array of information about the newly-uploaded file.
[2084] Fix | Delete
* @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
[2085] Fix | Delete
*/
[2086] Fix | Delete
function upload_is_file_too_big( $upload ) {
[2087] Fix | Delete
if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) {
[2088] Fix | Delete
return $upload;
[2089] Fix | Delete
}
[2090] Fix | Delete
[2091] Fix | Delete
if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
[2092] Fix | Delete
/* translators: %s: Maximum allowed file size in kilobytes. */
[2093] Fix | Delete
return sprintf( __( 'This file is too big. Files must be less than %s KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) );
[2094] Fix | Delete
}
[2095] Fix | Delete
[2096] Fix | Delete
return $upload;
[2097] Fix | Delete
}
[2098] Fix | Delete
[2099] Fix | Delete
/**
[2100] Fix | Delete
* Adds a nonce field to the signup page.
[2101] Fix | Delete
*
[2102] Fix | Delete
* @since MU (3.0.0)
[2103] Fix | Delete
*/
[2104] Fix | Delete
function signup_nonce_fields() {
[2105] Fix | Delete
$id = mt_rand();
[2106] Fix | Delete
echo "<input type='hidden' name='signup_form_id' value='{$id}' />";
[2107] Fix | Delete
wp_nonce_field( 'signup_form_' . $id, '_signup_form', false );
[2108] Fix | Delete
}
[2109] Fix | Delete
[2110] Fix | Delete
/**
[2111] Fix | Delete
* Processes the signup nonce created in signup_nonce_fields().
[2112] Fix | Delete
*
[2113] Fix | Delete
* @since MU (3.0.0)
[2114] Fix | Delete
*
[2115] Fix | Delete
* @param array $result
[2116] Fix | Delete
* @return array
[2117] Fix | Delete
*/
[2118] Fix | Delete
function signup_nonce_check( $result ) {
[2119] Fix | Delete
if ( ! strpos( $_SERVER['PHP_SELF'], 'wp-signup.php' ) ) {
[2120] Fix | Delete
return $result;
[2121] Fix | Delete
}
[2122] Fix | Delete
[2123] Fix | Delete
if ( ! wp_verify_nonce( $_POST['_signup_form'], 'signup_form_' . $_POST['signup_form_id'] ) ) {
[2124] Fix | Delete
$result['errors']->add( 'invalid_nonce', __( 'Unable to submit this form, please try again.' ) );
[2125] Fix | Delete
}
[2126] Fix | Delete
[2127] Fix | Delete
return $result;
[2128] Fix | Delete
}
[2129] Fix | Delete
[2130] Fix | Delete
/**
[2131] Fix | Delete
* Corrects 404 redirects when NOBLOGREDIRECT is defined.
[2132] Fix | Delete
*
[2133] Fix | Delete
* @since MU (3.0.0)
[2134] Fix | Delete
*/
[2135] Fix | Delete
function maybe_redirect_404() {
[2136] Fix | Delete
if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) ) {
[2137] Fix | Delete
/**
[2138] Fix | Delete
* Filters the redirect URL for 404s on the main site.
[2139] Fix | Delete
*
[2140] Fix | Delete
* The filter is only evaluated if the NOBLOGREDIRECT constant is defined.
[2141] Fix | Delete
*
[2142] Fix | Delete
* @since 3.0.0
[2143] Fix | Delete
*
[2144] Fix | Delete
* @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT.
[2145] Fix | Delete
*/
[2146] Fix | Delete
$destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT );
[2147] Fix | Delete
[2148] Fix | Delete
if ( $destination ) {
[2149] Fix | Delete
if ( '%siteurl%' === $destination ) {
[2150] Fix | Delete
$destination = network_home_url();
[2151] Fix | Delete
}
[2152] Fix | Delete
[2153] Fix | Delete
wp_redirect( $destination );
[2154] Fix | Delete
exit;
[2155] Fix | Delete
}
[2156] Fix | Delete
}
[2157] Fix | Delete
}
[2158] Fix | Delete
[2159] Fix | Delete
/**
[2160] Fix | Delete
* Adds a new user to a blog by visiting /newbloguser/{key}/.
[2161] Fix | Delete
*
[2162] Fix | Delete
* This will only work when the user's details are saved as an option
[2163] Fix | Delete
* keyed as 'new_user_{key}', where '{key}' is a hash generated for the user to be
[2164] Fix | Delete
* added, as when a user is invited through the regular WP Add User interface.
[2165] Fix | Delete
*
[2166] Fix | Delete
* @since MU (3.0.0)
[2167] Fix | Delete
*/
[2168] Fix | Delete
function maybe_add_existing_user_to_blog() {
[2169] Fix | Delete
if ( ! str_contains( $_SERVER['REQUEST_URI'], '/newbloguser/' ) ) {
[2170] Fix | Delete
return;
[2171] Fix | Delete
}
[2172] Fix | Delete
[2173] Fix | Delete
$parts = explode( '/', $_SERVER['REQUEST_URI'] );
[2174] Fix | Delete
$key = array_pop( $parts );
[2175] Fix | Delete
[2176] Fix | Delete
if ( '' === $key ) {
[2177] Fix | Delete
$key = array_pop( $parts );
[2178] Fix | Delete
}
[2179] Fix | Delete
[2180] Fix | Delete
$details = get_option( 'new_user_' . $key );
[2181] Fix | Delete
if ( ! empty( $details ) ) {
[2182] Fix | Delete
delete_option( 'new_user_' . $key );
[2183] Fix | Delete
}
[2184] Fix | Delete
[2185] Fix | Delete
if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) {
[2186] Fix | Delete
wp_die(
[2187] Fix | Delete
sprintf(
[2188] Fix | Delete
/* translators: %s: Home URL. */
[2189] Fix | Delete
__( 'An error occurred adding you to this site. Go to the <a href="%s">homepage</a>.' ),
[2190] Fix | Delete
home_url()
[2191] Fix | Delete
)
[2192] Fix | Delete
);
[2193] Fix | Delete
}
[2194] Fix | Delete
[2195] Fix | Delete
wp_die(
[2196] Fix | Delete
sprintf(
[2197] Fix | Delete
/* translators: 1: Home URL, 2: Admin URL. */
[2198] Fix | Delete
__( 'You have been added to this site. Please visit the <a href="%1$s">homepage</a> or <a href="%2$s">log in</a> using your username and password.' ),
[2199] Fix | Delete
home_url(),
[2200] Fix | Delete
admin_url()
[2201] Fix | Delete
),
[2202] Fix | Delete
__( 'WordPress &rsaquo; Success' ),
[2203] Fix | Delete
array( 'response' => 200 )
[2204] Fix | Delete
);
[2205] Fix | Delete
}
[2206] Fix | Delete
[2207] Fix | Delete
/**
[2208] Fix | Delete
* Adds a user to a blog based on details from maybe_add_existing_user_to_blog().
[2209] Fix | Delete
*
[2210] Fix | Delete
* @since MU (3.0.0)
[2211] Fix | Delete
*
[2212] Fix | Delete
* @param array|false $details {
[2213] Fix | Delete
* User details. Must at least contain values for the keys listed below.
[2214] Fix | Delete
*
[2215] Fix | Delete
* @type int $user_id The ID of the user being added to the current blog.
[2216] Fix | Delete
* @type string $role The role to be assigned to the user.
[2217] Fix | Delete
* }
[2218] Fix | Delete
* @return true|WP_Error|void True on success or a WP_Error object if the user doesn't exist
[2219] Fix | Delete
* or could not be added. Void if $details array was not provided.
[2220] Fix | Delete
*/
[2221] Fix | Delete
function add_existing_user_to_blog( $details = false ) {
[2222] Fix | Delete
if ( is_array( $details ) ) {
[2223] Fix | Delete
$blog_id = get_current_blog_id();
[2224] Fix | Delete
$result = add_user_to_blog( $blog_id, $details['user_id'], $details['role'] );
[2225] Fix | Delete
[2226] Fix | Delete
/**
[2227] Fix | Delete
* Fires immediately after an existing user is added to a site.
[2228] Fix | Delete
*
[2229] Fix | Delete
* @since MU (3.0.0)
[2230] Fix | Delete
*
[2231] Fix | Delete
* @param int $user_id User ID.
[2232] Fix | Delete
* @param true|WP_Error $result True on success or a WP_Error object if the user doesn't exist
[2233] Fix | Delete
* or could not be added.
[2234] Fix | Delete
*/
[2235] Fix | Delete
do_action( 'added_existing_user', $details['user_id'], $result );
[2236] Fix | Delete
[2237] Fix | Delete
return $result;
[2238] Fix | Delete
}
[2239] Fix | Delete
}
[2240] Fix | Delete
[2241] Fix | Delete
/**
[2242] Fix | Delete
* Adds a newly created user to the appropriate blog
[2243] Fix | Delete
*
[2244] Fix | Delete
* To add a user in general, use add_user_to_blog(). This function
[2245] Fix | Delete
* is specifically hooked into the {@see 'wpmu_activate_user'} action.
[2246] Fix | Delete
*
[2247] Fix | Delete
* @since MU (3.0.0)
[2248] Fix | Delete
*
[2249] Fix | Delete
* @see add_user_to_blog()
[2250] Fix | Delete
*
[2251] Fix | Delete
* @param int $user_id User ID.
[2252] Fix | Delete
* @param string $password User password. Ignored.
[2253] Fix | Delete
* @param array $meta Signup meta data.
[2254] Fix | Delete
*/
[2255] Fix | Delete
function add_new_user_to_blog( $user_id, $password, $meta ) {
[2256] Fix | Delete
if ( ! empty( $meta['add_to_blog'] ) ) {
[2257] Fix | Delete
$blog_id = $meta['add_to_blog'];
[2258] Fix | Delete
$role = $meta['new_role'];
[2259] Fix | Delete
remove_user_from_blog( $user_id, get_network()->site_id ); // Remove user from main blog.
[2260] Fix | Delete
[2261] Fix | Delete
$result = add_user_to_blog( $blog_id, $user_id, $role );
[2262] Fix | Delete
[2263] Fix | Delete
if ( ! is_wp_error( $result ) ) {
[2264] Fix | Delete
update_user_meta( $user_id, 'primary_blog', $blog_id );
[2265] Fix | Delete
}
[2266] Fix | Delete
}
[2267] Fix | Delete
}
[2268] Fix | Delete
[2269] Fix | Delete
/**
[2270] Fix | Delete
* Corrects From host on outgoing mail to match the site domain.
[2271] Fix | Delete
*
[2272] Fix | Delete
* @since MU (3.0.0)
[2273] Fix | Delete
*
[2274] Fix | Delete
* @param PHPMailer $phpmailer The PHPMailer instance (passed by reference).
[2275] Fix | Delete
*/
[2276] Fix | Delete
function fix_phpmailer_messageid( $phpmailer ) {
[2277] Fix | Delete
$phpmailer->Hostname = get_network()->domain;
[2278] Fix | Delete
}
[2279] Fix | Delete
[2280] Fix | Delete
/**
[2281] Fix | Delete
* Determines whether a user is marked as a spammer, based on user login.
[2282] Fix | Delete
*
[2283] Fix | Delete
* @since MU (3.0.0)
[2284] Fix | Delete
*
[2285] Fix | Delete
* @param string|WP_User $user Optional. Defaults to current user. WP_User object,
[2286] Fix | Delete
* or user login name as a string.
[2287] Fix | Delete
* @return bool
[2288] Fix | Delete
*/
[2289] Fix | Delete
function is_user_spammy( $user = null ) {
[2290] Fix | Delete
if ( ! ( $user instanceof WP_User ) ) {
[2291] Fix | Delete
if ( $user ) {
[2292] Fix | Delete
$user = get_user_by( 'login', $user );
[2293] Fix | Delete
} else {
[2294] Fix | Delete
$user = wp_get_current_user();
[2295] Fix | Delete
}
[2296] Fix | Delete
}
[2297] Fix | Delete
[2298] Fix | Delete
return $user && isset( $user->spam ) && 1 == $user->spam;
[2299] Fix | Delete
}
[2300] Fix | Delete
[2301] Fix | Delete
/**
[2302] Fix | Delete
* Updates this blog's 'public' setting in the global blogs table.
[2303] Fix | Delete
*
[2304] Fix | Delete
* Public blogs have a setting of 1, private blogs are 0.
[2305] Fix | Delete
*
[2306] Fix | Delete
* @since MU (3.0.0)
[2307] Fix | Delete
*
[2308] Fix | Delete
* @param int $old_value The old public value.
[2309] Fix | Delete
* @param int $value The new public value.
[2310] Fix | Delete
*/
[2311] Fix | Delete
function update_blog_public( $old_value, $value ) {
[2312] Fix | Delete
update_blog_status( get_current_blog_id(), 'public', (int) $value );
[2313] Fix | Delete
}
[2314] Fix | Delete
[2315] Fix | Delete
/**
[2316] Fix | Delete
* Determines whether users can self-register, based on Network settings.
[2317] Fix | Delete
*
[2318] Fix | Delete
* @since MU (3.0.0)
[2319] Fix | Delete
*
[2320] Fix | Delete
* @return bool
[2321] Fix | Delete
*/
[2322] Fix | Delete
function users_can_register_signup_filter() {
[2323] Fix | Delete
$registration = get_site_option( 'registration' );
[2324] Fix | Delete
return ( 'all' === $registration || 'user' === $registration );
[2325] Fix | Delete
}
[2326] Fix | Delete
[2327] Fix | Delete
/**
[2328] Fix | Delete
* Ensures that the welcome message is not empty. Currently unused.
[2329] Fix | Delete
*
[2330] Fix | Delete
* @since MU (3.0.0)
[2331] Fix | Delete
*
[2332] Fix | Delete
* @param string $text
[2333] Fix | Delete
* @return string
[2334] Fix | Delete
*/
[2335] Fix | Delete
function welcome_user_msg_filter( $text ) {
[2336] Fix | Delete
if ( ! $text ) {
[2337] Fix | Delete
remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
[2338] Fix | Delete
[2339] Fix | Delete
/* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */
[2340] Fix | Delete
$text = __(
[2341] Fix | Delete
'Howdy USERNAME,
[2342] Fix | Delete
[2343] Fix | Delete
Your new account is set up.
[2344] Fix | Delete
[2345] Fix | Delete
You can log in with the following information:
[2346] Fix | Delete
Username: USERNAME
[2347] Fix | Delete
Password: PASSWORD
[2348] Fix | Delete
LOGINLINK
[2349] Fix | Delete
[2350] Fix | Delete
Thanks!
[2351] Fix | Delete
[2352] Fix | Delete
--The Team @ SITE_NAME'
[2353] Fix | Delete
);
[2354] Fix | Delete
update_site_option( 'welcome_user_email', $text );
[2355] Fix | Delete
}
[2356] Fix | Delete
return $text;
[2357] Fix | Delete
}
[2358] Fix | Delete
[2359] Fix | Delete
/**
[2360] Fix | Delete
* Determines whether to force SSL on content.
[2361] Fix | Delete
*
[2362] Fix | Delete
* @since 2.8.5
[2363] Fix | Delete
*
[2364] Fix | Delete
* @param bool $force
[2365] Fix | Delete
* @return bool True if forced, false if not forced.
[2366] Fix | Delete
*/
[2367] Fix | Delete
function force_ssl_content( $force = '' ) {
[2368] Fix | Delete
static $forced_content = false;
[2369] Fix | Delete
[2370] Fix | Delete
if ( ! $force ) {
[2371] Fix | Delete
$old_forced = $forced_content;
[2372] Fix | Delete
$forced_content = $force;
[2373] Fix | Delete
return $old_forced;
[2374] Fix | Delete
}
[2375] Fix | Delete
[2376] Fix | Delete
return $forced_content;
[2377] Fix | Delete
}
[2378] Fix | Delete
[2379] Fix | Delete
/**
[2380] Fix | Delete
* Formats a URL to use https.
[2381] Fix | Delete
*
[2382] Fix | Delete
* Useful as a filter.
[2383] Fix | Delete
*
[2384] Fix | Delete
* @since 2.8.5
[2385] Fix | Delete
*
[2386] Fix | Delete
* @param string $url URL.
[2387] Fix | Delete
* @return string URL with https as the scheme.
[2388] Fix | Delete
*/
[2389] Fix | Delete
function filter_SSL( $url ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[2390] Fix | Delete
if ( ! is_string( $url ) ) {
[2391] Fix | Delete
return get_bloginfo( 'url' ); // Return home site URL with proper scheme.
[2392] Fix | Delete
}
[2393] Fix | Delete
[2394] Fix | Delete
if ( force_ssl_content() && is_ssl() ) {
[2395] Fix | Delete
$url = set_url_scheme( $url, 'https' );
[2396] Fix | Delete
}
[2397] Fix | Delete
[2398] Fix | Delete
return $url;
[2399] Fix | Delete
}
[2400] Fix | Delete
[2401] Fix | Delete
/**
[2402] Fix | Delete
* Schedules update of the network-wide counts for the current network.
[2403] Fix | Delete
*
[2404] Fix | Delete
* @since 3.1.0
[2405] Fix | Delete
*/
[2406] Fix | Delete
function wp_schedule_update_network_counts() {
[2407] Fix | Delete
if ( ! is_main_site() ) {
[2408] Fix | Delete
return;
[2409] Fix | Delete
}
[2410] Fix | Delete
[2411] Fix | Delete
if ( ! wp_next_scheduled( 'update_network_counts' ) && ! wp_installing() ) {
[2412] Fix | Delete
wp_schedule_event( time(), 'twicedaily', 'update_network_counts' );
[2413] Fix | Delete
}
[2414] Fix | Delete
}
[2415] Fix | Delete
[2416] Fix | Delete
/**
[2417] Fix | Delete
* Updates the network-wide counts for the current network.
[2418] Fix | Delete
*
[2419] Fix | Delete
* @since 3.1.0
[2420] Fix | Delete
* @since 4.8.0 The `$network_id` parameter has been added.
[2421] Fix | Delete
*
[2422] Fix | Delete
* @param int|null $network_id ID of the network. Default is the current network.
[2423] Fix | Delete
*/
[2424] Fix | Delete
function wp_update_network_counts( $network_id = null ) {
[2425] Fix | Delete
wp_update_network_user_counts( $network_id );
[2426] Fix | Delete
wp_update_network_site_counts( $network_id );
[2427] Fix | Delete
}
[2428] Fix | Delete
[2429] Fix | Delete
/**
[2430] Fix | Delete
* Updates the count of sites for the current network.
[2431] Fix | Delete
*
[2432] Fix | Delete
* If enabled through the {@see 'enable_live_network_counts'} filter, update the sites count
[2433] Fix | Delete
* on a network when a site is created or its status is updated.
[2434] Fix | Delete
*
[2435] Fix | Delete
* @since 3.7.0
[2436] Fix | Delete
* @since 4.8.0 The `$network_id` parameter has been added.
[2437] Fix | Delete
*
[2438] Fix | Delete
* @param int|null $network_id ID of the network. Default is the current network.
[2439] Fix | Delete
*/
[2440] Fix | Delete
function wp_maybe_update_network_site_counts( $network_id = null ) {
[2441] Fix | Delete
$is_small_network = ! wp_is_large_network( 'sites', $network_id );
[2442] Fix | Delete
[2443] Fix | Delete
/**
[2444] Fix | Delete
* Filters whether to update network site or user counts when a new site is created.
[2445] Fix | Delete
*
[2446] Fix | Delete
* @since 3.7.0
[2447] Fix | Delete
*
[2448] Fix | Delete
* @see wp_is_large_network()
[2449] Fix | Delete
*
[2450] Fix | Delete
* @param bool $small_network Whether the network is considered small.
[2451] Fix | Delete
* @param string $context Context. Either 'users' or 'sites'.
[2452] Fix | Delete
*/
[2453] Fix | Delete
if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) {
[2454] Fix | Delete
return;
[2455] Fix | Delete
}
[2456] Fix | Delete
[2457] Fix | Delete
wp_update_network_site_counts( $network_id );
[2458] Fix | Delete
}
[2459] Fix | Delete
[2460] Fix | Delete
/**
[2461] Fix | Delete
* Updates the network-wide users count.
[2462] Fix | Delete
*
[2463] Fix | Delete
* If enabled through the {@see 'enable_live_network_counts'} filter, update the users count
[2464] Fix | Delete
* on a network when a user is created or its status is updated.
[2465] Fix | Delete
*
[2466] Fix | Delete
* @since 3.7.0
[2467] Fix | Delete
* @since 4.8.0 The `$network_id` parameter has been added.
[2468] Fix | Delete
*
[2469] Fix | Delete
* @param int|null $network_id ID of the network. Default is the current network.
[2470] Fix | Delete
*/
[2471] Fix | Delete
function wp_maybe_update_network_user_counts( $network_id = null ) {
[2472] Fix | Delete
$is_small_network = ! wp_is_large_network( 'users', $network_id );
[2473] Fix | Delete
[2474] Fix | Delete
/** This filter is documented in wp-includes/ms-functions.php */
[2475] Fix | Delete
if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) {
[2476] Fix | Delete
return;
[2477] Fix | Delete
}
[2478] Fix | Delete
[2479] Fix | Delete
wp_update_network_user_counts( $network_id );
[2480] Fix | Delete
}
[2481] Fix | Delete
[2482] Fix | Delete
/**
[2483] Fix | Delete
* Updates the network-wide site count.
[2484] Fix | Delete
*
[2485] Fix | Delete
* @since 3.7.0
[2486] Fix | Delete
* @since 4.8.0 The `$network_id` parameter has been added.
[2487] Fix | Delete
*
[2488] Fix | Delete
* @param int|null $network_id ID of the network. Default is the current network.
[2489] Fix | Delete
*/
[2490] Fix | Delete
function wp_update_network_site_counts( $network_id = null ) {
[2491] Fix | Delete
$network_id = (int) $network_id;
[2492] Fix | Delete
if ( ! $network_id ) {
[2493] Fix | Delete
$network_id = get_current_network_id();
[2494] Fix | Delete
}
[2495] Fix | Delete
[2496] Fix | Delete
$count = get_sites(
[2497] Fix | Delete
array(
[2498] Fix | Delete
'network_id' => $network_id,
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function