Index: bp-templates/bp-legacy/buddypress-functions.php
===================================================================
--- bp-templates/bp-legacy/buddypress-functions.php (revision 6761)
+++ bp-templates/bp-legacy/buddypress-functions.php (working copy)
@@ -96,6 +96,7 @@
add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS
add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization
add_action( 'bp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the
+ add_action( 'dynamic_sidebar', array( $this, 'get_notices' ), 10, 1 ); // Output the admin notices if any
/** Buttons ***********************************************************/
@@ -284,6 +285,16 @@
'',
+ 'after_widget' => "\n"
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r );
+
+ $before_widget = sprintf( $before_widget, 'bp-sidebar-notice', '' );
+
+ /*
+ I added this 2 vars which default to false to bp_message_get_notices
+ in order to add an id to the notices container so that we can style it
+ as in the sidebar, the identifier #buddypress is not available
+ */
+ bp_message_get_notices( $before_widget, $after_widget );
+
+}
+
+/**
+ * Eventually prints once (and only) the notices in the sidebar
+ *
+ * using the new hook bp_legacy_get_notices to check did_action
+ * this way if someone else hooks dynamic_sidebar, it won't interfere
+ * in our amount of actions to count.
+ *
+ * @param array $widget_array
+ * @global $wp_registered_sidebars to get the theme's widget structure
+ * @uses did_action() to check the number of time bp_legacy_get_notices is hooked
+ * @uses is_admin() to stop the process if we're in backend
+ * @uses bp_is_active() to stop the process if messages component is not active
+ * @uses bp_legacy_format_notices() to respect theme's widget structure to print notices
+ */
+function bp_legacy_print_notices( $widget_array = false ) {
+ global $wp_registered_sidebars;
+
+ $did_action = did_action( 'bp_legacy_get_notices' );
+
+ if( is_admin() )
+ return;
+
+ if ( !bp_is_active( 'messages' ) )
+ return;
+
+ // this way we print the notice before the first widget and not at every widget.
+ if( $did_action <= 1 ) {
+
+ $notices_args = array();
+
+ if( count( $wp_registered_sidebars ) >= 1 ) {
+
+ $widget_structure = array_slice( $wp_registered_sidebars, 0, 1 );
+ $widget_sisebar_id = key( $widget_structure );
+ $notice_args = $widget_structure[$widget_sisebar_id];
+ }
+
+ bp_legacy_format_notices( $notice_args );
+ }
+}
+
+add_action( 'bp_legacy_get_notices', 'bp_legacy_print_notices', 10, 1 );
\ No newline at end of file
Index: bp-templates/bp-legacy/css/buddypress.css
===================================================================
--- bp-templates/bp-legacy/css/buddypress.css (revision 6761)
+++ bp-templates/bp-legacy/css/buddypress.css (working copy)
@@ -506,7 +506,7 @@
#buddypress div#message.updated {
clear: both;
}
-#buddypress div#message p {
+#buddypress div#message p, #bp-sidebar-notice div#message p {
font-size: 90%;
display: block;
padding: 10px 15px;
@@ -1003,7 +1003,7 @@
font-weight: bold;
}
#buddypress span.activity,
-#buddypress div#message p {
+#buddypress div#message p, #bp-sidebar-notice div#message p {
border: 1px solid #e1ca82;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
Index: bp-messages/bp-messages-template.php
===================================================================
--- bp-messages/bp-messages-template.php (revision 6761)
+++ bp-messages/bp-messages-template.php (working copy)
@@ -584,7 +584,13 @@
return apply_filters( 'bp_get_messages_slug', $bp->messages->slug );
}
-function bp_message_get_notices() {
+/**
+ * Displays admin notices in the sidebar
+ *
+ * @param string $before_notice used by bp_legacy_format_notices to add before_widget html
+ * @param string $after_notice used by bp_legacy_format_notices to add after_widget html
+ */
+function bp_message_get_notices( $before_notice = false, $after_notice = false ) {
global $userdata;
$notice = BP_Messages_Notice::get_active();
@@ -599,6 +605,7 @@
if ( is_array($closed_notices) ) {
if ( !in_array( $notice->id, $closed_notices ) && $notice->id ) {
+ echo $before_notice;
?>
- if ( !$new_notices = bp_get_user_meta( bp_displayed_user_id(), 'notification_messages_new_notice', true ) )
- $new_notices = 'yes'; ?>
-