Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/05/2015 06:18:13 PM (5 years ago)
Author:
boonebgorges
Message:

Introduce bp_core_get_root_option() and use throughout BP.

Previously, we referenced the $bp->site_options array directly. This causes
problems in cases where these options may be referenced before the array is
initially populated. bp_core_get_root_option() will fetch the requested
value from the array if it's been populated, and will populate it if it has not.

Fixes #6045.

File:
1 edited

Legend:

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

    r9598 r9698  
    482482}
    483483
     484/**
     485 * Get a root option.
     486 *
     487 * "Root options" are those that apply across an entire installation, and are fetched only a single
     488 * time during a pageload and stored in `buddypress()->site_options` to prevent future lookups.
     489 * See {@see bp_core_get_root_options()}.
     490 *
     491 * @since BuddyPress (2.3.0)
     492 *
     493 * @param  string $option Name of the option key.
     494 * @return mixed Value, if found.
     495 */
     496function bp_core_get_root_option( $option ) {
     497    $bp = buddypress();
     498
     499    if ( ! isset( $bp->site_options ) ) {
     500        $bp->site_options = bp_core_get_root_options();
     501    }
     502
     503    $value = '';
     504    if ( isset( $bp->site_options[ $option ] ) ) {
     505        $value = $bp->site_options[ $option ];
     506    }
     507
     508    return $value;
     509}
     510
    484511/** Active? *******************************************************************/
    485512
Note: See TracChangeset for help on using the changeset viewer.