Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/07/2016 04:59:52 PM (10 years ago)
Author:
imath
Message:

Post Type Activities: make sure it is possible to filter by post type activity comment action within the Activity Administration screen.

Fixes #6482

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-activity-list-table.php

    r10516 r10546  
    8585                // Option defaults.
    8686                $filter           = array();
     87                $filter_query     = false;
    8788                $include_id       = false;
    8889                $search_terms     = false;
     
    111112
    112113                // Filter.
    113                 if ( !empty( $_REQUEST['activity_type'] ) )
     114                if ( ! empty( $_REQUEST['activity_type'] ) ) {
    114115                        $filter = array( 'action' => $_REQUEST['activity_type'] );
     116
     117                        /**
     118                         * Filter here to override the filter with a filter query
     119                         *
     120                         * @since  2.5.0
     121                         *
     122                         * @param array $filter
     123                         */
     124                        $has_filter_query = apply_filters( 'bp_activity_list_table_filter_activity_type_items', $filter );
     125
     126                        if ( ! empty( $has_filter_query['filter_query'] ) ) {
     127                                // Reset the filter
     128                                $filter       = array();
     129
     130                                // And use the filter query instead
     131                                $filter_query = $has_filter_query['filter_query'];
     132                        }
     133                }
    115134
    116135                // Are we doing a search?
     
    140159                        'per_page'         => $per_page,
    141160                        'search_terms'     => $search_terms,
     161                        'filter_query'     => $filter_query,
    142162                        'show_hidden'      => true,
    143163                        // 'sort'             => $sort,
     
    743763         *
    744764         * @since 2.0.0
     765         * @since 2.5.0 Include Post type activities types
    745766         *
    746767         * @param array $item An array version of the BP_Activity_Activity object.
     
    748769         */
    749770        protected function can_comment( $item  ) {
    750                 $can_comment = true;
    751 
    752                 if ( $this->disable_blogforum_comments ) {
    753                         switch ( $item['type'] ) {
    754                                 case 'new_blog_post' :
    755                                 case 'new_blog_comment' :
    756                                 case 'new_forum_topic' :
    757                                 case 'new_forum_post' :
    758                                         $can_comment = false;
    759                                         break;
     771                $can_comment = bp_activity_type_supports( $item['type'], 'comment-reply' );
     772
     773                if ( ! $this->disable_blogforum_comments && bp_is_active( 'blogs' ) ) {
     774                        $parent_activity = false;
     775
     776                        if ( bp_activity_type_supports( $item['type'], 'post-type-comment-tracking' ) ) {
     777                                $parent_activity = (object) $item;
     778                        } elseif ( 'activity_comment' === $item['type'] ) {
     779                                $parent_activity = new BP_Activity_Activity( $item['item_id'] );
    760780                        }
    761781
    762                 // Activity comments supported.
    763                 } else {
    764                         // Activity comment.
    765                         if ( 'activity_comment' == $item['type'] ) {
    766                                 // Blogs.
    767                                 if ( bp_is_active( 'blogs' ) ) {
    768                                         // Grab the parent activity entry.
    769                                         $parent_activity = new BP_Activity_Activity( $item['item_id'] );
    770 
    771                                         // Fetch blog post comment depth and if the blog post's comments are open.
    772                                         bp_blogs_setup_activity_loop_globals( $parent_activity );
    773 
    774                                         // Check if the activity item can be replied to.
    775                                         if ( false === bp_blogs_can_comment_reply( true, $item ) ) {
    776                                                 $can_comment = false;
    777                                         }
    778                                 }
    779 
    780                         // Blog post.
    781                         } elseif ( 'new_blog_post' == $item['type'] ) {
    782                                 if ( bp_is_active( 'blogs' ) ) {
    783                                         bp_blogs_setup_activity_loop_globals( (object) $item );
    784 
    785                                         if ( empty( buddypress()->blogs->allow_comments[$item['id']] ) ) {
    786                                                 $can_comment = false;
    787                                         }
    788                                 }
     782                        if ( isset( $parent_activity->type ) && bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'post_type' ) ) {
     783                                // Fetch blog post comment depth and if the blog post's comments are open.
     784                                bp_blogs_setup_activity_loop_globals( $parent_activity );
     785
     786                                $can_comment = bp_blogs_can_comment_reply( true, $item );
    789787                        }
    790788                }
     
    794792                 *
    795793                 * @since 2.0.0
    796                  *
    797                  * @param bool $can_comment Whether an activity item can be commented on or not.
     794                 * @since 2.5.0 Add a second parameter to include the activity item into the filter.
     795                 *
     796                 * @param bool  $can_comment Whether an activity item can be commented on or not.
     797                 * @param array $item        An array version of the BP_Activity_Activity object.
    798798                 */
    799                 return apply_filters( 'bp_activity_list_table_can_comment', $can_comment );
     799                return apply_filters( 'bp_activity_list_table_can_comment', $can_comment, $item );
    800800        }
    801801
Note: See TracChangeset for help on using the changeset viewer.