Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/15/2013 08:57:09 PM (10 years ago)
Author:
boonebgorges
Message:

Support more liberal params for disabling comments in bp_has_activities()

The 'display_comments' argument of bp_has_activities() takes either a string
value (such as 'threaded') or a bool false to disable comments altogether.
However, the false check in the query method is strict, meaning that various
analogous null values for display_comments were not recognized. In particular,
the strict check made it impossible to disable activity comments via a
querystring, as is often done in templates: ?display_comments=0.

This changeset adds 0, '0', 'false', and 'none' to the possible values for
the null display_comments value, to support the longtime codex suggestions.
Changes are made at the level of bp_has_activities(), which means that the
query method still requires a string false for $display_comments.

Fixes #5029

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/activity/template.php

    r7127 r7574  
    254254
    255255    }
    256     /**
    257      * @ticket BP5029
    258      */
    259     public function test_get_with_display_comments_false_querystring() {
    260         $now = time();
    261         $a1 = $this->factory->activity->create( array(
    262             'content' => 'Life Rules',
    263             'recorded_time' => date( 'Y-m-d H:i:s', $now ),
    264         ) );
    265         $a2 = $this->factory->activity->create( array(
    266             'content' => 'Life Drools',
    267             'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
    268         ) );
    269         $a3 = bp_activity_new_comment( array(
    270             'activity_id' => $a1,
    271             'content' => 'Candy is good',
    272             'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
    273         ) );
    274 
    275         $expected = BP_Activity_Activity::get( array(
    276             'display_comments' => false,
    277         ) );
    278 
    279         $found = BP_Activity_Activity::get( 'display_comments=false' );
    280         $this->assertEquals( $expected, $found );
    281 
    282     }
    283 
    284 
    285256}
Note: See TracChangeset for help on using the changeset viewer.