Esempio n. 1
0
    /**
     * Render the widget.
     *
     * @see WP_Widget::widget() for a description of parameters.
     *
     * @param array $args See {@WP_Widget::widget()}.
     * @param array $args See {@WP_Widget::widget()}.
     */
    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'] : '';
        $title = apply_filters('widget_title', $title, $instance);
        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;
    }
 /**
  * @group cache
  */
 public function test_get_active_notices()
 {
     // send notice
     $subject = 'Test notice';
     $message = 'This is a notice';
     messages_send_notice($subject, $message);
     // now get the active notice and assert
     $notice = BP_Messages_Notice::get_active();
     $this->assertEquals($subject, $notice->subject);
     $this->assertEquals($message, $notice->message);
     // deactivate notice and make sure cache is invalidated
     $notice->deactivate();
     $this->assertFalse(wp_cache_get('active_notice', 'bp_messages'));
     // create a new notice
     $subject2 = 'Another notice';
     $message2 = 'Say what?';
     messages_send_notice($subject2, $message2);
     // now get the new active notice
     BP_Messages_Notice::get_active();
     // grab the cache and make sure it equals our new notice
     $cache = wp_cache_get('active_notice', 'bp_messages');
     $this->assertEquals($subject2, $cache->subject);
     $this->assertEquals($message2, $cache->message);
 }
    /**
     * Render the widget.
     *
     * @see WP_Widget::widget() for a description of parameters.
     *
     * @param array $args     See {@WP_Widget::widget()}.
     * @param array $instance See {@WP_Widget::widget()}.
     */
    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 1.9.0
         * @since 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;
    }
function bp_message_get_notices()
{
    global $userdata;
    $notice = BP_Messages_Notice::get_active();
    $closed_notices = get_usermeta($userdata->ID, 'closed_notices');
    if (!$closed_notices) {
        $closed_notices = array();
    }
    if (is_array($closed_notices)) {
        if (!in_array($notice->id, $closed_notices) && $notice->id) {
            ?>
			<div class="notice" id="<?php 
            echo $notice->id;
            ?>
">
				<h5><?php 
            echo stripslashes($notice->subject);
            ?>
</h5>
				<?php 
            echo stripslashes($notice->message);
            ?>
				<a href="#" id="close-notice"><?php 
            _e('Close', 'buddypress');
            ?>
</a>
			</div>
			<?php 
        }
    }
}
/**
 * Generate markup for currently active notices.
 */
function bp_message_get_notices()
{
    $notice = BP_Messages_Notice::get_active();
    if (empty($notice)) {
        return false;
    }
    $closed_notices = bp_get_user_meta(bp_loggedin_user_id(), 'closed_notices', true);
    if (empty($closed_notices)) {
        $closed_notices = array();
    }
    if (is_array($closed_notices)) {
        if (!in_array($notice->id, $closed_notices) && $notice->id) {
            ?>
			<div id="message" class="info notice" rel="n-<?php 
            echo esc_attr($notice->id);
            ?>
">
				<p>
					<strong><?php 
            echo stripslashes(wp_filter_kses($notice->subject));
            ?>
</strong><br />
					<?php 
            echo stripslashes(wp_filter_kses($notice->message));
            ?>
					<a href="#" id="close-notice"><?php 
            _e('Close', 'buddypress');
            ?>
</a>
				</p>
			</div>
			<?php 
        }
    }
}
function firmasite_bp_message_get_notices()
{
    global $userdata;
    $notice = BP_Messages_Notice::get_active();
    if (empty($notice)) {
        return false;
    }
    $closed_notices = bp_get_user_meta($userdata->ID, 'closed_notices', true);
    if (!$closed_notices) {
        $closed_notices = array();
    }
    if (is_array($closed_notices)) {
        if (!in_array($notice->id, $closed_notices) && $notice->id) {
            ?>
		<div id="message-<?php 
            echo $notice->id;
            ?>
" class="info notice modal fade" rel="n-<?php 
            echo $notice->id;
            ?>
" tabindex="-1" role="dialog" aria-hidden="false">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <h3 class="modal-title"><?php 
            echo stripslashes(wp_filter_kses($notice->subject));
            ?>
</h3>
              </div>
              <div class="modal-body">
                <p><?php 
            echo stripslashes(wp_filter_kses($notice->message));
            ?>
</p>
              </div>              
              <div class="modal-footer">
                <a href="#" id="close-notice" class="btn btn-primary" data-dismiss="modal" aria-hidden="true"><?php 
            _e('Close', 'firmasite');
            ?>
</a>
              </div>
            </div><!-- /.modal-content -->
          </div><!-- /.modal-dialog -->
		</div>
            <script> 
			jQuery(document).ready(function() {
				jQuery('#message-<?php 
            echo $notice->id;
            ?>
').modal('show'); 
				jQuery("#message-<?php 
            echo $notice->id;
            ?>
 #close-notice").click(function(){ jQuery('#message-<?php 
            echo $notice->id;
            ?>
').modal('hide'); });
            });
            </script>
			<?php 
        }
    }
}
Esempio n. 7
0
function bp_message_get_notices() {
	global $userdata;

	$notice = BP_Messages_Notice::get_active();

	if ( empty( $notice ) )
		return false;

	$closed_notices = get_user_meta( $userdata->ID, 'closed_notices', true );

	if ( !$closed_notices )
		$closed_notices = array();

	if ( is_array($closed_notices) ) {
		if ( !in_array( $notice->id, $closed_notices ) && $notice->id ) {
			?>
			<div id="message" class="info notice" rel="n-<?php echo $notice->id ?>">
				<p>
					<strong><?php echo stripslashes( wp_filter_kses( $notice->subject ) ) ?></strong><br />
					<?php echo stripslashes( wp_filter_kses( $notice->message) ) ?>
					<a href="#" id="close-notice"><?php _e( 'Close', 'buddypress' ) ?></a>
				</p>
			</div>
			<?php
		}
	}
}
/**
 * Customize bp_message_get_notices() function 
 *
 * Instead of down in the sidebar, the sitewide notice display is moved to just above the primary navigation.  
 *
 * @since 1.6
 */
function frisco_bp_message_get_notices()
{
    global $userdata;
    $notice = BP_Messages_Notice::get_active();
    if (empty($notice)) {
        return false;
    }
    $closed_notices = bp_get_user_meta($userdata->ID, 'closed_notices', true);
    if (!$closed_notices) {
        $closed_notices = array();
    }
    if (is_array($closed_notices)) {
        if (!in_array($notice->id, $closed_notices) && $notice->id) {
            ?>
			<div id="message" class="info notice frisco_notice" rel="n-<?php 
            echo $notice->id;
            ?>
">
				<p>
					<strong><?php 
            echo stripslashes(wp_filter_kses($notice->subject));
            ?>
</strong>
					<?php 
            echo stripslashes(wp_filter_kses($notice->message));
            ?>
					<a href="#" id="close-notice"><?php 
            _e('x', 'friscotheme');
            ?>
</a>
				</p>
			</div>
			<?php 
        }
    }
}