Skip to:
Content

BuddyPress.org

Changeset 12331


Ignore:
Timestamp:
02/02/2019 03:14:25 PM (6 years ago)
Author:
espellcaste
Message:

Added hooks to filter Activity and Groups list table get_sortable_columns

Adding custom hooks permitting the sortable columns of the Activity and Group list table to be filtered.

Props @modemlooper
Fixes #7533

Location:
trunk/src
Files:
2 edited

Legend:

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

    r11764 r12331  
    339339     * @return array Key/value pairs for the bulk actions dropdown.
    340340     */
    341     function get_bulk_actions() {
    342         $actions = array();
    343         $actions['bulk_spam']   = __( 'Mark as Spam', 'buddypress' );
    344         $actions['bulk_ham']    = __( 'Not Spam', 'buddypress' );
    345         $actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
     341    public function get_bulk_actions() {
    346342
    347343        /**
     
    352348         * @param array $actions Default available actions for bulk operations.
    353349         */
    354         return apply_filters( 'bp_activity_list_table_get_bulk_actions', $actions );
     350        return apply_filters( 'bp_activity_list_table_get_bulk_actions', array(
     351            'bulk_spam'   => __( 'Mark as Spam', 'buddypress' ),
     352            'bulk_ham'    => __( 'Not Spam', 'buddypress' ),
     353            'bulk_delete' => __( 'Delete Permanently', 'buddypress' ),
     354        ) );
    355355    }
    356356
     
    365365     */
    366366    function get_columns() {
     367
    367368        /**
    368369         * Filters the titles for the columns for the activity list table.
     
    374375        return apply_filters( 'bp_activity_list_table_get_columns', array(
    375376            'cb'       => '<input name type="checkbox" />',
    376             'author'   => _x('Author', 'Admin SWA column header', 'buddypress' ),
     377            'author'   => _x( 'Author', 'Admin SWA column header', 'buddypress' ),
    377378            'comment'  => _x( 'Activity', 'Admin SWA column header', 'buddypress' ),
    378379            'action'   => _x( 'Action', 'Admin SWA column header', 'buddypress' ),
     
    384385     * Get the column names for sortable columns.
    385386     *
    386      * Currently, returns an empty array (no columns are sortable).
    387      *
    388      * @since 1.6.0
    389      * @todo For this to work, BP_Activity_Activity::get() needs updating
    390      *       to support ordering by specific fields.
     387     * @since 1.6.0
    391388     *
    392389     * @return array The columns that can be sorted on the Activity screen.
    393390     */
    394     function get_sortable_columns() {
    395         return array();
    396 
    397         /*return array(
    398             'author' => array( 'activity_author', false ),  // Intentionally not using "=>"
    399         );*/
     391    public function get_sortable_columns() {
     392
     393        /**
     394         * Filters the column names for the sortable columns.
     395         *
     396         * @since 5.0.0
     397         *
     398         * @param array $value Array of column names.
     399         */
     400        return apply_filters( 'bp_activity_list_table_get_sortable_columns', array() );
    400401    }
    401402
  • trunk/src/bp-groups/classes/class-bp-groups-list-table.php

    r11530 r12331  
    418418     */
    419419    public function get_sortable_columns() {
    420         return array(
     420
     421        /**
     422         * Filters the column names for the sortable columns.
     423         *
     424         * @since 5.0.0
     425         *
     426         * @param array $value Array of keys and their values.
     427         */
     428        return apply_filters( 'bp_groups_list_table_get_sortable_columns', array(
    421429            'gid'         => array( 'gid', false ),
    422430            'comment'     => array( 'name', false ),
    423431            'members'     => array( 'members', false ),
    424432            'last_active' => array( 'last_active', false ),
    425         );
     433        ) );
    426434    }
    427435
Note: See TracChangeset for help on using the changeset viewer.