Make WordPress Core

Changeset 41241


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.

Location:
trunk/src
Files:
5 edited

Legend:

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

    r41219 r41241  
    788788 * Whether or not we can edit this network from this page.
    789789 *
    790  * By default editing of network is restricted to the Network Admin for that `$site_id`
    791  * this allows for this to be overridden.
     790 * By default editing of network is restricted to the Network Admin for that `$network_id`.
     791 * This function allows for this to be overridden.
    792792 *
    793793 * @since 3.1.0
     
    795795 * @global wpdb $wpdb WordPress database abstraction object.
    796796 *
    797  * @param int $site_id The network/site ID to check.
     797 * @param int $network_id The network ID to check.
    798798 * @return bool True if network can be edited, otherwise false.
    799799 */
    800 function can_edit_network( $site_id ) {
     800function can_edit_network( $network_id ) {
    801801    global $wpdb;
    802802
    803     if ( $site_id == $wpdb->siteid )
     803    if ( $network_id == $wpdb->siteid )
    804804        $result = true;
    805805    else
     
    811811     * @since 3.1.0
    812812     *
    813      * @param bool $result  Whether the network can be edited from this page.
    814      * @param int  $site_id The network/site ID to check.
     813     * @param bool $result     Whether the network can be edited from this page.
     814     * @param int  $network_id The network ID to check.
    815815     */
    816     return apply_filters( 'can_edit_network', $result, $site_id );
     816    return apply_filters( 'can_edit_network', $result, $network_id );
    817817}
    818818
  • trunk/src/wp-includes/ms-deprecated.php

    r41200 r41241  
    421421 * @global wpdb $wpdb WordPress database abstraction object.
    422422 *
    423  * @param string $sitedomain Optional. Site domain.
    424  * @param string $path       Optional. Site path.
    425  * @return array|false The network admins
    426  */
    427 function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
     423 * @param string $domain Optional. Network domain.
     424 * @param string $path   Optional. Network path.
     425 * @return array|false The network admins.
     426 */
     427function get_admin_users_for_domain( $domain = '', $path = '' ) {
    428428    _deprecated_function( __FUNCTION__, '4.4.0' );
    429429
    430430    global $wpdb;
    431431
    432     if ( ! $sitedomain )
    433         $site_id = $wpdb->siteid;
     432    if ( ! $domain )
     433        $network_id = $wpdb->siteid;
    434434    else
    435         $site_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path ) );
    436 
    437     if ( $site_id )
    438         return $wpdb->get_results( $wpdb->prepare( "SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $site_id ), ARRAY_A );
     435        $network_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path ) );
     436
     437    if ( $network_id )
     438        return $wpdb->get_results( $wpdb->prepare( "SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $network_id ), ARRAY_A );
    439439
    440440    return false;
  • 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;
  • trunk/src/wp-includes/option.php

    r41013 r41241  
    215215 * @global wpdb $wpdb WordPress database abstraction object.
    216216 *
    217  * @param int $site_id Optional site ID for which to query the options. Defaults to the current site.
    218  */
    219 function wp_load_core_site_options( $site_id = null ) {
     217 * @param int $network_id Optional site ID for which to query the options. Defaults to the current site.
     218 */
     219function wp_load_core_site_options( $network_id = null ) {
    220220    global $wpdb;
    221221
     
    223223        return;
    224224
    225     if ( empty($site_id) )
    226         $site_id = $wpdb->siteid;
     225    if ( empty($network_id) )
     226        $network_id = $wpdb->siteid;
    227227
    228228    $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
    229229
    230230    $core_options_in = "'" . implode("', '", $core_options) . "'";
    231     $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
     231    $options = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $network_id ) );
    232232
    233233    foreach ( $options as $option ) {
    234234        $key = $option->meta_key;
    235         $cache_key = "{$site_id}:$key";
     235        $cache_key = "{$network_id}:$key";
    236236        $option->meta_value = maybe_unserialize( $option->meta_value );
    237237
  • trunk/src/wp-includes/wp-db.php

    r41162 r41241  
    894894     *
    895895     * @param int $blog_id
    896      * @param int $site_id Optional.
     896     * @param int $network_id Optional.
    897897     * @return int previous blog id
    898898     */
    899     public function set_blog_id( $blog_id, $site_id = 0 ) {
    900         if ( ! empty( $site_id ) )
    901             $this->siteid = $site_id;
     899    public function set_blog_id( $blog_id, $network_id = 0 ) {
     900        if ( ! empty( $network_id ) ) {
     901            $this->siteid = $network_id;
     902        }
    902903
    903904        $old_blog_id  = $this->blogid;
Note: See TracChangeset for help on using the changeset viewer.