Make WordPress Core


Ignore:
Timestamp:
08/03/2012 05:51:42 PM (12 years ago)
Author:
ryan
Message:

Deprecate get_blog_option(), add_blog_option(), update_blog_option(), and delete_blog_option().

Use the regular option functions wrapped in switch_to_blog() and restore_current_blog() instead.

Group multiple operations within a single switch where possible.

fixes #21432

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-theme.php

    r21117 r21414  
    11101110        $current = $blog_id == get_current_blog_id();
    11111111
    1112         if ( $current )
     1112        if ( $current ) {
    11131113            $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' );
    1114         else
    1115             $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowedthemes' );
     1114        } else {
     1115            switch_to_blog( $blog_id );
     1116            $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' );
     1117            restore_current_blog();
     1118        }
    11161119
    11171120        // This is all super old MU back compat joy.
    11181121        // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
    11191122        if ( false === $allowed_themes[ $blog_id ] ) {
    1120             if ( $current )
     1123            if ( $current ) {
    11211124                $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' );
    1122             else
    1123                 $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowed_themes' );
     1125            } else {
     1126                switch_to_blog( $blog_id );
     1127                $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' );
     1128                restore_current_blog();
     1129            }
    11241130
    11251131            if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) {
     
    11401146                    delete_option( 'allowed_themes' );
    11411147                } else {
    1142                     update_blog_option( $blog_id, 'allowedthemes', $allowed_themes[ $blog_id ] );
    1143                     delete_blog_option( $blog_id, 'allowed_themes' );
     1148                    switch_to_blog( $blog_id );
     1149                    update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
     1150                    delete_option( 'allowed_themes' );
     1151                    restore_current_blog();
    11441152                }
    11451153            }
Note: See TracChangeset for help on using the changeset viewer.