Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/12/2014 01:34:45 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Clean up to bp-core-options.php:

  • Brackets
  • Replace $bp global with buddypress()
  • Use array_keys() to avoid creating $value variables
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-options.php

    r8668 r8812  
    150150
    151151    // Add default options
    152     foreach ( $options as $key => $value )
     152    foreach ( array_keys( $options ) as $key ) {
    153153        delete_option( $key );
     154    }
    154155
    155156    // Allow previously activated plugins to append their own options.
     
    174175
    175176    // Add filters to each BuddyPress option
    176     foreach ( $options as $key => $value )
     177    foreach ( array_keys( $options ) as $key ) {
    177178        add_filter( 'pre_option_' . $key, 'bp_pre_get_option' );
     179    }
    178180
    179181    // Allow previously activated plugins to append their own options.
     
    188190 * @since BuddyPress (1.6)
    189191 *
    190  * @global BuddyPress $bp
    191192 * @param bool $value Optional. Default value false
    192193 * @return mixed false if not overloaded, mixed if set
    193194 */
    194195function bp_pre_get_option( $value = false ) {
    195     global $bp;
     196    $bp = buddypress();
    196197
    197198    // Get the name of the current filter so we can manipulate it
     
    202203
    203204    // Check the options global for preset value
    204     if ( !empty( $bp->options[$option] ) )
    205         $value = $bp->options[$option];
     205    if ( ! empty( $bp->options[ $option ] ) ) {
     206        $value = $bp->options[ $option ];
     207    }
    206208
    207209    // Always return a value, even if false
     
    383385            // Loop through options
    384386            foreach ( $root_blog_options as $old_meta_key => $old_meta_default ) {
    385                 // Clear out the value from the last time around
    386                 unset( $old_meta_value );
    387387
    388388                if ( isset( $existing_options[$old_meta_key] ) ) {
     
    391391
    392392                // Get old site option
    393                 if ( is_multisite() )
     393                if ( is_multisite() ) {
    394394                    $old_meta_value = get_site_option( $old_meta_key );
     395                }
    395396
    396397                // No site option so look in root blog
    397                 if ( empty( $old_meta_value ) )
     398                if ( empty( $old_meta_value ) ) {
    398399                    $old_meta_value = bp_get_option( $old_meta_key, $old_meta_default );
     400                }
    399401
    400402                // Update the root blog option
     
    403405                // Update the global array
    404406                $root_blog_options_meta[$old_meta_key] = $old_meta_value;
     407
     408                // Clear out the value for the next time around
     409                unset( $old_meta_value );
    405410            }
    406411
     
    411416        } else {
    412417            // Loop through our results and make them usable
    413             foreach ( $root_blog_options_meta as $root_blog_option )
     418            foreach ( $root_blog_options_meta as $root_blog_option ) {
    414419                $root_blog_options[$root_blog_option->name] = $root_blog_option->value;
     420            }
    415421
    416422            // Copy the options no the return val
Note: See TracChangeset for help on using the changeset viewer.