BP_Latest_Activities::widget( array $args, array $instance )

Display the widget content.

Description

Parameters

$args

(Required) Widget arguments.

$instance

(Required) Widget settings, as saved by the user.

Source

File: bp-templates/bp-nouveau/includes/activity/widgets.php

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
public function widget( $args, $instance ) {
    // Default values
    $title      = __( 'Latest updates', 'buddyboss' );
    $type       = array( 'activity_update' );
    $max        = 5;
    $bp_nouveau = bp_nouveau();
 
    // Check instance for a custom title
    if ( ! empty( $instance['title'] ) ) {
        $title = $instance['title'];
    }
 
    /**
     * Filters the BP_Latest_Activities widget title.
     *
     * @since BuddyPress 3.0.0
     *
     * @param string $title    The widget title.
     * @param array  $instance The settings for the particular instance of the widget.
     * @param string $id_base  Root ID for all widgets of this type.
     */
    $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
 
    // Check instance for custom max number of activities to display
    if ( ! empty( $instance['max'] ) ) {
        $max = (int) $instance['max'];
    }
 
    // Check instance for custom activity types
    if ( ! empty( $instance['type'] ) ) {
        $type    = maybe_unserialize( $instance['type'] );
        $classes = array_map( 'sanitize_html_class', array_merge( $type, array( 'bp-latest-activities' ) ) );
 
        // Add classes to the container
        $args['before_widget'] = str_replace( 'bp-latest-activities', join( ' ', $classes ), $args['before_widget'] );
    }
 
    echo $args['before_widget'];
 
    if ( $title ) {
        echo $args['before_title'] . $title . $args['after_title'];
    }
 
    $reset_activities_template = null;
    if ( ! empty( $GLOBALS['activities_template'] ) ) {
        $reset_activities_template = $GLOBALS['activities_template'];
    }
 
    /**
     * Globalize the activity widget arguments.
     * @see bp_nouveau_activity_widget_query() to override
     */
    $bp_nouveau->activity->widget_args = array(
        'max'          => $max,
        'scope'        => 'all',
        'user_id'      => 0,
        'object'       => false,
        'action'       => join( ',', $type ),
        'primary_id'   => 0,
        'secondary_id' => 0,
    );
 
    bp_get_template_part( 'activity/widget' );
 
    // Reset the globals
    $GLOBALS['activities_template']    = $reset_activities_template;
    $bp_nouveau->activity->widget_args = array();
 
    echo $args['after_widget'];
}

Changelog

Changelog
Version Description
BuddyPress 3.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.