Skip to:
Content

BuddyPress.org

Ticket #8504: 8504.patch

File 8504.patch, 1.6 KB (added by imath, 4 years ago)
  • src/bp-activity/bp-activity-functions.php

    diff --git src/bp-activity/bp-activity-functions.php src/bp-activity/bp-activity-functions.php
    index 1a4fe39b2..cf9410657 100644
    function bp_activity_get_types() { 
    842842        return apply_filters( 'bp_activity_get_types', $actions );
    843843}
    844844
     845/**
     846 * Returns the list of available BuddyPress activity types.
     847 *
     848 * @since 9.0.0
     849 *
     850 * @return array An array of activity type labels keyed by type names.
     851 */
     852function bp_activity_get_types_list() {
     853        $actions_object = bp_activity_get_actions();
     854        $actions_array  = get_object_vars( $actions_object );
     855
     856        $types = array();
     857        foreach ( $actions_array as $component => $actions ) {
     858                $new_types = wp_list_pluck( $actions, 'label', 'key' );
     859
     860                if ( $types ) {
     861                        // Makes sure activity types are unique.
     862                        $new_types = array_diff_key( $new_types, $types );
     863
     864                        if ( 'friends' === $component ) {
     865                                $new_types = array_diff_key(
     866                                        array(
     867                                                'friendship_accepted'              => false,
     868                                                'friendship_created'               => false,
     869                                                'friends_register_activity_action' => false,
     870                                        ),
     871                                        $new_types
     872                                );
     873
     874                                $new_types['friendship_accepted,friendship_created'] = __( 'Friendships', 'buddypress' );
     875                        }
     876                }
     877
     878                $types = array_merge( $types, $new_types );
     879        }
     880
     881        /**
     882         * Filter here to edit the activity types list.
     883         *
     884         * @since 9.0.0
     885         *
     886         * @param array $types An array of activity type labels keyed by type names.
     887         */
     888        return apply_filters( 'bp_activity_get_types_list', $types );
     889}
     890
    845891/**
    846892 * Gets the current activity context.
    847893 *