Changeset 9698
- Timestamp:
- 04/05/2015 06:18:13 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-template.php
r9665 r9698 296 296 297 297 // Check if blog/forum replies are disabled 298 $this->disable_blogforum_replies = isset( $bp->site_options['bp-disable-blogforum-comments'] ) ? $bp->site_options['bp-disable-blogforum-comments'] : false;298 $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disabled-blogforum-comments' ); 299 299 300 300 // Get an array of the logged in user's favorite activities -
trunk/src/bp-blogs/bp-blogs-filters.php
r9472 r9698 87 87 * That plugin changed the way its settings were stored at some point. Thus the dual check. 88 88 */ 89 if ( ! empty( $bp->site_options['sitewide_tags_blog'] ) ) { 90 $st_options = maybe_unserialize( $bp->site_options['sitewide_tags_blog'] ); 89 $sitewide_tags_blog_settings = bp_core_get_root_option( 'sitewide_tags_blog' ); 90 if ( ! empty( $sitewide_tags_blog_settings ) ) { 91 $st_options = maybe_unserialize( $sitewide_tags_blog_settings ); 91 92 $tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0; 92 93 } else { 93 $tags_blog_id = isset( $bp->site_options['tags_blog_id'] ) ? $bp->site_options['tags_blog_id'] : 0; 94 $tags_blog_id = bp_core_get_root_option( 'sitewide_tags_blog' ); 95 $tags_blog_id = intval( $tags_blog_id ); 94 96 } 95 97 -
trunk/src/bp-core/bp-core-avatars.php
r9624 r9698 32 32 if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) { 33 33 34 if ( !isset( $bp->site_options['fileupload_maxk'] ) ) { 34 $fileupload_maxk = bp_core_get_root_option( 'fileupload_maxk' ); 35 if ( '' === $fileupload_maxk ) { 35 36 define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 ); // 5mb 36 37 } else { 37 define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $ bp->site_options['fileupload_maxk']* 1024 );38 define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $fileupload_maxk * 1024 ); 38 39 } 39 40 } -
trunk/src/bp-core/bp-core-options.php
r9598 r9698 482 482 } 483 483 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 */ 496 function 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 484 511 /** Active? *******************************************************************/ 485 512 -
trunk/src/bp-core/bp-core-template.php
r9618 r9698 820 820 } 821 821 822 $status = b uddypress()->site_options['registration'];822 $status = bp_core_get_root_option( 'registration' ); 823 823 if ( ( 'none' !== $status ) && ( 'user' !== $status ) ) { 824 824 return true; -
trunk/src/bp-forums/bp-forums-loader.php
r9351 r9698 58 58 59 59 // The location of the bbPress stand-alone config file 60 if ( isset( $bp->site_options['bb-config-location'] ) ) 61 $this->bbconfig = $bp->site_options['bb-config-location']; 60 $bbconfig = bp_core_get_root_option( 'bb-config-location' ); 61 if ( '' !== $bbconfig ) 62 $this->bbconfig = $bbconfig; 62 63 63 64 // All globals for messaging component. -
trunk/src/bp-groups/bp-groups-loader.php
r9454 r9698 299 299 300 300 // If avatar uploads are not disabled, add avatar option 301 if ( ! (int) $bp->site_options['bp-disable-avatar-uploads'] && $bp->avatar->show_avatars ) { 301 $disabled_avatar_uploads = (int) bp_core_get_root_option( 'bp-disable-avatar-uploads' ); 302 if ( ! $disabled_avatar_uploads && $bp->avatar->show_avatars ) { 302 303 $this->group_creation_steps['group-avatar'] = array( 303 304 'name' => _x( 'Photo', 'Group screen nav', 'buddypress' ), -
trunk/src/bp-members/bp-members-screens.php
r9471 r9698 157 157 // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled 158 158 if ( isset( $_POST['signup_with_blog'] ) ) { 159 $active_signup = $bp->site_options['registration'];159 $active_signup = bp_core_get_root_option( 'registration' ); 160 160 161 161 if ( 'blog' == $active_signup || 'all' == $active_signup ) { … … 197 197 198 198 // No errors! Let's register those deets. 199 $active_signup = !empty( $bp->site_options['registration'] ) ? $bp->site_options['registration'] : '';199 $active_signup = bp_core_get_root_option( 'registration' ); 200 200 201 201 if ( 'none' != $active_signup ) { -
trunk/src/bp-members/bp-members-template.php
r9665 r9698 2245 2245 2246 2246 if ( is_multisite() ) { 2247 if ( ! isset( $bp->site_options ) ) { 2248 $bp->site_options = bp_core_get_root_options(); 2249 } 2250 2251 if ( in_array( $bp->site_options['registration'], array( 'all', 'user' ) ) ) { 2247 $registration = bp_core_get_root_option( 'registration' ); 2248 2249 if ( in_array( $registration, array( 'all', 'user' ) ) ) { 2252 2250 $signup_allowed = true; 2253 2251 } -
trunk/src/bp-settings/bp-settings-loader.php
r9351 r9698 184 184 185 185 // Delete Account 186 if ( !bp_current_user_can( 'bp_moderate' ) && empty( $bp->site_options['bp-disable-account-deletion']) ) {186 if ( !bp_current_user_can( 'bp_moderate' ) && ! bp_core_get_root_option( 'bp-disable-account-deletion' ) ) { 187 187 $wp_admin_nav[] = array( 188 188 'parent' => 'my-account-' . $this->id, -
trunk/src/bp-xprofile/bp-xprofile-loader.php
r9676 r9698 96 96 // Defined conditionally to accommodate unit tests 97 97 if ( ! defined( 'BP_XPROFILE_BASE_GROUP_NAME' ) ) { 98 define( 'BP_XPROFILE_BASE_GROUP_NAME', stripslashes( $bp->site_options['bp-xprofile-base-group-name']) );98 define( 'BP_XPROFILE_BASE_GROUP_NAME', stripslashes( bp_core_get_root_option( 'avatar_default' ) ) ); 99 99 } 100 100 101 101 if ( ! defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) ) { 102 define( 'BP_XPROFILE_FULLNAME_FIELD_NAME', stripslashes( $bp->site_options['bp-xprofile-fullname-field-name']) );102 define( 'BP_XPROFILE_FULLNAME_FIELD_NAME', stripslashes( bp_core_get_root_option( 'bp-xprofile-fullname-field-name' ) ) ); 103 103 } 104 104 -
trunk/tests/phpunit/testcases/core/functions.php
r9616 r9698 522 522 523 523 /** 524 * @group bp_core_get_root_option 525 */ 526 public function test_bp_core_get_root_option_with_unpopulated_cache() { 527 // Back up and unset global cache. 528 $old_options = buddypress()->site_options; 529 unset( buddypress()->site_options ); 530 531 $this->assertSame( $old_options['avatar_default'], bp_core_get_root_option( 'avatar_default' ) ); 532 533 // Clean up. 534 buddypress()->site_options = $old_options; 535 } 536 537 /** 538 * @group bp_core_get_root_option 539 */ 540 public function test_bp_core_get_root_option_with_populated_cache() { 541 // Back up and unset global cache. 542 $old_options = buddypress()->site_options; 543 buddypress()->site_options = bp_core_get_root_options(); 544 $expected = buddypress()->site_options['avatar_default']; 545 546 $this->assertSame( $expected, bp_core_get_root_option( 'avatar_default' ) ); 547 } 548 549 /** 524 550 * @group bp_core_add_root_component 525 551 */
Note: See TracChangeset
for help on using the changeset viewer.