Skip to:
Content

BuddyPress.org

Ticket #5143: 5143-02.patch

File 5143-02.patch, 3.2 KB (added by hnla, 12 years ago)

Remove check for theme_compat active to prevent widget loading on bp-default

  • bp-core/bp-core-widgets.php

     
    1414        add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
    1515        add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
    1616        add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
     17        add_action('widgets_init', create_function('', 'return register_widget("BP_Core_sitewide_messages_Widget");') );
    1718}
    1819add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
    1920
     
    287288        <?php
    288289        }
    289290}
     291/*** SITEWIDE MESSAGES WIDGET **********/
    290292
     293class 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}
    291350/** Widget AJAX ******************/
    292351
    293352function bp_core_ajax_widget_members() {
  • bp-templates/bp-legacy/buddypress-functions.php

     
    122122                /** Notices ***********************************************************/
    123123
    124124                if ( bp_is_active( 'messages' ) ) {
    125                         add_action( 'wp_footer', array( $this, 'sitewide_notices' ), 9999 );
     125                        if( !is_active_widget( false, false, 'bp_core_sitewide_messages_widget', true ) ) {
     126                                add_action( 'wp_footer', array( $this, 'sitewide_notices' ), 9999 );
     127                        }
    126128                }
    127129
    128130                /** Ajax **************************************************************/