Changeset 8402
- Timestamp:
- 05/09/2014 07:16:31 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-template.php
r8251 r8402 2657 2657 2658 2658 /** 2659 * Determine if a comment can be made on an activity reply item. 2660 * 2661 * Defaults to true, but can be modified by plugins. 2662 * 2663 * @since BuddyPress (1.5) 2664 * 2665 * @uses apply_filters() To call the 'bp_activity_can_comment_reply' hook 2659 * Determine whether a comment can be made on an activity reply item. 2660 * 2661 * @since BuddyPress (1.5.0) 2666 2662 * 2667 2663 * @param object $comment Activity comment. 2668 * @return bool $can_comment True if comment can receive comments. 2664 * @return bool $can_comment True if comment can receive comments, otherwise 2665 * false. 2669 2666 */ 2670 2667 function bp_activity_can_comment_reply( $comment ) { 2671 2668 $can_comment = true; 2672 2669 2673 if ( get_option( 'thread_comments' ) && bp_activity_get_comment_depth() >= get_option( 'thread_comments_depth' ) ) { 2670 // Fall back on current comment in activity loop 2671 $comment_depth = 0; 2672 if ( isset( $comment->depth ) ) { 2673 $comment_depth = intval( $comment->depth ); 2674 } else { 2675 $comment_depth = bp_activity_get_comment_depth(); 2676 } 2677 2678 if ( get_option( 'thread_comments' ) ) { 2679 $can_comment = $comment_depth < get_option( 'thread_comments_depth' ); 2680 } else { 2681 // No threading for comment replies if no threading for comments 2674 2682 $can_comment = false; 2675 2683 } -
trunk/src/bp-languages/buddypress.pot
r8401 r8402 5 5 "Project-Id-Version: BuddyPress 2.1-alpha\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/buddypress\n" 7 "POT-Creation-Date: 2014-05-0 8 17:46:26+00:00\n"7 "POT-Creation-Date: 2014-05-09 19:15:25+00:00\n" 8 8 "MIME-Version: 1.0\n" 9 9 "Content-Type: text/plain; charset=utf-8\n" … … 869 869 msgstr "" 870 870 871 #: bp-activity/bp-activity-template.php:28 52871 #: bp-activity/bp-activity-template.php:2860 872 872 msgid "a user" 873 873 msgstr "" 874 874 875 #: bp-activity/bp-activity-template.php:29 06875 #: bp-activity/bp-activity-template.php:2914 876 876 msgid "Send a public message on your activity stream." 877 877 msgstr "" 878 878 879 #: bp-activity/bp-activity-template.php:29 07879 #: bp-activity/bp-activity-template.php:2915 880 880 msgid "Public Message" 881 881 msgstr "" 882 882 883 #: bp-activity/bp-activity-template.php:336 0883 #: bp-activity/bp-activity-template.php:3368 884 884 msgid "Site Wide Activity RSS Feed" 885 885 msgstr "" -
trunk/tests/phpunit/testcases/activity/template.php
r7905 r8402 308 308 $this->assertNotEmpty( wp_cache_get( $a2, 'activity_meta' ) ); 309 309 } 310 311 /** 312 * @group bp_activity_can_comment_reply 313 */ 314 public function test_bp_activity_can_comment_reply_thread_comments_on() { 315 $tc = get_option( 'thread_comments' ); 316 update_option( 'thread_comments', '1' ); 317 318 $tcd = get_option( 'thread_comments_depth' ); 319 update_option( 'thread_comments_depth', '4' ); 320 321 // Fake the global 322 global $activities_template; 323 $activities_template = new stdClass; 324 $activities_template->activity = new stdClass; 325 $activities_template->activity->current_comment = new stdClass; 326 327 $comment = new stdClass; 328 $comment->item_id = 4; 329 330 $activities_template->activity->current_comment->depth = 1; 331 $this->assertTrue( bp_activity_can_comment_reply( $comment ) ); 332 333 $activities_template->activity->current_comment->depth = 3; 334 $this->assertTrue( bp_activity_can_comment_reply( $comment ) ); 335 336 $activities_template->activity->current_comment->depth = 4; 337 $this->assertFalse( bp_activity_can_comment_reply( $comment ) ); 338 339 $activities_template->activity->current_comment->depth = 5; 340 $this->assertFalse( bp_activity_can_comment_reply( $comment ) ); 341 342 // Set right what once went wrong 343 update_option( 'thread_comments', $tc ); 344 update_option( 'thread_comments_depth', $tcd ); 345 $activities_template = null; 346 } 347 348 /** 349 * @group bp_activity_can_comment_reply 350 */ 351 public function test_bp_activity_can_comment_reply_thread_comments_off() { 352 $tc = get_option( 'thread_comments' ); 353 update_option( 'thread_comments', '0' ); 354 355 $tcd = get_option( 'thread_comments_depth' ); 356 update_option( 'thread_comments_depth', '4' ); 357 358 // Fake the global 359 global $activities_template; 360 $activities_template = new stdClass; 361 $activities_template->activity = new stdClass; 362 $activities_template->activity->current_comment = new stdClass; 363 364 $comment = new stdClass; 365 $comment->item_id = 4; 366 367 $activities_template->activity->current_comment->depth = 1; 368 $this->assertFalse( bp_activity_can_comment_reply( $comment ) ); 369 370 $activities_template->activity->current_comment->depth = 2; 371 $this->assertFalse( bp_activity_can_comment_reply( $comment ) ); 372 373 // Set right what once went wrong 374 update_option( 'thread_comments', $tc ); 375 update_option( 'thread_comments_depth', $tcd ); 376 $activities_template = null; 377 } 310 378 }
Note: See TracChangeset
for help on using the changeset viewer.