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