Skip to:
Content

BuddyPress.org

Changeset 8402


Ignore:
Timestamp:
05/09/2014 07:16:31 PM (12 years ago)
Author:
boonebgorges
Message:

Disable activity reply threading if WP comment threading is disabled

In r8201, BP adopted WP's thread_comments_depth setting for its own activity
reply threading. See #2768. However, the thread_comments toggle was not
respected. The current changeset adds support for thread_comments, so that
disabling WP comment threading will also enable nested activity comments
(though the top level of comments will still be allowed).

Fixes #5562

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-template.php

    r8251 r8402  
    26572657
    26582658/**
    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)
    26662662 *
    26672663 * @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.
    26692666 */
    26702667function bp_activity_can_comment_reply( $comment ) {
    26712668        $can_comment = true;
    26722669
    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
    26742682                $can_comment = false;
    26752683        }
  • trunk/src/bp-languages/buddypress.pot

    r8401 r8402  
    55"Project-Id-Version: BuddyPress 2.1-alpha\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/buddypress\n"
    7 "POT-Creation-Date: 2014-05-08 17:46:26+00:00\n"
     7"POT-Creation-Date: 2014-05-09 19:15:25+00:00\n"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=utf-8\n"
     
    869869msgstr ""
    870870
    871 #: bp-activity/bp-activity-template.php:2852
     871#: bp-activity/bp-activity-template.php:2860
    872872msgid "a user"
    873873msgstr ""
    874874
    875 #: bp-activity/bp-activity-template.php:2906
     875#: bp-activity/bp-activity-template.php:2914
    876876msgid "Send a public message on your activity stream."
    877877msgstr ""
    878878
    879 #: bp-activity/bp-activity-template.php:2907
     879#: bp-activity/bp-activity-template.php:2915
    880880msgid "Public Message"
    881881msgstr ""
    882882
    883 #: bp-activity/bp-activity-template.php:3360
     883#: bp-activity/bp-activity-template.php:3368
    884884msgid "Site Wide Activity RSS Feed"
    885885msgstr ""
  • trunk/tests/phpunit/testcases/activity/template.php

    r7905 r8402  
    308308                $this->assertNotEmpty( wp_cache_get( $a2, 'activity_meta' ) );
    309309        }
     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        }
    310378}
Note: See TracChangeset for help on using the changeset viewer.