Make WordPress Core


Ignore:
Timestamp:
08/12/2017 12:47:38 PM (7 years ago)
Author:
flixos90
Message:

Multisite: Rename internal $site_id variables referencing networks to $network_id.

This change improves code clarity by using the current naming conventions for networks.

Props lemacarl.
Fixes #41510.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r41230 r41241  
    11721172 * @since MU (3.0.0)
    11731173 *
    1174  * @param string $domain  The new site's domain.
    1175  * @param string $path    The new site's path.
    1176  * @param string $title   The new site's title.
    1177  * @param int    $user_id The user ID of the new site's admin.
    1178  * @param array  $meta    Optional. Array of key=>value pairs used to set initial site options.
    1179  *                        If valid status keys are included ('public', 'archived', 'mature',
    1180  *                        'spam', 'deleted', or 'lang_id') the given site status(es) will be
    1181  *                        updated. Otherwise, keys and values will be used to set options for
    1182  *                        the new site. Default empty array.
    1183  * @param int    $site_id Optional. Network ID. Only relevant on multi-network installs.
     1174 * @param string $domain     The new site's domain.
     1175 * @param string $path       The new site's path.
     1176 * @param string $title      The new site's title.
     1177 * @param int    $user_id    The user ID of the new site's admin.
     1178 * @param array  $meta       Optional. Array of key=>value pairs used to set initial site options.
     1179 *                           If valid status keys are included ('public', 'archived', 'mature',
     1180 *                           'spam', 'deleted', or 'lang_id') the given site status(es) will be
     1181 *                           updated. Otherwise, keys and values will be used to set options for
     1182 *                           the new site. Default empty array.
     1183 * @param int    $network_id Optional. Network ID. Only relevant on multi-network installs.
    11841184 * @return int|WP_Error Returns WP_Error object on failure, the new site ID on success.
    11851185 */
    1186 function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) {
     1186function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $network_id = 1 ) {
    11871187    $defaults = array(
    11881188        'public' => 0,
    1189         'WPLANG' => get_network_option( $site_id, 'WPLANG' ),
     1189        'WPLANG' => get_network_option( $network_id, 'WPLANG' ),
    11901190    );
    11911191    $meta = wp_parse_args( $meta, $defaults );
     
    12031203
    12041204    // Check if the domain has been used already. We should return an error message.
    1205     if ( domain_exists($domain, $path, $site_id) )
     1205    if ( domain_exists($domain, $path, $network_id) )
    12061206        return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
    12071207
     
    12101210    }
    12111211
    1212     if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
     1212    if ( ! $blog_id = insert_blog($domain, $path, $network_id) )
    12131213        return new WP_Error('insert_blog', __('Could not create site.'));
    12141214
     
    12371237     * @since MU (3.0.0)
    12381238     *
    1239      * @param int    $blog_id Site ID.
    1240      * @param int    $user_id User ID.
    1241      * @param string $domain  Site domain.
    1242      * @param string $path    Site path.
    1243      * @param int    $site_id Network ID. Only relevant on multi-network installs.
    1244      * @param array  $meta    Meta data. Used to set initial site options.
    1245      */
    1246     do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta );
     1239     * @param int    $blog_id    Site ID.
     1240     * @param int    $user_id    User ID.
     1241     * @param string $domain     Site domain.
     1242     * @param string $path       Site path.
     1243     * @param int    $network_id Network ID. Only relevant on multi-network installs.
     1244     * @param array  $meta       Meta data. Used to set initial site options.
     1245     */
     1246    do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $network_id, $meta );
    12471247
    12481248    wp_cache_set( 'last_changed', microtime(), 'sites' );
     
    13511351 * @global wpdb $wpdb WordPress database abstraction object.
    13521352 *
    1353  * @param string $domain  The domain to be checked.
    1354  * @param string $path    The path to be checked.
    1355  * @param int    $site_id Optional. Relevant only on multi-network installs.
     1353 * @param string $domain     The domain to be checked.
     1354 * @param string $path       The path to be checked.
     1355 * @param int    $network_id Optional. Network ID. Relevant only on multi-network installs.
    13561356 * @return int
    13571357 */
    1358 function domain_exists($domain, $path, $site_id = 1) {
     1358function domain_exists( $domain, $path, $network_id = 1 ) {
    13591359    $path = trailingslashit( $path );
    13601360    $args = array(
    1361         'network_id' => $site_id,
    1362         'domain' => $domain,
    1363         'path' => $path,
    1364         'fields' => 'ids',
     1361        'network_id' => $network_id,
     1362        'domain'     => $domain,
     1363        'path'       => $path,
     1364        'fields'     => 'ids',
    13651365    );
    13661366    $result = get_sites( $args );
     
    13721372     * @since 3.5.0
    13731373     *
    1374      * @param int|null $result  The blog_id if the blogname exists, null otherwise.
    1375      * @param string   $domain  Domain to be checked.
    1376      * @param string   $path    Path to be checked.
    1377      * @param int      $site_id Site ID. Relevant only on multi-network installs.
    1378      */
    1379     return apply_filters( 'domain_exists', $result, $domain, $path, $site_id );
     1374     * @param int|null $result     The blog_id if the blogname exists, null otherwise.
     1375     * @param string   $domain     Domain to be checked.
     1376     * @param string   $path       Path to be checked.
     1377     * @param int      $network_id Network ID. Relevant only on multi-network installs.
     1378     */
     1379    return apply_filters( 'domain_exists', $result, $domain, $path, $network_id );
    13801380}
    13811381
     
    13901390 * @global wpdb $wpdb WordPress database abstraction object.
    13911391 *
    1392  * @param string $domain  The domain of the new site.
    1393  * @param string $path    The path of the new site.
    1394  * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
     1392 * @param string $domain     The domain of the new site.
     1393 * @param string $path       The path of the new site.
     1394 * @param int    $network_id Unless you're running a multi-network install, be sure to set this value to 1.
    13951395 * @return int|false The ID of the new row
    13961396 */
    1397 function insert_blog($domain, $path, $site_id) {
     1397function insert_blog($domain, $path, $network_id) {
    13981398    global $wpdb;
    13991399
    14001400    $path = trailingslashit($path);
    1401     $site_id = (int) $site_id;
    1402 
    1403     $result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
     1401    $network_id = (int) $network_id;
     1402
     1403    $result = $wpdb->insert( $wpdb->blogs, array('site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
    14041404    if ( ! $result )
    14051405        return false;
     
    14081408    refresh_blog_details( $blog_id );
    14091409
    1410     wp_maybe_update_network_site_counts( $site_id );
     1410    wp_maybe_update_network_site_counts( $network_id );
    14111411
    14121412    return $blog_id;
Note: See TracChangeset for help on using the changeset viewer.