Ticket #5130: 5130.06.patch
| File 5130.06.patch, 45.9 KB (added by , 12 years ago) |
|---|
-
bp-activity/admin/css/admin.css
75 75 #bp-activities-primaryid { 76 76 margin-bottom: 1em; 77 77 } 78 .column-action { 79 width: 12%; 80 } 81 No newline at end of file -
bp-activity/admin/css/admin.min.css
1 .akismet-status{float:right}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:white}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em} 2 No newline at end of file 1 .akismet-status{float:right}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:white}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}.column-action{width:12%} 2 No newline at end of file -
bp-activity/bp-activity-admin.php
458 458 459 459 // Activity type 460 460 if ( ! empty( $_POST['bp-activities-type'] ) ) { 461 $actions = array(); 462 463 // Walk through the registered actions, and build an array of actions/values. 464 foreach ( $bp->activity->actions as $action ) { 465 $action = array_values( (array) $action ); 466 467 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) 468 $actions[] = $action[$i]['key']; 469 } 470 471 // This was a mis-named activity type from before BP 1.6 472 unset( $actions['friends_register_activity_action'] ); 461 $actions = bp_activity_admin_get_activity_actions(); 473 462 474 463 // Check that the new type is a registered activity type 475 if ( in_array( $_POST['bp-activities-type'], $actions ) ) 464 if ( in_array( $_POST['bp-activities-type'], $actions ) ) { 476 465 $activity->type = $_POST['bp-activities-type']; 466 } 477 467 } 478 468 479 469 // Activity timestamp … … 736 726 } 737 727 738 728 /** 739 * Activity type metabox for the Activity admin edit screen729 * Get flattened array of all registered activity actions. 740 730 * 741 * @since BuddyPress (1.6.0)731 * Format is [activity_type] => Pretty name for activity type. 742 732 * 743 * @ global object $bp BuddyPress global settings.733 * @since BuddyPress (2.0.0) 744 734 * 745 * @ param object $item Activity item.735 * @return array 746 736 */ 747 function bp_activity_admin_edit_metabox_type( $item ) { 748 global $bp; 749 737 function bp_activity_admin_get_activity_actions() { 750 738 $actions = array(); 751 $selected = $item->type;752 739 753 740 // Walk through the registered actions, and build an array of actions/values. 754 foreach ( $bp->activity->actions as $action ) {741 foreach ( buddypress()->activity->actions as $action ) { 755 742 $action = array_values( (array) $action ); 756 743 757 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) 744 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) { 758 745 $actions[ $action[$i]['key'] ] = $action[$i]['value']; 746 } 759 747 } 760 748 761 749 // This was a mis-named activity type from before BP 1.6 … … 764 752 // Sort array by the human-readable value 765 753 natsort( $actions ); 766 754 755 return $actions; 756 } 757 758 /** 759 * Activity type metabox for the Activity admin edit screen 760 * 761 * @since BuddyPress (1.6.0) 762 * 763 * @global object $bp BuddyPress global settings. 764 * 765 * @param object $item Activity item. 766 */ 767 function bp_activity_admin_edit_metabox_type( $item ) { 768 $actions = bp_activity_admin_get_activity_actions(); 769 $selected = $item->type; 770 767 771 // If the activity type is not registered properly (eg, a plugin has 768 772 // not called bp_activity_set_action()), add the raw type to the end 769 773 // of the list … … 974 978 */ 975 979 public function __construct() { 976 980 981 // See if activity commenting is enabled for blog / forum activity items 982 $this->disable_blogforum_comments = bp_disable_blogforum_comments(); 983 977 984 // Define singular and plural labels, as well as whether we support AJAX. 978 985 parent::__construct( array( 979 986 'ajax' => false, … … 1217 1224 'cb' => '<input name type="checkbox" />', 1218 1225 'author' => __( 'Author', 'buddypress' ), 1219 1226 'comment' => __( 'Activity', 'buddypress' ), 1227 'action' => __( 'Action', 'buddypress' ), 1220 1228 'response' => __( 'In Response To', 'buddypress' ), 1221 1229 ); 1222 1230 } … … 1300 1308 } 1301 1309 1302 1310 /** 1311 * Action column markup. 1312 * 1313 * @since BuddyPress (2.0.0) 1314 * 1315 * @see WP_List_Table::single_row_columns() 1316 * 1317 * @param array $item A singular item (one full row). 1318 */ 1319 function column_action( $item ) { 1320 $actions = bp_activity_admin_get_activity_actions(); 1321 1322 if ( isset( $actions[ $item['type'] ] ) ) { 1323 echo $actions[ $item['type'] ]; 1324 } else { 1325 printf( __( 'Unregistered action - %s', 'buddypress' ), $item['type'] ); 1326 } 1327 } 1328 1329 /** 1303 1330 * Content column, and "quick admin" rollover actions. 1304 1331 * 1305 1332 * Called "comment" in the CSS so we can re-use some WP core CSS. … … 1338 1365 1339 1366 // Reply - javascript only; implemented by AJAX. 1340 1367 if ( 'spam' != $item_status ) { 1341 $actions['reply'] = sprintf( '<a href="#" class="reply hide-if-no-js">%s</a>', __( 'Reply', 'buddypress' ) ); 1368 if ( $this->can_comment( $item ) ) { 1369 $actions['reply'] = sprintf( '<a href="#" class="reply hide-if-no-js">%s</a>', __( 'Reply', 'buddypress' ) ); 1370 } else { 1371 $actions['reply'] = sprintf( '<span class="form-input-tip" title="%s">%s</span>', __( 'Replies are disabled for this activity item', 'buddypress' ), __( 'Replies disabled', 'buddypress' ) ); 1372 } 1342 1373 1343 1374 // Edit 1344 1375 $actions['edit'] = sprintf( '<a href="%s">%s</a>', $edit_url, __( 'Edit', 'buddypress' ) ); … … 1445 1476 } 1446 1477 1447 1478 /** 1479 * Checks if an activity item can be replied to. 1480 * 1481 * This method merges functionality from {@link bp_activity_can_comment()} and 1482 * {@link bp_blogs_disable_activity_commenting()}. This is done because the activity 1483 * list table doesn't use a BuddyPress activity loop, which prevents those 1484 * functions from working as intended. 1485 * 1486 * @since BuddyPress (2.0.0) 1487 * 1488 * @param array $item An array version of the BP_Activity_Activity object. 1489 * @return bool 1490 */ 1491 protected function can_comment( $item ) { 1492 $can_comment = true; 1493 1494 if ( $this->disable_blogforum_comments ) { 1495 switch ( $item['type'] ) { 1496 case 'new_blog_post' : 1497 case 'new_blog_comment' : 1498 case 'new_forum_topic' : 1499 case 'new_forum_post' : 1500 $can_comment = false; 1501 break; 1502 } 1503 1504 // activity comments require special checking 1505 } elseif ( 'activity_comment' == $item['type'] ) { 1506 // blogs 1507 if ( bp_is_active( 'blogs' ) ) { 1508 // grab the parent activity entry 1509 $parent_activity = new BP_Activity_Activity( $item['item_id'] ); 1510 1511 // fetch blog post comment depth and if the blog post's comments are open 1512 bp_blogs_setup_activity_loop_globals( $parent_activity ); 1513 1514 // check if the activity item can be replied to 1515 if ( false === bp_blogs_can_comment_reply( true, $item ) ) { 1516 $can_comment = false; 1517 } 1518 } 1519 } 1520 1521 return apply_filters( 'bp_activity_list_table_can_comment', $can_comment ); 1522 } 1523 1524 /** 1448 1525 * Flatten the activity array. 1449 1526 * 1450 1527 * In some cases, BuddyPress gives us a structured tree of activity -
bp-activity/bp-activity-functions.php
1522 1522 * You may want to hook into this filter if you want to override this function and 1523 1523 * handle the deletion of child comments differently. Make sure you return false. 1524 1524 */ 1525 if ( !apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) 1526 return false; 1525 if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) { 1526 return true; 1527 } 1527 1528 1528 1529 // Delete any children of this comment. 1529 1530 bp_activity_delete_children( $activity_id, $comment_id ); -
bp-activity/bp-activity-template.php
2972 2972 } 2973 2973 2974 2974 /** 2975 * Recurse through all activity comments and return the activity comment IDs. 2976 * 2977 * @since BuddyPress (2.0.0) 2978 * 2979 * @param array $activity Array of activities generated from {@link bp_activity_get()}. 2980 * @return array 2981 */ 2982 function bp_activity_recurse_comments_activity_ids( $activity = array(), $activity_ids = array() ) { 2983 if ( is_array( $activity ) && ! empty( $activity['activities'] ) ) { 2984 $activity = $activity['activities'][0]; 2985 } 2986 2987 if ( ! empty( $activity->children ) ) { 2988 foreach ($activity->children as $child ) { 2989 $activity_ids[] = $child->id; 2990 2991 if( ! empty( $child->children ) ) { 2992 $activity_ids = bp_activity_recurse_comments_activity_ids( $child, $activity_ids ); 2993 } 2994 } 2995 } 2996 2997 return $activity_ids; 2998 } 2999 3000 /** 2975 3001 * Output the mentionname for the displayed user. 2976 3002 * 2977 3003 * @since BuddyPress (1.9.0) -
bp-blogs/bp-blogs-activity.php
345 345 'secondary_item_id' => $secondary_item_id 346 346 ) ); 347 347 } 348 349 /** 350 * Check if a blog post's activity item should be closed from commenting. 351 * 352 * This mirrors the {@link comments_open()} and {@link _close_comments_for_old_post()} 353 * functions, but for use with the BuddyPress activity stream to be as 354 * lightweight as possible. 355 * 356 * By lightweight, we actually mirror a few of the blog's commenting settings 357 * to blogmeta and checks the values in blogmeta instead. This is to prevent 358 * multiple {@link switch_to_blog()} calls in the activity stream. 359 * 360 * @param object $activity The BP_Activity_Activity object 361 * @return bool 362 */ 363 function bp_blogs_comments_open( $activity ) { 364 $open = true; 365 366 $blog_id = $activity->item_id; 367 368 // see if we've mirrored the close comments option before 369 $days_old = bp_blogs_get_blogmeta( $blog_id, 'close_comments_days_old' ); 370 371 // we've never cached these items before, so do it now 372 if ( '' === $days_old ) { 373 switch_to_blog( $blog_id ); 374 375 // use comments_open() 376 remove_filter( 'comments_open', 'bp_comments_open', 10, 2 ); 377 $open = comments_open( $activity->secondary_item_id ); 378 add_filter( 'comments_open', 'bp_comments_open', 10, 2 ); 379 380 // might as well mirror values to blogmeta since we're here! 381 $thread_depth = get_option( 'thread_comments' ); 382 if ( ! empty( $thread_depth ) ) { 383 $thread_depth = get_option( 'thread_comments_depth' ); 384 } else { 385 // perhaps filter this? 386 $thread_depth = 1; 387 } 388 389 bp_blogs_update_blogmeta( $blog_id, 'close_comments_for_old_posts', get_option( 'close_comments_for_old_posts' ) ); 390 bp_blogs_update_blogmeta( $blog_id, 'close_comments_days_old', get_option( 'close_comments_days_old' ) ); 391 bp_blogs_update_blogmeta( $blog_id, 'thread_comments_depth', $thread_depth ); 392 393 restore_current_blog(); 394 395 // check blogmeta and manually check activity item 396 // basically a copy of _close_comments_for_old_post() 397 } else { 398 399 // comments are closed 400 if ( 'closed' == bp_activity_get_meta( $activity->id, 'post_comment_status' ) ) { 401 return false; 402 } 403 404 if ( ! bp_blogs_get_blogmeta( $blog_id, 'close_comments_for_old_posts' ) ) { 405 return $open; 406 } 407 408 $days_old = (int) $days_old; 409 if ( ! $days_old ) { 410 return $open; 411 } 412 413 /* commenting out for now - needs some more thought... 414 should we add the post type to activity meta? 415 416 $post = get_post($post_id); 417 418 // This filter is documented in wp-includes/comment.php 419 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); 420 if ( ! in_array( $post->post_type, $post_types ) ) 421 return $open; 422 */ 423 424 if ( time() - strtotime( $activity->date_recorded ) > ( $days_old * DAY_IN_SECONDS ) ) { 425 return false; 426 } 427 428 return $open; 429 } 430 431 return $open; 432 } 433 434 /** POST COMMENT SYNCHRONIZATION ****************************************/ 435 436 /** 437 * Syncs activity comments and posts them back as blog comments. 438 * 439 * Note: This is only a one-way sync - activity comments -> blog comment. 440 * 441 * For blog post -> activity comment, see {@link bp_blogs_record_comment()}. 442 * 443 * @since BuddyPress (2.0.0) 444 * 445 * @param int $comment_id The activity ID for the posted activity comment. 446 * @param array $params Parameters for the activity comment. 447 * @param object Parameters of the parent activity item (in this case, the blog post). 448 */ 449 function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_activity ) { 450 // if parent activity isn't a blog post, stop now! 451 if ( $parent_activity->type != 'new_blog_post' ) { 452 return; 453 } 454 455 // if activity comments are disabled for blog posts, stop now! 456 if ( bp_disable_blogforum_comments() ) { 457 return; 458 } 459 460 // get userdata 461 if ( $params['user_id'] == bp_loggedin_user_id() ) { 462 $user = buddypress()->loggedin_user->userdata; 463 } else { 464 $user = bp_core_get_core_userdata( $params['user_id'] ); 465 } 466 467 // see if a parent WP comment ID exists 468 if ( ! empty( $params['parent_id'] ) ) { 469 $comment_parent = bp_activity_get_meta( $params['parent_id'], 'bp_blogs_post_comment_id' ); 470 } else { 471 $comment_parent = 0; 472 } 473 474 // comment args 475 $args = array( 476 'comment_post_ID' => $parent_activity->secondary_item_id, 477 'comment_author' => bp_core_get_user_displayname( $params['user_id'] ), 478 'comment_author_email' => $user->user_email, 479 'comment_author_url' => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ), 480 'comment_content' => $params['content'], 481 'comment_type' => '', // could be interesting to add 'buddypress' here... 482 'comment_parent' => (int) $comment_parent, 483 'user_id' => $params['user_id'], 484 485 // commenting these out for now 486 //'comment_author_IP' => '127.0.0.1', 487 //'comment_agent' => '', 488 489 'comment_approved' => 1 490 ); 491 492 // prevent separate activity entry being made 493 remove_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 ); 494 495 // handle multisite 496 switch_to_blog( $parent_activity->item_id ); 497 498 // handle timestamps for the WP comment after we've switched to the blog 499 $args['comment_date'] = current_time( 'mysql' ); 500 $args['comment_date_gmt'] = current_time( 'mysql', 1 ); 501 502 // post the comment 503 $post_comment_id = wp_insert_comment( $args ); 504 505 // add meta to comment 506 add_comment_meta( $post_comment_id, 'bp_activity_comment_id', $comment_id ); 507 508 // add meta to activity comment 509 bp_activity_update_meta( $comment_id, 'bp_blogs_post_comment_id', $post_comment_id ); 510 511 // resave activity comment with WP comment permalink 512 // 513 // in bp_blogs_activity_comment_permalink(), we change activity comment 514 // permalinks to use the post comment link 515 // 516 // @todo since this is done after AJAX posting, the activity comment permalink 517 // doesn't change on the frontend until the next page refresh. 518 $resave_activity = new BP_Activity_Activity( $comment_id ); 519 $resave_activity->primary_link = get_comment_link( $post_comment_id ); 520 $resave_activity->save(); 521 522 // multisite again! 523 restore_current_blog(); 524 525 // add the comment hook back 526 add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 ); 527 528 do_action( 'bp_blogs_sync_add_from_activity_comment', $comment_id, $args, $parent_activity, $user ); 529 } 530 add_action( 'bp_activity_comment_posted', 'bp_blogs_sync_add_from_activity_comment', 10, 3 ); 531 532 /** 533 * Deletes the blog comment when the associated activity comment is deleted. 534 * 535 * Note: This is hooked on the 'bp_activity_delete_comment_pre' filter instead 536 * of the 'bp_activity_delete_comment' action because we need to fetch the 537 * activity comment children before they are deleted. 538 * 539 * @since BuddyPress (2.0.0) 540 * 541 * @param bool $retval 542 * @param int $parent_activity_id The parent activity ID for the activity comment. 543 * @param int $activity_id The activity ID for the pending deleted activity comment. 544 */ 545 function bp_blogs_sync_delete_from_activity_comment( $retval, $parent_activity_id, $activity_id ) { 546 // check if parent activity is a blog post 547 $parent_activity = new BP_Activity_Activity( $parent_activity_id ); 548 if ( 'new_blog_post' != $parent_activity->type ) { 549 return $retval; 550 } 551 552 // fetch the activity comments for the activity item 553 $activity = bp_activity_get( array( 554 'in' => $activity_id, 555 'display_comments' => 'stream', 556 ) ); 557 558 // get all activity comment IDs for the pending deleted item 559 $activity_ids = bp_activity_recurse_comments_activity_ids( $activity ); 560 $activity_ids[] = $activity_id; 561 562 // handle multisite 563 // switch to the blog where the comment was made 564 switch_to_blog( $parent_activity->item_id ); 565 566 // remove associated blog comments 567 bp_blogs_remove_associated_blog_comments( $activity_ids, current_user_can( 'moderate_comments' ) ); 568 569 // multisite again! 570 restore_current_blog(); 571 572 // rebuild activity comment tree 573 // emulate bp_activity_delete_comment() 574 BP_Activity_Activity::rebuild_activity_comment_tree( $parent_activity_id ); 575 576 // we're overriding the default bp_activity_delete_comment() functionality 577 // so we need to return false 578 return false; 579 } 580 add_filter( 'bp_activity_delete_comment_pre', 'bp_blogs_sync_delete_from_activity_comment', 10, 3 ); 581 582 /** 583 * Updates the blog comment when the associated activity comment is edited. 584 * 585 * @since BuddyPress (2.0.0) 586 * 587 * @param BP_Activity_Activity $activity The activity object. 588 */ 589 function bp_blogs_sync_activity_edit_to_post_comment( BP_Activity_Activity $activity ) { 590 // not an activity comment? stop now! 591 if ( 'activity_comment' !== $activity->type ) { 592 return; 593 } 594 595 // this is a new entry, so stop! 596 // we only want edits! 597 if ( empty( $activity->id ) ) { 598 return; 599 } 600 601 // prevent recursion 602 remove_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 ); 603 604 // Try to see if a corresponding blog comment exists 605 $post_comment_id = bp_activity_get_meta( $activity->id, 'bp_blogs_post_comment_id' ); 606 607 if ( empty( $post_comment_id ) ) { 608 return; 609 } 610 611 // fetch parent activity item 612 $parent_activity = new BP_Activity_Activity( $activity->item_id ); 613 614 // sanity check 615 if ( 'new_blog_post' !== $parent_activity->type ) { 616 return; 617 } 618 619 // handle multisite 620 switch_to_blog( $parent_activity->item_id ); 621 622 // update the blog post comment 623 wp_update_comment( array( 624 'comment_ID' => $post_comment_id, 625 'comment_content' => $activity->content 626 ) ); 627 628 restore_current_blog(); 629 } 630 add_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 ); 631 632 /** 633 * When a post is trashed, remove each comment's associated activity meta. 634 * 635 * When a post is trashed and later untrashed, we currently don't reinstate 636 * activity items for these comments since their activity entries are already 637 * deleted when initially trashed. 638 * 639 * Since these activity entries are deleted, we need to remove the deleted 640 * activity comment IDs from each comment's meta when a post is trashed. 641 * 642 * @since BuddyPress (2.0.0) 643 * 644 * @param int $post_id The post ID 645 * @param array $statuses Array of comment statuses. The key is comment ID, the 646 * value is the $comment->comment_approved value. 647 */ 648 function bp_blogs_remove_activity_meta_for_trashed_comments( $post_id, $statuses ) { 649 foreach ( $statuses as $comment_id => $comment_approved ) { 650 delete_comment_meta( $comment_id, 'bp_activity_comment_id' ); 651 } 652 } 653 add_action( 'trashed_post_comments', 'bp_blogs_remove_activity_meta_for_trashed_comments', 10, 2 ); 654 655 /** 656 * Utility function to set up some variables for use in the activity loop. 657 * 658 * Grabs the blog's comment depth and the post's open comment status options 659 * for later use in the activity and activity comment loops. 660 * 661 * This is to prevent having to requery these items later on. 662 * 663 * @since BuddyPress (2.0.0) 664 * 665 * @see bp_blogs_disable_activity_commenting() 666 * @see bp_blogs_setup_comment_loop_globals_on_ajax() 667 * 668 * @param object $activity The BP_Activity_Activity object 669 */ 670 function bp_blogs_setup_activity_loop_globals( $activity ) { 671 if ( ! is_object( $activity ) ) { 672 return; 673 } 674 675 // parent not a blog post? stop now! 676 if ( 'new_blog_post' !== $activity->type ) { 677 return; 678 } 679 680 if ( empty( $activity->id ) ) { 681 return; 682 } 683 684 // if we've already done this before, stop now! 685 if ( isset( buddypress()->blogs->allow_comments[ $activity->id ] ) ) { 686 return; 687 } 688 689 $allow_comments = bp_blogs_comments_open( $activity ); 690 $thread_depth = bp_blogs_get_blogmeta( $activity->item_id, 'thread_comments_depth' ); 691 692 // initialize a local object so we won't have to query this again in the 693 // comment loop 694 if ( empty( buddypress()->blogs->allow_comments ) ) { 695 buddypress()->blogs->allow_comments = array(); 696 } 697 if ( empty( buddypress()->blogs->thread_depth ) ) { 698 buddypress()->blogs->thread_depth = array(); 699 } 700 701 // cache comment settings in the buddypress() singleton to reference later in 702 // the activity comment loop 703 // @see bp_blogs_disable_activity_replies() 704 // 705 // thread_depth is keyed by activity ID instead of blog ID because when we're 706 // in a comment loop, we don't have access to the blog ID... 707 // should probably object cache these values instead... 708 buddypress()->blogs->allow_comments[ $activity->id ] = $allow_comments; 709 buddypress()->blogs->thread_depth[ $activity->id ] = $thread_depth; 710 } 711 712 /** 713 * Set up some globals used in the activity comment loop when AJAX is used. 714 * 715 * @since BuddyPress (2.0.0) 716 * 717 * @see bp_blogs_setup_activity_loop_globals() 718 */ 719 function bp_blogs_setup_comment_loop_globals_on_ajax() { 720 // not AJAX? stop now! 721 if ( ! defined( 'DOING_AJAX' ) ) { 722 return; 723 } 724 if ( false === (bool) constant( 'DOING_AJAX' ) ) { 725 return; 726 } 727 728 // get the parent activity item 729 $comment = bp_activity_current_comment(); 730 $parent_activity = new BP_Activity_Activity( $comment->item_id ); 731 732 // setup the globals 733 bp_blogs_setup_activity_loop_globals( $parent_activity ); 734 } 735 add_action( 'bp_before_activity_comment', 'bp_blogs_setup_comment_loop_globals_on_ajax' ); 736 737 /** 738 * Disable activity commenting for blog posts based on certain criteria. 739 * 740 * If activity commenting is enabled for blog posts, we still need to disable 741 * commenting if: 742 * - comments are disabled for the WP blog post from the admin dashboard 743 * - the WP blog post is supposed to be automatically closed from comments 744 * based on a certain age 745 * - the activity entry is a 'new_blog_comment' type 746 * 747 * @since BuddyPress (2.0.0) 748 * 749 * @param bool $retval Is activity commenting enabled for this activity entry? 750 * @return bool 751 */ 752 function bp_blogs_disable_activity_commenting( $retval ) { 753 // if activity commenting is disabled, return current value 754 if ( bp_disable_blogforum_comments() ) { 755 return $retval; 756 } 757 758 // activity commenting is enabled for blog posts 759 switch ( bp_get_activity_action_name() ) { 760 761 // we still have to disable activity commenting for 'new_blog_comment' items 762 // commenting should only be done on the parent 'new_blog_post' item 763 case 'new_blog_comment' : 764 $retval = false; 765 766 break; 767 768 // check if commenting is disabled for the WP blog post 769 // we should extrapolate this and automate this for plugins... or not 770 case 'new_blog_post' : 771 global $activities_template; 772 773 // setup some globals we'll need to reference later 774 bp_blogs_setup_activity_loop_globals( $activities_template->activity ); 775 776 // if comments are closed for the WP blog post, we should disable 777 // activity comments for this activity entry 778 if ( empty( buddypress()->blogs->allow_comments[bp_get_activity_id()] ) ) { 779 $retval = false; 780 } 781 782 break; 783 } 784 785 return $retval; 786 } 787 add_filter( 'bp_activity_can_comment', 'bp_blogs_disable_activity_commenting' ); 788 789 /** 790 * Check if an activity comment associated with a blog post can be replied to. 791 * 792 * By default, disables replying to activity comments if the corresponding WP 793 * blog post no longer accepts comments. 794 * 795 * This check uses a locally-cached value set in {@link bp_blogs_disable_activity_commenting()} 796 * via {@link bp_blogs_setup_activity_loop_globals()}. 797 * 798 * @since BuddyPress (2.0.0) 799 * 800 * @param bool $retval Are replies allowed for this activity reply? 801 * @param object $comment The activity comment object 802 * @return bool 803 */ 804 function bp_blogs_can_comment_reply( $retval, $comment ) { 805 if ( is_array( $comment ) ) { 806 $comment = (object) $comment; 807 } 808 809 // check comment depth and disable if depth is too large 810 if ( isset( buddypress()->blogs->thread_depth[$comment->item_id] ) ){ 811 if ( $comment->mptt_left > buddypress()->blogs->thread_depth[$comment->item_id] ) { 812 $retval = false; 813 } 814 } 815 816 // check if we should disable activity replies based on the parent activity 817 if ( isset( buddypress()->blogs->allow_comments[$comment->item_id] ) ){ 818 // the blog post has closed off commenting, so we should disable all activity 819 // comments under the parent 'new_blog_post' activity entry 820 if ( empty( buddypress()->blogs->allow_comments[$comment->item_id] ) ) { 821 $retval = false; 822 } 823 } 824 825 return $retval; 826 } 827 add_filter( 'bp_activity_can_comment_reply', 'bp_blogs_can_comment_reply', 10, 2 ); 828 829 /** 830 * Changes activity comment permalinks to use the blog comment permalink 831 * instead of the activity permalink. 832 * 833 * This is only done if activity commenting is allowed and whether the parent 834 * activity item is a 'new_blog_post' entry. 835 * 836 * @since BuddyPress (2.0.0) 837 * 838 * @param string $retval The activity comment permalink 839 * @return string 840 */ 841 function bp_blogs_activity_comment_permalink( $retval ) { 842 global $activities_template; 843 844 if ( isset( buddypress()->blogs->allow_comments[$activities_template->activity->current_comment->item_id] ) ){ 845 $retval = $activities_template->activity->current_comment->primary_link; 846 } 847 848 return $retval; 849 } 850 add_filter( 'bp_get_activity_comment_permalink', 'bp_blogs_activity_comment_permalink' ); -
bp-blogs/bp-blogs-functions.php
182 182 if ( !bp_blogs_is_blog_recordable( $blog_id, $user_id ) ) 183 183 return false; 184 184 185 $url = get_home_url( $blog_id ); 186 $name = get_blog_option( $blog_id, 'blogname' ); 187 $description = get_blog_option( $blog_id, 'blogdescription' ); 185 $name = get_blog_option( $blog_id, 'blogname' ); 188 186 189 if ( empty( $name ) ) 187 if ( empty( $name ) ) { 190 188 return false; 189 } 190 191 $url = get_home_url( $blog_id ); 192 $description = get_blog_option( $blog_id, 'blogdescription' ); 193 $close_old_posts = get_blog_option( $blog_id, 'close_comments_for_old_posts' ); 194 $close_days_old = get_blog_option( $blog_id, 'close_comments_days_old' ); 195 196 $thread_depth = get_blog_option( $blog_id, 'thread_comments' ); 197 if ( ! empty( $thread_depth ) ) { 198 $thread_depth = get_blog_option( $blog_id, 'thread_comments_depth' ); 199 } else { 200 // perhaps filter this? 201 $thread_depth = 1; 202 } 191 203 192 204 $recorded_blog = new BP_Blogs_Blog; 193 205 $recorded_blog->user_id = $user_id; … … 199 211 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name ); 200 212 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description ); 201 213 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', bp_core_current_time() ); 214 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'close_comments_for_old_posts', $close_old_posts ); 215 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'close_comments_days_old', $close_days_old ); 216 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'thread_comments_depth', $thread_depth ); 202 217 203 218 $is_private = !empty( $_POST['blog_public'] ) && (int) $_POST['blog_public'] ? false : true; 204 219 $is_private = !apply_filters( 'bp_is_new_blog_public', !$is_private ); … … 252 267 add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescription', 10, 2 ); 253 268 254 269 /** 270 * Update "Close comments for old posts" option in BuddyPress blogmeta table. 271 * 272 * @since BuddyPress (2.0.0) 273 * 274 * @global object $wpdb DB Layer. 275 * 276 * @param string $oldvalue Value before save. Passed by do_action() but 277 * unused here. 278 * @param string $newvalue Value to change meta to. 279 */ 280 function bp_blogs_update_option_close_comments_for_old_posts( $oldvalue, $newvalue ) { 281 global $wpdb; 282 283 bp_blogs_update_blogmeta( $wpdb->blogid, 'close_comments_for_old_posts', $newvalue ); 284 } 285 add_action( 'update_option_close_comments_for_old_posts', 'bp_blogs_update_option_close_comments_for_old_posts', 10, 2 ); 286 287 /** 288 * Update "Close comments after days old" option in BuddyPress blogmeta table. 289 * 290 * @since BuddyPress (2.0.0) 291 * 292 * @global object $wpdb DB Layer. 293 * 294 * @param string $oldvalue Value before save. Passed by do_action() but 295 * unused here. 296 * @param string $newvalue Value to change meta to. 297 */ 298 function bp_blogs_update_option_close_close_comments_days_old( $oldvalue, $newvalue ) { 299 global $wpdb; 300 301 bp_blogs_update_blogmeta( $wpdb->blogid, 'close_comments_days_old', $newvalue ); 302 } 303 add_action( 'update_option_close_comments_days_old', 'bp_blogs_update_option_close_comments_days_old', 10, 2 ); 304 305 /** 306 * When toggling threaded comments, update thread depth in blogmeta table. 307 * 308 * @since BuddyPress (2.0.0) 309 * 310 * @global object $wpdb DB Layer. 311 * 312 * @param string $oldvalue Value before save. Passed by do_action() but 313 * unused here. 314 * @param string $newvalue Value to change meta to. 315 */ 316 function bp_blogs_update_option_thread_comments( $oldvalue, $newvalue ) { 317 global $wpdb; 318 319 if ( empty( $newvalue ) ) { 320 $thread_depth = 1; 321 } else { 322 $thread_depth = get_option( 'thread_comments_depth' ); 323 } 324 325 bp_blogs_update_blogmeta( $wpdb->blogid, 'thread_comments_depth', $thread_depth ); 326 } 327 add_action( 'update_option_thread_comments', 'bp_blogs_update_option_thread_comments', 10, 2 ); 328 329 /** 330 * When updating comment depth, update thread depth in blogmeta table. 331 * 332 * @since BuddyPress (2.0.0) 333 * 334 * @global object $wpdb DB Layer. 335 * 336 * @param string $oldvalue Value before save. Passed by do_action() but 337 * unused here. 338 * @param string $newvalue Value to change meta to. 339 */ 340 function bp_blogs_update_option_thread_comments_depth( $oldvalue, $newvalue ) { 341 global $wpdb; 342 343 $comments_enabled = get_option( 'thread_comments' ); 344 345 if ( $comments_enabled ) { 346 bp_blogs_update_blogmeta( $wpdb->blogid, 'thread_comments_depth', $newvalue ); 347 } 348 } 349 add_action( 'update_option_thread_comments_depth', 'bp_blogs_update_option_thread_comments_depth', 10, 2 ); 350 351 /** 255 352 * Detect a change in post status, and initiate an activity update if necessary. 256 353 * 257 354 * Posts get new activity updates when (a) they are being published, and (b) … … 262 359 * 263 360 * @since BuddyPress (2.0.0) 264 361 * 362 * @todo Support untrashing better 363 * 265 364 * @param string $new_status New status for the post. 266 365 * @param string $old_status Old status for the post. 267 366 * @param object $post Post data. 268 367 */ 269 368 function bp_blogs_catch_transition_post_status( $new_status, $old_status, $post ) { 270 369 271 // Do nothing for edits370 // This is an edit 272 371 if ( $new_status === $old_status ) { 273 return; 372 if ( $new_status == 'publish' ) { 373 bp_blogs_update_post( $post ); 374 } 274 375 } 275 376 276 377 // Publishing a previously unpublished post 277 378 if ( 'publish' === $new_status ) { 278 return bp_blogs_record_post( $post->ID, $post ); 379 // Untrashing the post 380 // Nothing here yet 381 if ( 'trash' == $old_status ) {} 382 383 // Record the post 384 bp_blogs_record_post( $post->ID, $post ); 279 385 280 386 // Unpublishing a previously published post 281 387 } else if ( 'publish' === $old_status ) { 282 return bp_blogs_remove_post( $post->ID ); 388 // Some form of pending status 389 // Only remove the activity entry 390 bp_blogs_delete_activity( array( 391 'item_id' => get_current_blog_id(), 392 'secondary_item_id' => $post->ID, 393 'component' => buddypress()->blogs->id, 394 'type' => 'new_blog_post' 395 ) ); 283 396 } 284 397 } 285 398 add_action( 'transition_post_status', 'bp_blogs_catch_transition_post_status', 10, 3 ); … … 369 482 370 483 // Update the blogs last activity 371 484 bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() ); 372 } else {373 bp_blogs_remove_post( $post_id, $blog_id, $user_id );374 485 } 375 486 376 487 do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id ); 377 488 } 378 489 379 490 /** 491 * Updates a blog post's corresponding activity entry during a post edit. 492 * 493 * @since BuddyPress (2.0.0) 494 * 495 * @see bp_blogs_catch_transition_post_status() 496 * 497 * @param WP_Post $post 498 */ 499 function bp_blogs_update_post( $post ) { 500 if ( ! bp_is_active( 'activity' ) ) { 501 return; 502 } 503 504 $activity_id = bp_activity_get_activity_id( array( 505 'component' => buddypress()->blogs->id, 506 'item_id' => get_current_blog_id(), 507 'secondary_item_id' => $post->ID, 508 'type' => 'new_blog_post', 509 ) ); 510 511 // activity ID doesn't exist, so stop! 512 if ( empty( $activity_id ) ) { 513 return; 514 } 515 516 // update the activity entry 517 $activity = new BP_Activity_Activity( $activity_id ); 518 $activity->content = $post->post_content; 519 $activity->save(); 520 521 // add post comment status to activity meta if closed 522 if( 'closed' == $post->comment_status ) { 523 bp_activity_update_meta( $activity_id, 'post_comment_status', $post->comment_status ); 524 } else { 525 bp_activity_delete_meta( $activity_id, 'post_comment_status' ); 526 } 527 } 528 529 /** 380 530 * Record a new blog comment in the BuddyPress activity stream. 381 531 * 382 532 * Only posts the item if blog is public and post is not password-protected. … … 441 591 $post_permalink = get_permalink( $recorded_comment->comment_post_ID ); 442 592 $comment_link = get_comment_link( $recorded_comment->comment_ID ); 443 593 444 // Prepare to record in activity streams 445 if ( is_multisite() ) 446 $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>' ); 447 else 448 $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>' ); 594 // Setup activity args 595 $args = array(); 596 597 $args['user_id'] = $user_id; 598 $args['content'] = apply_filters_ref_array( 'bp_blogs_activity_new_comment_content', array( $recorded_comment->comment_content, &$recorded_comment, $comment_link ) ); 599 $args['primary_link'] = apply_filters_ref_array( 'bp_blogs_activity_new_comment_primary_link', array( $comment_link, &$recorded_comment ) ); 600 $args['recorded_time'] = $recorded_comment->comment_date_gmt; 601 602 // Setup some different activity args depending if activity commenting is 603 // enabled or not 604 605 // if cannot comment, record separate activity entry 606 // this is the old way of doing things 607 if ( bp_disable_blogforum_comments() ) { 608 $args['type'] = 'new_blog_comment'; 609 $args['item_id'] = $blog_id; 610 $args['secondary_item_id'] = $comment_id; 611 612 // record the activity entry 613 bp_blogs_record_activity( $args ); 614 615 // record comment as BP activity comment under the parent 'new_blog_post' 616 // activity item 617 } else { 618 // this is a comment edit 619 // check to see if corresponding activity entry already exists 620 if ( ! empty( $_REQUEST['action'] ) ) { 621 $existing_activity_id = get_comment_meta( $comment_id, 'bp_activity_comment_id', true ); 622 623 if ( ! empty( $existing_activity_id ) ) { 624 $args['id'] = $existing_activity_id; 625 } 626 } 449 627 450 $activity_content = $recorded_comment->comment_content; 628 // find the parent 'new_blog_post' activity entry 629 $parent_activity_id = bp_activity_get_activity_id( array( 630 'user_id' => $user_id, 631 'component' => 'blogs', 632 'type' => 'new_blog_post', 633 'item_id' => $blog_id, 634 'secondary_item_id' => $recorded_comment->comment_post_ID 635 ) ); 636 637 // we found the parent activity entry 638 // so let's go ahead and reconfigure some activity args 639 if ( ! empty( $parent_activity_id ) ) { 640 // set the 'item_id' with the parent activity entry ID 641 $args['item_id'] = $parent_activity_id; 642 643 // now see if the WP parent comment has a BP activity ID 644 $comment_parent = 0; 645 if ( ! empty( $recorded_comment->comment_parent ) ) { 646 $comment_parent = get_comment_meta( $recorded_comment->comment_parent, 'bp_activity_comment_id', true ); 647 } 451 648 452 // Record in activity streams 453 bp_blogs_record_activity( array( 454 'user_id' => $user_id, 455 'content' => apply_filters_ref_array( 'bp_blogs_activity_new_comment_content', array( $activity_content, &$recorded_comment, $comment_link ) ), 456 'primary_link' => apply_filters_ref_array( 'bp_blogs_activity_new_comment_primary_link', array( $comment_link, &$recorded_comment ) ), 457 'type' => 'new_blog_comment', 458 'item_id' => $blog_id, 459 'secondary_item_id' => $comment_id, 460 'recorded_time' => $recorded_comment->comment_date_gmt 461 ) ); 649 // WP parent comment does not have a BP activity ID 650 // so set to 'new_blog_post' activity ID 651 if ( empty( $comment_parent ) ) { 652 $comment_parent = $parent_activity_id; 653 } 654 655 $args['secondary_item_id'] = $comment_parent; 656 $args['component'] = 'activity'; 657 $args['type'] = 'activity_comment'; 658 659 // could not find corresponding parent activity entry 660 // so wipe out $args array 661 } else { 662 $args = array(); 663 } 664 665 // Record in activity streams 666 if ( ! empty( $args ) ) { 667 // @todo should we use bp_activity_new_comment()? that function will also send 668 // an email to people in the activity comment thread 669 // 670 // what if a site already has some comment email notification plugin setup? 671 // this is why I decided to go with bp_activity_add() to avoid any conflict 672 // with existing comment email notification plugins 673 $comment_activity_id = bp_activity_add( $args ); 674 675 if ( empty( $args['id'] ) ) { 676 // add meta to activity comment 677 bp_activity_update_meta( $comment_activity_id, 'bp_blogs_post_comment_id', $comment_id ); 678 679 // add meta to comment 680 add_comment_meta( $comment_id, 'bp_activity_comment_id', $comment_activity_id ); 681 } 682 } 683 } 462 684 463 685 // Update the blogs last active date 464 686 bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() ); … … 632 854 function bp_blogs_remove_comment( $comment_id ) { 633 855 global $wpdb; 634 856 635 // Delete activity stream item 636 bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid, 'secondary_item_id' => $comment_id, 'type' => 'new_blog_comment' ) ); 857 // activity comments are disabled for blog posts 858 // which means that individual activity items exist for blog comments 859 if ( bp_disable_blogforum_comments() ) { 860 // Delete the individual activity stream item 861 bp_blogs_delete_activity( array( 862 'item_id' => $wpdb->blogid, 863 'secondary_item_id' => $comment_id, 864 'type' => 'new_blog_comment' 865 ) ); 866 867 // activity comments are enabled for blog posts 868 // remove the associated activity item 869 } else { 870 // get associated activity ID from comment meta 871 $activity_id = get_comment_meta( $comment_id, 'bp_activity_comment_id', true ); 872 873 // delete the associated activity comment 874 // 875 // also removes child post comments and associated activity comments 876 if ( ! empty( $activity_id ) && bp_is_active( 'activity' ) ) { 877 // fetch the activity comments for the activity item 878 $activity = bp_activity_get( array( 879 'in' => $activity_id, 880 'display_comments' => 'stream', 881 ) ); 882 883 // get all activity comment IDs for the pending deleted item 884 if ( ! empty( $activity['activities'] ) ) { 885 $activity_ids = bp_activity_recurse_comments_activity_ids( $activity ); 886 $activity_ids[] = $activity_id; 887 888 // delete activity items 889 foreach ( $activity_ids as $activity_id ) { 890 bp_activity_delete( array( 891 'id' => $activity_id 892 ) ); 893 } 894 895 // remove associated blog comments 896 bp_blogs_remove_associated_blog_comments( $activity_ids ); 897 898 // rebuild activity comment tree 899 BP_Activity_Activity::rebuild_activity_comment_tree( $activity['activities'][0]->item_id ); 900 } 901 } 902 } 637 903 638 904 do_action( 'bp_blogs_remove_comment', $wpdb->blogid, $comment_id, bp_loggedin_user_id() ); 639 905 } 640 906 add_action( 'delete_comment', 'bp_blogs_remove_comment' ); 641 907 642 908 /** 909 * Removes blog comments that are associated with activity comments. 910 * 911 * @since BuddyPress (2.0.0) 912 * 913 * @see bp_blogs_remove_comment() 914 * @see bp_blogs_sync_delete_from_activity_comment() 915 * 916 * @param array $activity_ids The activity IDs to check association with blog 917 * comments. 918 * @param bool $force_delete Whether to force delete the comments. If false, 919 * comments are trashed instead. 920 */ 921 function bp_blogs_remove_associated_blog_comments( $activity_ids = array(), $force_delete = true ) { 922 // query args 923 $query_args = array( 924 'meta_query' => array( 925 array( 926 'key' => 'bp_activity_comment_id', 927 'value' => implode( ',', (array) $activity_ids ), 928 'compare' => 'IN', 929 ) 930 ) 931 ); 932 933 // get comment 934 $comment_query = new WP_Comment_Query; 935 $comments = $comment_query->query( $query_args ); 936 937 // found the corresponding comments 938 // let's delete them! 939 foreach ( $comments as $comment ) { 940 wp_delete_comment( $comment->comment_ID, $force_delete ); 941 942 // if we're trashing the comment, remove the meta key as well 943 if ( empty( $force_delete ) ) { 944 delete_comment_meta( $comment->comment_ID, 'bp_activity_comment_id' ); 945 } 946 } 947 } 948 949 /** 643 950 * When a blog comment status transition occurs, update the relevant activity's status. 644 951 * 645 952 * @since BuddyPress (1.6.0) … … 667 974 */ 668 975 669 976 // This clause was moved in from bp_blogs_remove_comment() in BuddyPress 1.6. It handles delete/hold. 670 if ( in_array( $new_status, array( 'delete', 'hold' ) ) ) 977 if ( in_array( $new_status, array( 'delete', 'hold' ) ) ) { 671 978 return bp_blogs_remove_comment( $comment->comment_ID ); 672 979 673 980 // These clauses handle trash, spam, and un-spams. 674 elseif ( in_array( $new_status, array( 'trash', 'spam' ) ) )981 } elseif ( in_array( $new_status, array( 'trash', 'spam' ) ) ) { 675 982 $action = 'spam_activity'; 676 elseif ( 'approved' == $new_status )983 } elseif ( 'approved' == $new_status ) { 677 984 $action = 'ham_activity'; 985 } 678 986 679 987 // Get the activity 680 $activity_id = bp_activity_get_activity_id( array( 'component' => $bp->blogs->id, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $comment->comment_ID, 'type' => 'new_blog_comment', ) ); 988 if ( bp_disable_blogforum_comments() ) { 989 $activity_id = bp_activity_get_activity_id( array( 'component' => $bp->blogs->id, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $comment->comment_ID, 'type' => 'new_blog_comment', ) ); 990 } else { 991 $activity_id = get_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', true ); 992 } 681 993 682 994 // Check activity item exists 683 if ( ! $activity_id ) { 684 995 if ( empty( $activity_id ) ) { 685 996 // If no activity exists, but the comment has been approved, record it into the activity table. 686 if ( 'approved' == $new_status ) 997 if ( 'approved' == $new_status ) { 687 998 return bp_blogs_record_comment( $comment->comment_ID, true ); 999 } 688 1000 689 1001 return; 690 1002 } -
bp-core/bp-core-options.php
226 226 * @return mixed The value for the option. 227 227 */ 228 228 function bp_get_option( $option_name, $default = '' ) { 229 $value = get_blog_option( bp_get_root_blog_id(), $option_name, $default ); 229 // check buddypress()->site_options array first 230 if ( isset( buddypress()->site_options[$option_name] ) ) { 231 $value = buddypress()->site_options[$option_name]; 232 233 // query for the option if not available 234 } else { 235 $value = get_blog_option( bp_get_root_blog_id(), $option_name, $default ); 236 } 230 237 231 238 return apply_filters( 'bp_get_option', $value ); 232 239 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)