BBP_Views_Widget::widget( mixed $args = array(), array $instance = array() )
Displays the output, the view list
Description
Parameters
- $args
-
(Optional) Arguments
Default value: array()
- $instance
-
(Optional) Instance
Default value: array()
Source
File: bp-forums/common/widgets.php
public function widget( $args = array(), $instance = array() ) {
// Only output widget contents if views exist
if ( ! bbp_get_views() ) {
return;
}
// Get widget settings
$settings = $this->parse_settings( $instance );
// Typical WordPress filter
$settings['title'] = apply_filters( 'widget_title', $settings['title'], $instance, $this->id_base );
// Forums filter
$settings['title'] = apply_filters( 'bbp_view_widget_title', $settings['title'], $instance, $this->id_base );
echo $args['before_widget'];
if ( !empty( $settings['title'] ) ) {
echo $args['before_title'] . $settings['title'] . $args['after_title'];
} ?>
<ul>
<?php foreach ( array_keys( bbp_get_views() ) as $view ) : ?>
<li><a class="bbp-view-title" href="<?php bbp_view_url( $view ); ?>"><?php bbp_view_title( $view ); ?></a></li>
<?php endforeach; ?>
</ul>
<?php echo $args['after_widget'];
}
Changelog
| Version | Description |
|---|---|
| bbPress (r3020) | 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.