Skip to:
Content

BuddyPress.org

Ticket #6866: 6866.diff

File 6866.diff, 1.9 KB (added by boonebgorges, 9 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 b5e8a93..49f193e 100644
    function bp_activity_get_post_type_tracking_args( $post_type ) { 
    517517 * @return array List of post types with their tracking arguments.
    518518 */
    519519function bp_activity_get_post_types_tracking_args() {
    520         // Fetch all public post types.
    521         $post_types = get_post_types( array( 'public' => true ), 'names' );
     520        static $args;
    522521
    523         $post_types_tracking_args = array();
     522        if ( ! isset( $args ) ) {
     523                // Fetch all public post types.
     524                $post_types = get_post_types( array( 'public' => true ), 'names' );
    524525
    525         foreach ( $post_types as $post_type ) {
    526                 $track_post_type = bp_activity_get_post_type_tracking_args( $post_type );
     526                $post_types_tracking_args = array();
     527
     528                foreach ( $post_types as $post_type ) {
     529                        $track_post_type = bp_activity_get_post_type_tracking_args( $post_type );
     530
     531                        if ( ! empty( $track_post_type ) ) {
     532                                $post_types_tracking_args[ $track_post_type->action_id ] = $track_post_type;
     533                        }
    527534
    528                 if ( ! empty( $track_post_type ) ) {
    529                         $post_types_tracking_args[ $track_post_type->action_id ] = $track_post_type;
    530535                }
    531536
     537                /**
     538                 * Filters tracking arguments for all post types.
     539                 *
     540                 * @since 2.2.0
     541                 *
     542                 * @param array $post_types_tracking_args Array of post types with
     543                 *                                        their tracking arguments.
     544                 */
     545                $args = apply_filters( 'bp_activity_get_post_types_tracking_args', $post_types_tracking_args );
    532546        }
    533547
    534         /**
    535          * Filters tracking arguments for all post types.
    536          *
    537          * @since 2.2.0
    538          *
    539          * @param array $post_types_tracking_args Array of post types with
    540          *                                        their tracking arguments.
    541          */
    542         return apply_filters( 'bp_activity_get_post_types_tracking_args', $post_types_tracking_args );
     548        return $args;
    543549}
    544550
    545551/**