| 296 | class BP_CORE_sitewide_messages_Widget extends WP_Widget { |
| 297 | |
| 298 | function __construct() { |
| 299 | parent::__construct( |
| 300 | 'BP_CORE_sitewide_messages_Widget', |
| 301 | __('(BuddyPress) Sitewide Messages', 'buddypress'), |
| 302 | array( 'classname' => 'widget_bp_core_sitewide_messages buddypress widget', 'description' => __('Displays the BP admin \'all users\' sitewide messages', 'buddypress'), ) |
| 303 | ); |
| 304 | } |
| 305 | |
| 306 | public function widget( $args, $instance ) { |
| 307 | |
| 308 | if( !is_user_logged_in() || is_super_admin() ) |
| 309 | return; |
| 310 | |
| 311 | extract( $args ); |
| 312 | |
| 313 | $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance ); |
| 314 | |
| 315 | echo $before_widget; |
| 316 | echo $before_title . |
| 317 | $title . |
| 318 | $after_title; |
| 319 | |
| 320 | // output content to display ?> |
| 321 | |
| 322 | <?php if ( bp_is_active( 'messages' ) ) : ?> |
| 323 | |
| 324 | <div class="bp-site-wide-message"> |
| 325 | <?php bp_message_get_notices(); ?> |
| 326 | </div> |
| 327 | |
| 328 | <?php endif; ?> |
| 329 | |
| 330 | <?php |
| 331 | //end markup output |
| 332 | |
| 333 | echo $after_widget; |
| 334 | |
| 335 | }// close function 'widget' |
| 336 | |
| 337 | public function update( $new_instance, $old_instance ) { |
| 338 | $instance = $old_instance; |
| 339 | $instance['title'] = strip_tags($new_instance['title']); |
| 340 | return $instance; |
| 341 | } |
| 342 | public function form( $instance ) { |
| 343 | $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); |
| 344 | $title = strip_tags($instance['title']); |
| 345 | |
| 346 | ?> |
| 347 | <p> |
| 348 | <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> |
| 349 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /> |
| 350 | </p> |
| 351 | <?php } |
| 352 | } |