Ticket #5130: 5130.01b.patch
| File 5130.01b.patch, 24.4 KB (added by , 13 years ago) |
|---|
-
bp-activity/bp-activity-functions.php
function bp_activity_new_comment( $args = '' ) { 1201 1201 // Clear the comment cache for this activity 1202 1202 wp_cache_delete( 'bp_activity_comments_' . $parent_id ); 1203 1203 1204 do_action( 'bp_activity_comment_posted', $comment_id, $params );1204 do_action( 'bp_activity_comment_posted', $comment_id, $params, $activity ); 1205 1205 1206 1206 return $comment_id; 1207 1207 } … … function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) { 1657 1657 do_action( 'bp_activity_mark_as_ham', $activity, $source ); 1658 1658 } 1659 1659 1660 1661 1660 /** Embeds *******************************************************************/ 1662 1661 1663 1662 /** -
bp-blogs/bp-blogs-activity.php
function bp_blogs_delete_activity( $args = true ) { 128 128 'secondary_item_id' => $secondary_item_id 129 129 ) ); 130 130 } 131 132 /** 133 * Syncs activity comments and posts them back as blog comments. 134 * 135 * Note: This is only a one-way sync - activity comments -> blog comment. 136 * 137 * For blog post -> activity comment, see {@link bp_blogs_record_comment()}. 138 * 139 * @since BuddyPress (1.9) 140 * 141 * @param int $comment_id The activity ID for the posted activity comment. 142 * @param array $params Parameters for the activity comment. 143 * @param obj Parameters of the parent activity item (in this case, the blog post). 144 */ 145 function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_activity ) { 146 // if parent activity isn't a blog post, stop now! 147 if ( $parent_activity->type != 'new_blog_post' ) { 148 return; 149 } 150 151 // if activity comments are disabled for blog posts, stop now! 152 if ( bp_disable_blogforum_comments() ) { 153 return; 154 } 155 156 // get userdata 157 if ( $params['user_id'] == bp_loggedin_user_id() ) { 158 $user = buddypress()->loggedin_user->userdata; 159 } else { 160 $user = bp_core_get_core_userdata( $params['user_id'] ); 161 } 162 163 // see if a parent WP comment ID exists 164 if ( ! empty( $params['parent_id'] ) ) { 165 $comment_parent = bp_activity_get_meta( $params['parent_id'], 'bp_blogs_post_comment_id' ); 166 } else { 167 $comment_parent = 0; 168 } 169 170 // comment args 171 $args = array( 172 'comment_post_ID' => $parent_activity->secondary_item_id, 173 174 // should this use display name? 175 // using username for now 176 'comment_author' => bp_core_get_username( $params['user_id'], $user->user_nicename, $user->user_login ), 177 178 'comment_author_email' => $user->user_email, 179 'comment_author_url' => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ), 180 'comment_content' => $params['content'], 181 'comment_type' => '', // could be interesting to add 'buddypress' here... 182 'comment_parent' => (int) $comment_parent, 183 'user_id' => $params['user_id'], 184 185 // commenting these out for now 186 //'comment_author_IP' => '127.0.0.1', 187 //'comment_agent' => '', 188 189 'comment_approved' => 1 190 ); 191 192 // prevent separate activity entry being made 193 remove_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 ); 194 195 // handle multisite 196 switch_to_blog( $parent_activity->item_id ); 197 198 // handle timestamps for the WP comment after we've switched to the blog 199 $args['comment_date'] = current_time( 'mysql' ); 200 $args['comment_date_gmt'] = current_time( 'mysql', 1 ); 201 202 // post the comment 203 $post_comment_id = wp_insert_comment( $args ); 204 205 // add meta to comment 206 add_comment_meta( $post_comment_id, 'bp_activity_comment_id', $comment_id ); 207 208 // add meta to activity comment 209 bp_activity_update_meta( $comment_id, 'bp_blogs_post_comment_id', $post_comment_id ); 210 211 // resave activity comment with WP comment permalink 212 // 213 // in bp_blogs_activity_comment_permalink(), we change activity comment 214 // permalinks to use the post comment link 215 // 216 // @todo since this is done after AJAX posting, the activity comment permalink 217 // doesn't change on the frontend until the next page refresh. 218 $resave_activity = new BP_Activity_Activity( $comment_id ); 219 $resave_activity->primary_link = get_comment_link( $post_comment_id ); 220 $resave_activity->save(); 221 222 // multisite again! 223 restore_current_blog(); 224 225 // add the comment hook back 226 add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 ); 227 228 do_action( 'bp_blogs_sync_add_from_activity_comment', $comment_id, $args, $parent_activity, $user ); 229 } 230 231 /** 232 * Deletes the blog comment when the associated activity comment is deleted. 233 * 234 * @since BuddyPress (1.9) 235 * 236 * @param int $activity_id The activity ID for the posted activity comment. 237 * @param array $params Parameters for the activity comment. 238 * @param obj Parameters of the parent activity item (in this case, the blog post). 239 */ 240 function bp_blogs_sync_delete_from_activity_comment( $activity_id, $comment_id ) { 241 // query args 242 $query_args = array( 243 'meta_query' => array( 244 array( 245 'key' => 'bp_activity_comment_id', 246 'value' => $comment_id 247 ) 248 ) 249 ); 250 251 // get comment 252 $comment_query = new WP_Comment_Query; 253 $comment = $comment_query->query( $query_args ); 254 255 // no comment? stop now! 256 if ( empty( $comment[0] ) ) { 257 return; 258 } else { 259 $comment = $comment[0]; 260 } 261 262 // delete the comment 263 // we force delete the comment, since activity items are deleted immediately 264 wp_delete_comment( $comment->comment_ID, true ); 265 } 266 267 /** 268 * Disable activity commenting for blog posts based on certain criteria. 269 * 270 * If activity commenting is enabled for blog posts, we still need to disable 271 * commenting if: 272 * - comments are disabled for the WP blog post from the admin dashboard 273 * - the WP blog post is supposed to be automatically closed from comments 274 * based on a certain age 275 * - the activity entry is a 'new_blog_comment' type 276 * 277 * @since BuddyPress (1.9) 278 * 279 * @param bool $retval Is activity commenting enabled for this activity entry? 280 * @return bool 281 */ 282 function bp_blogs_disable_activity_commenting( $retval ) { 283 // if activity commenting is disabled, return current value 284 if ( bp_disable_blogforum_comments() ) { 285 return $retval; 286 } 287 288 // activity commenting is enabled for blog posts 289 switch ( bp_get_activity_action_name() ) { 290 291 // we still have to disable activity commenting for 'new_blog_comment' items 292 // commenting should only be done on the parent 'new_blog_post' item 293 case 'new_blog_comment' : 294 $retval = false; 295 296 break; 297 298 // check if commenting is disabled for the WP blog post 299 // we should extrapolate this and automate this for plugins... or not 300 case 'new_blog_post' : 301 302 // BP's 'comments_open' filter trumps all! 303 // so we have to remove it temporarily 304 remove_filter( 'comments_open', 'bp_comments_open', 10, 2 ); 305 306 switch_to_blog( bp_get_activity_item_id() ); 307 308 // check if the WP post allows comments 309 // this also checks if comments should be closed based on age if enabled 310 $allow_comments = comments_open( bp_get_activity_secondary_item_id() ); 311 312 restore_current_blog(); 313 314 // reinstate BP's comment filter 315 add_filter( 'comments_open', 'bp_comments_open', 10, 2 ); 316 317 // if comments are closed for the WP blog post, we should disable 318 // activity comments for this activity entry 319 if ( ! $allow_comments ) { 320 $retval = false; 321 } 322 323 // initialize a local object so we don't have to query this again 324 if ( empty( buddypress()->activity->new_blog_post ) ) { 325 buddypress()->activity->new_blog_post = new stdClass; 326 buddypress()->activity->new_blog_post->allow_comments = array(); 327 } 328 329 // cache comment setting in the buddypress() singleton for later reference 330 // @see bp_blogs_disable_activity_replies() 331 buddypress()->activity->new_blog_post->allow_comments[bp_get_activity_id()] = $allow_comments; 332 333 break; 334 } 335 336 return $retval; 337 } 338 add_filter( 'bp_activity_can_comment', 'bp_blogs_disable_activity_commenting' ); 339 340 /** 341 * Disables replying to activity comments if the corresponding WP blog post no 342 * longer accepts comments. 343 * 344 * This check uses a locally-cached value set in {@link bp_blogs_disable_activity_commenting()}. 345 * 346 * @since BuddyPress (1.9) 347 * 348 * @param bool $retval Are replies allowed for this activity reply? 349 * @param obj $comment The activity comment object 350 * @return bool 351 */ 352 function bp_blogs_disable_activity_replies( $retval, $comment ) { 353 // check if we should disable activity replies based on the parent activity 354 if ( isset( buddypress()->activity->new_blog_post->allow_comments[$comment->item_id] ) ){ 355 // the blog post has closed off commenting, so we should disable all activity 356 // comments under the parent 'new_blog_post' activity entry 357 if ( empty( buddypress()->activity->new_blog_post->allow_comments[$comment->item_id] ) ) { 358 $retval = false; 359 } 360 } 361 362 return $retval; 363 } 364 add_filter( 'bp_activity_can_comment_reply', 'bp_blogs_disable_activity_replies', 10, 2 ); 365 366 /** 367 * Changes activity comment permalinks to use the blog comment permalink 368 * instead of the activity permalink. 369 * 370 * This is only done if activity commenting is allowed and whether the parent 371 * activity item is a 'new_blog_post' entry. 372 * 373 * @since BuddyPress (1.9) 374 * 375 * @param str $retval The activity comment permalink 376 * @return str 377 */ 378 function bp_blogs_activity_comment_permalink( $retval ) { 379 global $activities_template; 380 381 if ( isset( buddypress()->activity->new_blog_post->allow_comments[$activities_template->activity->current_comment->item_id] ) ){ 382 $retval = $activities_template->activity->current_comment->primary_link; 383 } 384 385 return $retval; 386 } 387 add_filter( 'bp_get_activity_comment_permalink', 'bp_blogs_activity_comment_permalink' ); -
bp-blogs/bp-blogs-functions.php
function bp_blogs_record_comment( $comment_id, $is_approved = true ) { 362 362 $post_permalink = get_permalink( $recorded_comment->comment_post_ID ); 363 363 $comment_link = get_comment_link( $recorded_comment->comment_ID ); 364 364 365 // Prepare to record in activity streams 366 if ( is_multisite() ) 367 $activity_action = sprintf( __( '%1$s commented on the post, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' ); 368 else 369 $activity_action = sprintf( __( '%1$s commented on the post, %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' ); 365 // Setup activity args 366 $args = array(); 367 368 $args['user_id'] = $user_id; 369 $args['content'] = apply_filters_ref_array( 'bp_blogs_activity_new_comment_content', array( $recorded_comment->comment_content, &$recorded_comment, $comment_link ) ); 370 $args['primary_link'] = apply_filters_ref_array( 'bp_blogs_activity_new_comment_primary_link', array( $comment_link, &$recorded_comment ) ); 371 $args['recorded_time'] = $recorded_comment->comment_date_gmt; 372 373 if ( is_multisite() ) { 374 $args['action'] = sprintf( __( '%1$s commented on the post, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' ); 375 } else { 376 $args['action'] = sprintf( __( '%1$s commented on the post, %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' ); 377 } 370 378 371 $activity_content = $recorded_comment->comment_content; 379 // Setup some different activity args depending if activity commenting is 380 // enabled or not 381 382 // if cannot comment, record separate activity entry 383 // this is the old way of doing things 384 if ( bp_disable_blogforum_comments() ) { 385 $args['type'] = 'new_blog_comment'; 386 $args['item_id'] = $blog_id; 387 $args['secondary_item_id'] = $comment_id; 388 389 // record the activity entry 390 bp_blogs_record_activity( $args ); 391 392 // record comment as BP activity comment under the parent 'new_blog_post' 393 // activity item 394 } else { 395 // find the parent 'new_blog_post' activity entry 396 $parent_activity_id = bp_activity_get_activity_id( array( 397 'user_id' => $user_id, 398 'component' => 'blogs', 399 'type' => 'new_blog_post', 400 'item_id' => $blog_id, 401 'secondary_item_id' => $recorded_comment->comment_post_ID 402 ) ); 403 404 // we found the parent activity entry 405 // so let's go ahead and reconfigure some activity args 406 if ( ! empty( $parent_activity_id ) ) { 407 // set the 'item_id' with the parent activity entry ID 408 $args['item_id'] = $parent_activity_id; 409 410 // now see if the WP parent comment has a BP activity ID 411 $comment_parent = 0; 412 if ( ! empty( $recorded_comment->comment_parent ) ) { 413 $comment_parent = get_comment_meta( $recorded_comment->comment_parent, 'bp_activity_comment_id', true ); 414 } 372 415 373 // Record in activity streams 374 bp_blogs_record_activity( array( 375 'user_id' => $user_id, 376 'action' => apply_filters_ref_array( 'bp_blogs_activity_new_comment_action', array( $activity_action, &$recorded_comment, $comment_link ) ), 377 'content' => apply_filters_ref_array( 'bp_blogs_activity_new_comment_content', array( $activity_content, &$recorded_comment, $comment_link ) ), 378 'primary_link' => apply_filters_ref_array( 'bp_blogs_activity_new_comment_primary_link', array( $comment_link, &$recorded_comment ) ), 379 'type' => 'new_blog_comment', 380 'item_id' => $blog_id, 381 'secondary_item_id' => $comment_id, 382 'recorded_time' => $recorded_comment->comment_date_gmt 383 ) ); 416 // WP parent comment does not have a BP activity ID 417 // so set to 'new_blog_post' activity ID 418 if ( empty( $comment_parent ) ) { 419 $comment_parent = $parent_activity_id; 420 } 421 422 $args['secondary_item_id'] = $comment_parent; 423 $args['component'] = 'activity'; 424 $args['type'] = 'activity_comment'; 425 426 // could not find corresponding parent activity entry 427 // so wipe out $args array 428 } else { 429 $args = array(); 430 } 431 432 // Record in activity streams 433 if ( ! empty( $args ) ) { 434 // @todo should we use bp_activity_new_comment()? that function will also send 435 // an email to people in the activity comment thread 436 // 437 // what if a site already has some comment email notification plugin setup? 438 // this is why I decided to go with bp_activity_add() to avoid any conflict 439 // with existing comment email notification plugins 440 $comment_activity_id = bp_activity_add( $args ); 441 442 // add meta to activity comment 443 bp_activity_update_meta( $comment_activity_id, 'bp_blogs_post_comment_id', $comment_id ); 444 445 // add meta to comment 446 add_comment_meta( $comment_id, 'bp_activity_comment_id', $comment_activity_id ); 447 } 448 } 384 449 385 450 // Update the blogs last active date 386 451 bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() ); … … function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) { 504 569 add_action( 'delete_post', 'bp_blogs_remove_post' ); 505 570 506 571 function bp_blogs_remove_comment( $comment_id ) { 507 global $wpdb;508 572 509 // Delete activity stream item 510 bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid, 'secondary_item_id' => $comment_id, 'type' => 'new_blog_comment' ) ); 573 // activity comments are disabled for blog posts 574 // which means that individual activity items exist for blog comments 575 if ( bp_disable_blogforum_comments() ) { 576 global $wpdb; 577 578 // Delete the individual activity stream item 579 bp_blogs_delete_activity( array( 580 'item_id' => $wpdb->blogid, 581 'secondary_item_id' => $comment_id, 582 'type' => 'new_blog_comment' 583 ) ); 584 585 // activity comments are enabled for blog posts 586 // remove the associated activity item 587 } else { 588 // get associated activity ID from comment meta 589 $activity_id = get_comment_meta( $comment_id, 'bp_activity_comment_id', true ); 590 591 // delete the associated activity comment 592 // 593 // @todo WP moves nested comments up a level when a comment is deleted, 594 // while BP deletes all nested activity comments... 595 // 596 // right now, we're simply deleting the singular activity comment 597 // with bp_activity_delete() and not using bp_activity_delete_comment() 598 // b/c that deletes activity comment children 599 // 600 // this needs further research: 601 // - how hard would it be to emulate WP's model? 602 // - what would happen if BP_Activity_Activity::rebuild_activity_comment_tree() 603 // is used when the main activity comment is not deleted? 604 if ( ! empty( $activity_id )) { 605 bp_activity_delete( array( 606 'id' => $activity_id 607 ) ); 608 609 /* WORK IN PROGRESS 610 // bp_activity_delete() needs to support multiple IDs for mass deletion 611 // and a "exclude_comments" from deletion parameter 612 // 613 // get WP comment children IDs 614 $comment_child_ids = bp_blogs_get_comment_children_ids( $comment_id ); 615 616 // delete all WP child comments 617 if ( ! empty( $comment_child_ids ) ) { 618 foreach( $comment_child_ids as $comment_child_id ) { 619 wp_delete_comment( $comment_child_id, true ); 620 } 621 } 622 */ 623 624 } 625 } 511 626 512 627 do_action( 'bp_blogs_remove_comment', $wpdb->blogid, $comment_id, bp_loggedin_user_id() ); 513 628 } 514 629 add_action( 'delete_comment', 'bp_blogs_remove_comment' ); 515 630 516 631 /** 632 * Utility function to get all WP comment children IDs. 633 * 634 * Pass the WP comment ID and this function will try to grab all other comment 635 * children IDs. 636 * 637 * @since BuddyPress (1.9) 638 * 639 * @param int $comment_id The WP comment ID to check for. 640 * @param array $comment_ids Mainly used for recursion purposes. 641 * @return array 642 */ 643 function bp_blogs_get_comment_children_ids( $comment_id, $comment_ids = array() ) { 644 global $wpdb; 645 646 // search for any comments that are a direct child of our comment 647 $search = $wpdb->get_results( 648 $wpdb->prepare( 649 "SELECT comment_id FROM {$wpdb->comments} WHERE comment_parent = %d", 650 $comment_id 651 ) 652 ); 653 654 // grab the comment IDs from our search 655 $new_comment_ids = wp_list_pluck( (array) $search, 'comment_id' ); 656 657 // merge comments with existing comment IDs 658 if ( ! empty( $new_comment_ids ) ) { 659 $comment_ids = $comment_ids + $new_comment_ids; 660 } 661 662 // okay, we have additional comments from our search 663 // now, we have to use recursion to get every other child 664 if ( ! empty( $new_comment_ids ) ) { 665 foreach( $new_comment_ids as $new_comment_id ) { 666 $comment_ids = bp_blogs_get_comment_children_ids( $new_comment_id, $comment_ids ); 667 } 668 } 669 670 return $comment_ids; 671 } 672 673 /** 517 674 * When a blog comment status transition occurs, update the relevant activity's status. 518 675 * 519 676 * @global object $bp BuddyPress global settings -
bp-blogs/bp-blogs-loader.php
class BP_Blogs_Component extends BP_Component { 61 61 62 62 // Setup the globals 63 63 parent::setup_globals( $args ); 64 65 // Activity comment post callback 66 $this->activity_comment_post_callback = apply_filters( 'bp_blogs_activity_comment_post_callback', array( 67 'add' => 'bp_blogs_sync_add_from_activity_comment', 68 'delete' => 'bp_blogs_sync_delete_from_activity_comment' 69 ) ); 64 70 } 65 71 66 72 /** -
bp-core/bp-core-component.php
class BP_Component { 247 247 public function setup_actions() { 248 248 249 249 // Setup globals 250 add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 );250 add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 ); 251 251 252 252 // Include required files. Called early to ensure that BP core 253 253 // components are loaded before plugins that hook their loader functions 254 254 // to bp_include with the default priority of 10. This is for backwards 255 255 // compatibility; henceforth, plugins should register themselves by 256 256 // extending this base class. 257 add_action( 'bp_include', array( $this, 'includes' ), 8);257 add_action( 'bp_include', array( $this, 'includes' ), 10 ); 258 258 259 259 // Setup navigation 260 add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 10 );260 add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 10 ); 261 261 262 262 // Setup WP Toolbar menus 263 add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar' ), 10 );263 add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar' ), 10 ); 264 264 265 265 // Setup component title 266 add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 );266 add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 ); 267 267 268 268 // Register post types 269 add_action( 'bp_register_post_types', array( $this, 'register_post_types' ), 10 );269 add_action( 'bp_register_post_types', array( $this, 'register_post_types' ), 10 ); 270 270 271 271 // Register taxonomies 272 add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies' ), 10 );272 add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies' ), 10 ); 273 273 274 274 // Add the rewrite tags 275 add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags' ), 10 );275 add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags' ), 10 ); 276 276 277 277 // Generate rewrite rules 278 add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 ); 278 add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 ); 279 280 // Activity comment callback setup 281 add_action( 'bp_setup_globals', array( $this, 'activity_comment_post_callback' ), 10 ); 279 282 280 283 // Additional actions can be attached here 281 284 do_action( 'bp_' . $this->id . '_setup_actions' ); … … class BP_Component { 394 397 public function generate_rewrite_rules() { 395 398 do_action( 'bp_' . $this->id . '_generate_rewrite_rules' ); 396 399 } 400 401 /** 402 * Setup activity comment post callback. 403 * 404 * If a component has the 'activity_comment_post_callback' property set, 405 * automatically setup the hooks to be used. 406 * 407 * @since BuddyPress (1.9) 408 */ 409 public function activity_comment_post_callback() { 410 // if activity component is not active or callback is not an array, stop now! 411 if ( ! bp_is_active( 'activity' ) || ! is_array( $this->activity_comment_post_callback ) ) { 412 return; 413 } 414 415 $callback = $this->activity_comment_post_callback; 416 417 // Activity comment addition callback 418 if ( ! empty( $callback['add'] ) && is_callable( $callback['add'] ) ) { 419 add_action( 'bp_activity_comment_posted', $callback['add'], 10, 3 ); 420 } 421 422 // Activity comment deletion callback 423 if ( ! empty( $callback['delete'] ) && is_callable( $callback['delete'] ) ) { 424 add_action( 'bp_activity_delete_comment', $callback['delete'], 10, 2 ); 425 } 426 427 } 397 428 } 398 429 endif; // BP_Component -
bp-core/bp-core-options.php
function bp_pre_get_option( $value = false ) { 202 202 * @return mixed The value for the option 203 203 */ 204 204 function bp_get_option( $option_name, $default = '' ) { 205 $value = get_blog_option( bp_get_root_blog_id(), $option_name, $default ); 205 // check buddypress()->site_options array first 206 if ( isset( buddypress()->site_options[$option_name] ) ) { 207 $value = buddypress()->site_options[$option_name]; 208 209 // query for the option if not available 210 } else { 211 $value = get_blog_option( bp_get_root_blog_id(), $option_name, $default ); 212 } 206 213 207 214 return apply_filters( 'bp_get_option', $value ); 208 215 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)