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

Render the widget.

Description

See also

Parameters

$args

(Required) See {@WP_Widget::widget()}.

$instance

(Required) See {@WP_Widget::widget()}.

Source

File: bp-messages/classes/class-bp-messages-sitewide-notices-widget.php

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
public function widget( $args, $instance ) {
 
    if ( ! is_user_logged_in() ) {
        return;
    }
 
    // Don't display the widget if there are no Notices to show.
    $notices = BP_Messages_Notice::get_active();
    if ( empty( $notices ) ) {
        return;
    }
 
    extract( $args );
 
    $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
 
    /**
     * Filters the title of the Messages widget.
     *
     * @since BuddyPress 1.9.0
     * @since BuddyPress 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
     *
     * @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 );
 
    echo $before_widget;
    echo $before_title . $title . $after_title; ?>
 
    <div class="bp-site-wide-message">
        <?php bp_message_get_notices(); ?>
    </div>
 
    <?php
 
    echo $after_widget;
}

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.