Ticket #4802: 4802.diff
| File 4802.diff, 6.8 KB (added by , 13 years ago) |
|---|
-
bp-templates/bp-legacy/buddypress-functions.php
96 96 add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS 97 97 add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization 98 98 add_action( 'bp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the <head> 99 add_action( 'dynamic_sidebar', array( $this, 'get_notices' ), 10, 1 ); // Output the admin notices if any 99 100 100 101 /** Buttons ***********************************************************/ 101 102 … … 284 285 285 286 <?php 286 287 } 288 289 /** 290 * Hooks dynamic_sidebar to reference a new hook for Admin notices 291 * 292 * @param array $widget_array the first widget data 293 * @uses do_action_ref_array to reference bp_legacy_get_notices new hook 294 */ 295 public function get_notices( $widget_array = false ) { 296 do_action_ref_array( 'bp_legacy_get_notices', array( $widget_array ) ); 297 } 287 298 288 299 /** 289 300 * Load localizations for topic script … … 1200 1211 1201 1212 exit; 1202 1213 } 1214 1215 /** 1216 * formats the notices in order to respect theme's widget structure 1217 * 1218 * @param array $args (the widget structure) 1219 * @uses wp_parse_args() to merge with the theme's widget structure 1220 * @uses bp_message_get_notices() to output the notices 1221 */ 1222 function bp_legacy_format_notices( $args = array() ) { 1223 1224 $defaults = array( 1225 'before_widget' => '<li id="%1$s" class="widget %2$s">', 1226 'after_widget' => "</li>\n" 1227 ); 1228 1229 $r = wp_parse_args( $args, $defaults ); 1230 extract( $r ); 1231 1232 $before_widget = sprintf( $before_widget, 'bp-sidebar-notice', '' ); 1233 1234 /* 1235 I added this 2 vars which default to false to bp_message_get_notices 1236 in order to add an id to the notices container so that we can style it 1237 as in the sidebar, the identifier #buddypress is not available 1238 */ 1239 bp_message_get_notices( $before_widget, $after_widget ); 1240 1241 } 1242 1243 /** 1244 * Eventually prints once (and only) the notices in the sidebar 1245 * 1246 * using the new hook bp_legacy_get_notices to check did_action 1247 * this way if someone else hooks dynamic_sidebar, it won't interfere 1248 * in our amount of actions to count. 1249 * 1250 * @param array $widget_array 1251 * @global $wp_registered_sidebars to get the theme's widget structure 1252 * @uses did_action() to check the number of time bp_legacy_get_notices is hooked 1253 * @uses is_admin() to stop the process if we're in backend 1254 * @uses bp_is_active() to stop the process if messages component is not active 1255 * @uses bp_legacy_format_notices() to respect theme's widget structure to print notices 1256 */ 1257 function bp_legacy_print_notices( $widget_array = false ) { 1258 global $wp_registered_sidebars; 1259 1260 $did_action = did_action( 'bp_legacy_get_notices' ); 1261 1262 if( is_admin() ) 1263 return; 1264 1265 if ( !bp_is_active( 'messages' ) ) 1266 return; 1267 1268 // this way we print the notice before the first widget and not at every widget. 1269 if( $did_action <= 1 ) { 1270 1271 $notices_args = array(); 1272 1273 if( count( $wp_registered_sidebars ) >= 1 ) { 1274 1275 $widget_structure = array_slice( $wp_registered_sidebars, 0, 1 ); 1276 $widget_sisebar_id = key( $widget_structure ); 1277 $notice_args = $widget_structure[$widget_sisebar_id]; 1278 } 1279 1280 bp_legacy_format_notices( $notice_args ); 1281 } 1282 } 1283 1284 add_action( 'bp_legacy_get_notices', 'bp_legacy_print_notices', 10, 1 ); 1285 No newline at end of file -
bp-templates/bp-legacy/css/buddypress.css
506 506 #buddypress div#message.updated { 507 507 clear: both; 508 508 } 509 #buddypress div#message p {509 #buddypress div#message p, #bp-sidebar-notice div#message p { 510 510 font-size: 90%; 511 511 display: block; 512 512 padding: 10px 15px; … … 1003 1003 font-weight: bold; 1004 1004 } 1005 1005 #buddypress span.activity, 1006 #buddypress div#message p {1006 #buddypress div#message p, #bp-sidebar-notice div#message p { 1007 1007 border: 1px solid #e1ca82; 1008 1008 -moz-border-radius: 3px; 1009 1009 -webkit-border-radius: 3px; -
bp-messages/bp-messages-template.php
584 584 return apply_filters( 'bp_get_messages_slug', $bp->messages->slug ); 585 585 } 586 586 587 function bp_message_get_notices() { 587 /** 588 * Displays admin notices in the sidebar 589 * 590 * @param string $before_notice used by bp_legacy_format_notices to add before_widget html 591 * @param string $after_notice used by bp_legacy_format_notices to add after_widget html 592 */ 593 function bp_message_get_notices( $before_notice = false, $after_notice = false ) { 588 594 global $userdata; 589 595 590 596 $notice = BP_Messages_Notice::get_active(); … … 599 605 600 606 if ( is_array($closed_notices) ) { 601 607 if ( !in_array( $notice->id, $closed_notices ) && $notice->id ) { 608 echo $before_notice; 602 609 ?> 603 610 <div id="message" class="info notice" rel="n-<?php echo $notice->id ?>"> 604 611 <p> … … 608 615 </p> 609 616 </div> 610 617 <?php 618 echo $after_notice; 611 619 } 612 620 } 613 621 } -
bp-messages/bp-messages-screens.php
160 160 161 161 if ( !$new_messages = bp_get_user_meta( bp_displayed_user_id(), 'notification_messages_new_message', true ) ) 162 162 $new_messages = 'yes'; 163 164 ?> 163 165 164 if ( !$new_notices = bp_get_user_meta( bp_displayed_user_id(), 'notification_messages_new_notice', true ) )165 $new_notices = 'yes'; ?>166 167 166 <table class="notification-settings" id="messages-notification-settings"> 168 167 <thead> 169 168 <tr> … … 181 180 <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php checked( $new_messages, 'yes', true ) ?>/></td> 182 181 <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php checked( $new_messages, 'no', true ) ?>/></td> 183 182 </tr> 184 <tr id="messages-notification-settings-new-site-notice">185 <td></td>186 <td><?php _e( 'A new site notice is posted', 'buddypress' ) ?></td>187 <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php checked( $new_notices, 'yes', true ) ?>/></td>188 <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php checked( $new_notices, 'no', true ) ?>/></td>189 </tr>190 183 191 184 <?php do_action( 'messages_screen_notification_settings' ) ?> 192 185 </tbody>