Changeset 13615
- Timestamp:
- 10/19/2023 11:52:53 PM (2 years ago)
- Location:
- branches/11.0/src
- Files:
-
- 15 edited
-
bp-core/admin/bp-core-admin-functions.php (modified) (5 diffs)
-
bp-core/admin/css/common-rtl.css (modified) (3 diffs)
-
bp-core/admin/css/common.css (modified) (3 diffs)
-
bp-core/admin/js/dismissible-admin-notices.js (modified) (5 diffs)
-
bp-core/bp-core-functions.php (modified) (1 diff)
-
bp-core/bp-core-options.php (modified) (1 diff)
-
bp-core/bp-core-update.php (modified) (2 diffs)
-
bp-core/classes/class-bp-admin.php (modified) (4 diffs)
-
bp-core/css/admin-bar-rtl.css (modified) (1 diff)
-
bp-core/css/admin-bar.css (modified) (1 diff)
-
bp-members/admin/js/admin.js (modified) (5 diffs)
-
bp-members/bp-members-adminbar.php (modified) (2 diffs)
-
bp-notifications/bp-notifications-adminbar.php (modified) (2 diffs)
-
class-buddypress.php (modified) (1 diff)
-
js/bp-core/admin/js/dismissible-admin-notices.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/11.0/src/bp-core/admin/bp-core-admin-functions.php
r13550 r13615 512 512 'name' => __( 'Pages', 'buddypress' ), 513 513 ), 514 ' 3' => array(514 '4' => array( 515 515 'id' => 'bp-credits', 516 516 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'admin.php' ) ), … … 518 518 ), 519 519 ); 520 521 if ( bp_core_get_unread_admin_notifications() || ( isset( $_GET['page'] ) && 'bp-admin-notifications' === $_GET['page'] ) ) { 522 $settings_tabs['3'] = array( 523 'id' => 'bp-admin-notifications', 524 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-admin-notifications' ), 'admin.php' ) ), 525 'name' => __( 'Notifications', 'buddypress' ), 526 ); 527 } 520 528 521 529 if ( ! $apply_filters ) { … … 1413 1421 */ 1414 1422 function bp_core_admin_notice_dismiss_callback() { 1415 if ( ! current_user_can( ' install_plugins' ) ) {1423 if ( ! current_user_can( 'manage_options' ) ) { 1416 1424 wp_send_json_error(); 1417 1425 } … … 1440 1448 } 1441 1449 1442 bp_ update_option( "bp-dismissed-notice-{$notice_id}", true);1450 bp_core_dismiss_admin_notification( $notice_id ); 1443 1451 1444 1452 wp_send_json_success(); … … 1512 1520 } 1513 1521 add_action( 'bp_init', 'bp_block_init_category_filter' ); 1522 1523 /** 1524 * Outputs an Admin Notification. 1525 * 1526 * @since 11.4.0 1527 * 1528 * @param object $notification An Admin Notification object. 1529 */ 1530 function bp_core_admin_format_notifications( $notification = null ) { 1531 if ( ! isset( $notification->id ) ) { 1532 return ''; 1533 } 1534 ?> 1535 <div class="bp-welcome-panel bp-notice-container"> 1536 <a class="bp-welcome-panel-close bp-is-dismissible" href="#" data-notice_id="<?php echo esc_attr( $notification->id ); ?>" aria-label="<?php esc_attr_e( 'Dismiss the notification', 'buddypress' ); ?>"><?php esc_html_e( 'Dismiss', 'buddypress' ); ?></a> 1537 <div class="bp-welcome-panel-content"> 1538 <h2><span class="bp-version"><?php echo number_format_i18n( $notification->version, 1 ); ?></span> <?php echo esc_html( $notification->title ); ?></h2> 1539 <p class="about-description"> 1540 <?php echo wp_kses( $notification->content, array( 'a' => array( 'href' => true ), 'br' => array(), 'strong' => array() ) ); ?> 1541 </p> 1542 <div class="bp-admin-notification-action"><a href="<?php echo esc_url( $notification->href ); ?>" class="button button-primary"><?php echo esc_html( $notification->text ); ?></a></div> 1543 </div> 1544 </div> 1545 <?php 1546 } -
branches/11.0/src/bp-core/admin/css/common-rtl.css
r13368 r13615 41 41 .bp-badge:before { 42 42 content: "\f448"; 43 } 44 45 .bp-version { 46 color: #fff; 47 background: #d84800; 48 padding: 2px 5px; 43 49 } 44 50 … … 614 620 615 621 .buddypress .bp-welcome-panel-content p { 616 padding-bottom: 23px;617 622 font-size: 14px; 623 } 624 625 .buddypress .bp-welcome-panel-content .bp-admin-notification-action { 626 margin: 23px 0; 618 627 } 619 628 … … 698 707 } 699 708 709 .buddypress-body .form-table.hide { 710 display: none; 711 } 712 700 713 /* Media queries */ 701 714 @media screen and (max-width: 782px) { -
branches/11.0/src/bp-core/admin/css/common.css
r13368 r13615 41 41 .bp-badge:before { 42 42 content: "\f448"; 43 } 44 45 .bp-version { 46 color: #fff; 47 background: #d84800; 48 padding: 2px 5px; 43 49 } 44 50 … … 614 620 615 621 .buddypress .bp-welcome-panel-content p { 616 padding-bottom: 23px;617 622 font-size: 14px; 623 } 624 625 .buddypress .bp-welcome-panel-content .bp-admin-notification-action { 626 margin: 23px 0; 618 627 } 619 628 … … 698 707 } 699 708 709 .buddypress-body .form-table.hide { 710 display: none; 711 } 712 700 713 /* Media queries */ 701 714 @media screen and (max-width: 782px) { -
branches/11.0/src/bp-core/admin/js/dismissible-admin-notices.js
r13164 r13615 121 121 // Use the bp global. 122 122 window.bp = window.bp || {}; 123 123 124 /** 124 125 * Use an XHR request to dismiss admin notices. … … 126 127 * @since 10.0.0 127 128 */ 128 129 129 bp.DismissibleAdminNotices = class { 130 130 constructor(settings) { 131 131 this.settings = settings || {}; 132 132 } 133 134 133 start() { 135 134 const { … … 137 136 nonce 138 137 } = this.settings; 139 140 138 if (!url || !nonce) { 141 139 return; 142 140 } 143 144 141 document.querySelectorAll('.bp-is-dismissible').forEach(notice => { 145 142 notice.addEventListener('click', event => { 146 143 event.preventDefault(); 147 144 const noticeLink = event.target; 148 149 145 if (noticeLink.classList.contains('loading')) { 150 146 return; 151 } // Prevent multiple clicks.147 } 152 148 149 // Prevent multiple clicks. 150 noticeLink.classList.add('loading'); 153 151 154 noticeLink.classList.add('loading'); // Set the notice ID & notice container. 155 152 // Set the notice ID & notice container. 156 153 const { 157 154 notice_id 158 155 } = noticeLink.dataset; 159 const noticeContainer = noticeLink.closest('.bp-notice-container'); // Set notice headers.156 const noticeContainer = noticeLink.closest('.bp-notice-container'); 160 157 158 // Set notice headers. 161 159 const noticeHeaders = new Headers({ 162 160 'X-BP-Nonce': nonce 163 }); // Set notice data.161 }); 164 162 163 // Set notice data. 165 164 const noticeData = new FormData(); 166 165 noticeData.append('action', 'bp_dismiss_notice'); … … 176 175 success 177 176 } = data; 178 179 177 if (success) { 180 178 noticeContainer.remove(); 179 if (0 === document.querySelectorAll('.bp-notice-container').length) { 180 document.querySelector('#no-admin-notifications').classList.remove('hide'); 181 } 181 182 } else { 182 183 noticeLink.classList.remove('loading'); … … 186 187 }); 187 188 } 188 189 189 }; 190 190 const settings = window.bpDismissibleAdminNoticesSettings || {}; 191 191 const bpDismissibleAdminNotices = new bp.DismissibleAdminNotices(settings); 192 193 192 if ('loading' === document.readyState) { 194 193 document.addEventListener('DOMContentLoaded', bpDismissibleAdminNotices.start()); -
branches/11.0/src/bp-core/bp-core-functions.php
r13377 r13615 4892 4892 return $latest_deprecated_functions_versions; 4893 4893 } 4894 4895 /** 4896 * Returns the list of unread Admin Notification IDs. 4897 * 4898 * @since 11.4.0 4899 * 4900 * @return array The list of unread Admin Notification IDs. 4901 */ 4902 function bp_core_get_unread_admin_notifications() { 4903 return (array) bp_get_option( 'bp_unread_admin_notifications', array() ); 4904 } 4905 4906 /** 4907 * Dismisses an Admin Notification. 4908 * 4909 * @since 11.4.0 4910 * 4911 * @param string $notification_id The Admin Notification to dismiss. 4912 */ 4913 function bp_core_dismiss_admin_notification( $notification_id = '' ) { 4914 $unread = bp_core_get_unread_admin_notifications(); 4915 $remaining = array_diff( $unread, array( $notification_id ) ); 4916 bp_update_option( 'bp_unread_admin_notifications', $remaining ); 4917 } 4918 4919 /** 4920 * @since 11.4.0 4921 * 4922 * @return array The list of Admin notifications. 4923 */ 4924 function bp_core_get_admin_notifications() { 4925 $unreads = bp_core_get_unread_admin_notifications(); 4926 if ( ! $unreads ) { 4927 return array(); 4928 } 4929 4930 $admin_notifications = array( 4931 'bp100-welcome-addons' => (object) array( 4932 'id' => 'bp100-welcome-addons', 4933 'href' => add_query_arg( 4934 array( 4935 'tab' => 'bp-add-ons', 4936 'n' => 'bp100-welcome-addons', 4937 ), 4938 bp_get_admin_url( 'plugin-install.php' ) 4939 ), 4940 'text' => __( 'Discover BuddyPress Add-ons', 'buddypress' ), 4941 'title' => __( 'Hello BuddyPress Add-ons!', 'buddypress' ), 4942 'content' => __( 'Add-ons are features as Plugins or Blocks maintained by the BuddyPress development team & hosted on the WordPress.org plugins directory.', 'buddypress' ) . 4943 __( 'Thanks to this new tab inside your Dashboard screen to add plugins, you’ll be able to find them faster and eventually contribute to beta features early to give the BuddyPress development team your feedbacks.', 'buddypress' ), 4944 'version' => 10.0, 4945 ), 4946 'bp114-prepare-for-rewrites' => (object) array( 4947 'id' => 'bp114-prepare-for-rewrites', 4948 'href' => add_query_arg( 4949 array( 4950 'tab' => 'bp-add-ons', 4951 'show' => 'bp-classic', 4952 'n' => 'bp114-prepare-for-rewrites' 4953 ), 4954 bp_get_admin_url( 'plugin-install.php' ) 4955 ), 4956 'text' => __( 'Get The BP Classic Add-on', 'buddypress' ), 4957 'title' => __( 'Get ready for the brand-new BP Rewrites API!', 'buddypress' ), 4958 'content' => __( 'Our next major version (12.0.0) will introduce several large changes that could be incompatible with your site\'s configuration. To prevent problems, we\'ve built the BP Classic Add-on, which you may want to proactively install if any of the following cases:', 'buddypress' ) . '<br><br>' . 4959 '<strong>' . __( 'Some of your BuddyPress plugins have not been updated lately.', 'buddypress' ) . '</strong><br>' . 4960 __( 'BuddyPress 12.0.0 introduces the BP Rewrites API, which completely changes the way BuddyPress URLs are built and routed. This fundamental change requires most BuddyPress plugins to update how they deal with BuddyPress URLs. If your BuddyPress plugins have not been updated in the last few months, they are probably not ready for BuddyPress 12.0.0.', 'buddypress' ) . '<br><br>' . 4961 '<strong>' . __( 'You are still using the BP Default theme.', 'buddypress' ) . '</strong><br><br>' . 4962 '<strong>' . __( 'You still use a BP Legacy Widget.', 'buddypress' ) . '</strong><br><br>' . 4963 __( 'If any of the above items are true, we strongly advise you to install and activate the Classic Add-on before updating to BuddyPress 12.0.0.', 'buddypress' ), 4964 'version' => 11.4, 4965 ) 4966 ); 4967 4968 // Only keep unread notifications. 4969 foreach ( array_keys( $admin_notifications ) as $notification_id ) { 4970 if ( ! in_array( $notification_id, $unreads, true ) ) { 4971 unset( $admin_notifications[ $notification_id ] ); 4972 } 4973 } 4974 4975 return $admin_notifications; 4976 } -
branches/11.0/src/bp-core/bp-core-options.php
r12893 r13615 106 106 'widget_bp_groups_widget' => false, 107 107 'widget_bp_messages_sitewide_notices_widget' => false, 108 109 /* Admin Notifications **************************************/ 110 'bp_unread_admin_notifications' => array( 'bp114-prepare-for-rewrites' ), 108 111 ); 109 112 -
branches/11.0/src/bp-core/bp-core-update.php
r13304 r13615 288 288 289 289 // Version 11.0.0. 290 if ( $raw_db_version < 13271 ) {290 if ( $raw_db_version < 13271 ) { 291 291 bp_update_to_11_0(); 292 292 } 293 293 294 // Version 11.4.0. 295 if ( $raw_db_version < 13408 ) { 296 bp_update_to_11_4(); 297 } 294 298 } 295 299 … … 792 796 793 797 return $new_emails; 798 } 799 800 /** 801 * 11.4.0 update routine. 802 * 803 * @since 11.4.0 804 */ 805 function bp_update_to_11_4() { 806 $unread = array( 'bp114-prepare-for-rewrites' ); 807 808 // Check if 10.0 notice was dismissed. 809 $old_dismissed = (bool) bp_get_option( 'bp-dismissed-notice-bp100-welcome-addons', false ); 810 if ( ! $old_dismissed ) { 811 $unread[] = 'bp100-welcome-addons'; 812 } 813 814 // Remove the dismissible option. 815 bp_delete_option( 'bp-dismissed-notice-bp100-welcome-addons' ); 816 817 // Create unread Admin notifications. 818 bp_update_option( 'bp_unread_admin_notifications', $unread ); 794 819 } 795 820 -
branches/11.0/src/bp-core/classes/class-bp-admin.php
r13613 r13615 298 298 $this->submenu_pages['settings']['bp-settings'] = $bp_settings_page; 299 299 $hooks[] = $bp_settings_page; 300 301 // Admin notifications. 302 $bp_admin_notifications = add_submenu_page( 303 $this->settings_page, 304 __( 'BuddyPress Admin Notifications', 'buddypress' ), 305 __( 'BuddyPress Admin Notifications', 'buddypress' ), 306 $this->capability, 307 'bp-admin-notifications', 308 array( $this, 'admin_notifications' ) 309 ); 310 311 $this->submenu_pages['settings']['bp-admin-notifications'] = $bp_admin_notifications; 312 $hooks[] = $bp_admin_notifications; 300 313 301 314 // Credits. … … 626 639 627 640 // Settings pages. 628 remove_submenu_page( $this->settings_page, 'bp-page-settings' ); 629 remove_submenu_page( $this->settings_page, 'bp-settings' ); 630 remove_submenu_page( $this->settings_page, 'bp-credits' ); 641 remove_submenu_page( $this->settings_page, 'bp-page-settings' ); 642 remove_submenu_page( $this->settings_page, 'bp-settings' ); 643 remove_submenu_page( $this->settings_page, 'bp-credits' ); 644 remove_submenu_page( $this->settings_page, 'bp-admin-notifications' ); 631 645 632 646 // Network Admin Tools. … … 1541 1555 */ 1542 1556 public function display_addons_table() { 1543 $notice_id = 'bp100-welcome-addons';1544 $dismissed = bp_get_option( "bp-dismissed-notice-{$notice_id}", false );1545 1546 if ( ! $dismissed ) {1547 // Enqueue the Script to Ajax Dismiss an Admin notice.1548 wp_enqueue_script( 'bp-dismissible-admin-notices' );1549 1550 ?>1551 <div class="bp-welcome-panel bp-notice-container">1552 <a class="bp-welcome-panel-close bp-is-dismissible" href="#" data-notice_id="<?php echo esc_attr( $notice_id ); ?>" aria-label="<?php esc_attr_e( 'Dismiss the welcome panel', 'buddypress' ); ?>"><?php esc_html_e( 'Dismiss', 'buddypress' ); ?></a>1553 <div class="bp-welcome-panel-content">1554 <h2><span class="bp-badge"></span> <?php esc_html_e( 'Hello BuddyPress Add-ons!', 'buddypress' ); ?></h2>1555 <p class="about-description">1556 <?php esc_html_e( 'Add-ons are features as Plugins or Blocks maintained by the BuddyPress development team & hosted on the WordPress.org plugins directory.', 'buddypress' ); ?>1557 <?php esc_html_e( 'Thanks to this new tab inside your Dashboard screen to add plugins, you’ll be able to find them faster and eventually contribute to beta features early to give the BuddyPress development team your feedbacks.', 'buddypress' ); ?>1558 </p>1559 </div>1560 </div>1561 <?php1562 }1563 1564 1557 if ( isset( $_GET['show'] ) && 'bp-classic' === $_GET['show'] ) { 1565 1558 wp_add_inline_script( … … 1577 1570 } 1578 1571 1572 if ( isset( $_GET['n'] ) && $_GET['n'] ) { 1573 $notification_id = sanitize_text_field( wp_unslash( $_GET['n'] ) ); 1574 bp_core_dismiss_admin_notification( $notification_id ); 1575 } 1576 1579 1577 // Display the "buddypress" favorites. 1580 1578 display_plugins_table(); 1581 1579 } 1580 1581 /** 1582 * Display the Admin Notifications screen. 1583 * 1584 * @since 11.4.0 1585 */ 1586 public function admin_notifications() { 1587 bp_core_admin_tabbed_screen_header( __( 'BuddyPress Settings', 'buddypress' ), __( 'Notifications', 'buddypress' ) ); 1588 $notifications = bp_core_get_admin_notifications(); 1589 $class = ''; 1590 1591 if ( $notifications ) { 1592 wp_enqueue_script( 'bp-dismissible-admin-notices' ); 1593 $notifications = array_reverse( bp_sort_by_key( $notifications, 'version', 'num' ) ); 1594 $class = 'hide'; 1595 } 1596 ?> 1597 <div class="buddypress-body admin-notifications"> 1598 <table id="no-admin-notifications" class="form-table <?php echo sanitize_html_class( $class ); ?>" role="presentation"> 1599 <tbody> 1600 <tr><td><?php esc_html_e( 'No new Admin Notfications', 'buddypress' ); ?></td><tr> 1601 </tbody> 1602 </table> 1603 1604 <?php if ( $notifications ) : foreach ( $notifications as $notification ) : ?> 1605 <?php bp_core_admin_format_notifications( $notification ); ?> 1606 <?php endforeach; endif; ?> 1607 </div> 1608 <?php 1609 } 1582 1610 } 1583 1611 endif; // End class_exists check. -
branches/11.0/src/bp-core/css/admin-bar-rtl.css
r12877 r13615 47 47 } 48 48 49 #wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert.admin-type { 50 background-color: #d84800; 51 } 52 49 53 #wpadminbar .quicklinks li#wp-admin-bar-bp-notifications > a { 50 54 padding: 0 0.5em; -
branches/11.0/src/bp-core/css/admin-bar.css
r12877 r13615 47 47 } 48 48 49 #wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert.admin-type { 50 background-color: #d84800; 51 } 52 49 53 #wpadminbar .quicklinks li#wp-admin-bar-bp-notifications > a { 50 54 padding: 0 0.5em; -
branches/11.0/src/bp-members/admin/js/admin.js
r13164 r13615 121 121 // Use the bp global. 122 122 window.bp = window.bp || {}; 123 123 124 /** 124 125 * Clears the checked/selected options of a radio button or a multiple select. … … 128 129 * @returns {void} 129 130 */ 130 131 131 bp.clear = container => { 132 132 const optionsContainer = document.getElementById(container); 133 134 133 if (!optionsContainer) { 135 134 return; 136 135 } 137 138 136 const checkedRadio = optionsContainer.querySelector('input:checked'); 139 137 const allOptions = optionsContainer.querySelectorAll('option'); 140 141 138 if (checkedRadio) { 142 139 checkedRadio.checked = ''; 143 140 } 144 145 141 if (allOptions) { 146 142 allOptions.forEach(option => { … … 149 145 } 150 146 }; 151 152 147 document.querySelectorAll('.visibility-toggle-link').forEach(button => { 153 148 button.addEventListener('click', event => { … … 155 150 const changeButton = event.target; 156 151 const changeButtonContainer = changeButton.closest('.field-visibility-settings-toggle'); 157 const settingsContainer = changeButtonContainer.nextElementSibling; // Hides the "Change" button.152 const settingsContainer = changeButtonContainer.nextElementSibling; 158 153 154 // Hides the "Change" button. 159 155 changeButton.setAttribute('aria-expanded', true); 160 changeButtonContainer.style.display = 'none'; // Displays the settings visibility container.156 changeButtonContainer.style.display = 'none'; 161 157 158 // Displays the settings visibility container. 162 159 settingsContainer.style.display = 'block'; 163 160 }); … … 169 166 const settingsContainer = closeButton.closest('.field-visibility-settings'); 170 167 const changeButtonContainer = settingsContainer.previousElementSibling; 171 const currentVisibility = settingsContainer.querySelector('input:checked').nextElementSibling.innerHTML; // Closes the visibility settings options.168 const currentVisibility = settingsContainer.querySelector('input:checked').nextElementSibling.innerHTML; 172 169 173 settingsContainer.style.display = 'none'; // Displays the current visibility. 170 // Closes the visibility settings options. 171 settingsContainer.style.display = 'none'; 174 172 173 // Displays the current visibility. 175 174 changeButtonContainer.querySelector('.visibility-toggle-link').setAttribute('aria-expanded', false); 176 175 changeButtonContainer.querySelector('.current-visibility-level').innerHTML = currentVisibility; -
branches/11.0/src/bp-members/bp-members-adminbar.php
r12945 r13615 154 154 * Build the "Notifications" dropdown. 155 155 * 156 * @since 11.4.0 157 */ 158 function bp_members_admin_bar_notifications_dropdown( $notifications = array(), $menu_link = '', $type = 'members' ) { 159 if ( ! $menu_link || ( 'admin' === $type && empty( $notifications ) ) ) { 160 return false; 161 } 162 163 global $wp_admin_bar; 164 165 $count = 0; 166 $alert_class = array( 'count', 'no-alert' ); 167 168 if ( ! empty( $notifications ) ) { 169 $count = number_format_i18n( count( $notifications ) ); 170 $alert_class = array( 'pending-count', 'alert' ); 171 172 if ( 'admin' === $type ) { 173 $count = '!'; 174 } 175 }; 176 177 $alert_class[] = $type . '-type'; 178 $menu_title = sprintf( 179 '<span id="ab-pending-notifications" class="%1$s">%2$s</span>', 180 implode( ' ', array_map( 'sanitize_html_class', $alert_class ) ), 181 $count 182 ); 183 184 // Add the top-level Notifications button. 185 $wp_admin_bar->add_node( array( 186 'parent' => 'top-secondary', 187 'id' => 'bp-notifications', 188 'title' => $menu_title, 189 'href' => $menu_link, 190 ) ); 191 192 if ( ! empty( $notifications ) ) { 193 foreach ( (array) $notifications as $notification ) { 194 $wp_admin_bar->add_node( array( 195 'parent' => 'bp-notifications', 196 'id' => 'notification-' . $notification->id, 197 'title' => $notification->content, 198 'href' => $notification->href, 199 ) ); 200 } 201 } else { 202 $wp_admin_bar->add_node( array( 203 'parent' => 'bp-notifications', 204 'id' => 'no-notifications', 205 'title' => __( 'No new notifications', 'buddypress' ), 206 'href' => $menu_link, 207 ) ); 208 } 209 210 return true; 211 } 212 213 /** 214 * Build the Admin or Members "Notifications" dropdown. 215 * 156 216 * @since 1.5.0 157 217 * … … 159 219 */ 160 220 function bp_members_admin_bar_notifications_menu() { 161 162 // Bail if notifications is not active. 163 if ( ! bp_is_active( 'notifications' ) ) { 164 return false; 165 } 166 167 bp_notifications_toolbar_menu(); 221 $admins_notifications = array(); 222 $capability = 'manage_options'; 223 224 if ( bp_core_do_network_admin() ) { 225 $capability = 'manage_network_options'; 226 } 227 228 if ( bp_current_user_can( $capability ) ) { 229 $notifications = bp_core_get_admin_notifications(); 230 231 if ( $notifications ) { 232 $menu_link = esc_url( bp_get_admin_url( add_query_arg( 'page', 'bp-admin-notifications', 'admin.php' ) ) ); 233 $count = count( $notifications ); 234 235 $notifications = array( 236 (object) array( 237 'id' => 'bp-admin-notifications', 238 'href' => $menu_link, 239 'content' => sprintf( 240 /* translators: %s: the number of admin notifications */ 241 _n( 'You have %s new important admin notification.', 'You have %s new important admin notifications.', $count, 'buddypress' ), 242 number_format_i18n( $count ) 243 ), 244 ), 245 ); 246 247 return bp_members_admin_bar_notifications_dropdown( $notifications, $menu_link, 'admin' ); 248 } 249 } 250 251 // Use Members notifications if the component is active. 252 if ( bp_is_active( 'notifications' ) ) { 253 return bp_notifications_toolbar_menu(); 254 } 168 255 } 169 256 add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 ); -
branches/11.0/src/bp-notifications/bp-notifications-adminbar.php
r13091 r13615 18 18 * @since 1.9.0 19 19 * 20 * @global WP_Admin_Bar $wp_admin_bar The WordPress object implementing a Toolbar API. 21 * 20 22 * @return bool 21 23 */ 22 24 function bp_notifications_toolbar_menu() { 23 global $wp_admin_bar;24 25 25 if ( ! is_user_logged_in() ) { 26 26 return false; … … 28 28 29 29 $notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id(), 'object' ); 30 $count = ! empty( $notifications ) ? count( $notifications ) : 0;31 $alert_class = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';32 $menu_title = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . number_format_i18n( $count ) . '</span>';33 30 $menu_link = trailingslashit( bp_loggedin_user_domain() . bp_get_notifications_slug() ); 34 31 35 // Add the top-level Notifications button. 36 $wp_admin_bar->add_node( array( 37 'parent' => 'top-secondary', 38 'id' => 'bp-notifications', 39 'title' => $menu_title, 40 'href' => $menu_link, 41 ) ); 42 43 if ( ! empty( $notifications ) ) { 44 foreach ( (array) $notifications as $notification ) { 45 $wp_admin_bar->add_node( array( 46 'parent' => 'bp-notifications', 47 'id' => 'notification-' . $notification->id, 48 'title' => $notification->content, 49 'href' => $notification->href, 50 ) ); 51 } 52 } else { 53 $wp_admin_bar->add_node( array( 54 'parent' => 'bp-notifications', 55 'id' => 'no-notifications', 56 'title' => __( 'No new notifications', 'buddypress' ), 57 'href' => $menu_link, 58 ) ); 59 } 60 61 return true; 32 return bp_members_admin_bar_notifications_dropdown( $notifications, $menu_link ); 62 33 } 63 add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 ); -
branches/11.0/src/class-buddypress.php
r13610 r13615 351 351 352 352 $this->version = '11.3.2'; 353 $this->db_version = 13 271;353 $this->db_version = 13408; 354 354 355 355 /** Loading */ -
branches/11.0/src/js/bp-core/admin/js/dismissible-admin-notices.js
r13164 r13615 56 56 if ( success ) { 57 57 noticeContainer.remove(); 58 59 if ( 0 === document.querySelectorAll( '.bp-notice-container' ).length ) { 60 document.querySelector( '#no-admin-notifications' ).classList.remove( 'hide' ); 61 } 58 62 } else { 59 63 noticeLink.classList.remove( 'loading' );
Note: See TracChangeset
for help on using the changeset viewer.