Skip to:
Content

BuddyPress.org

Ticket #8547: 8547.patch

File 8547.patch, 4.3 KB (added by imath, 3 years ago)
  • src/bp-templates/bp-nouveau/includes/messages/functions.php

    diff --git src/bp-templates/bp-nouveau/includes/messages/functions.php src/bp-templates/bp-nouveau/includes/messages/functions.php
    index 1ec7d6e26..a6c7a3064 100644
     
    33 * Messages functions
    44 *
    55 * @since 3.0.0
    6  * @version 3.1.0
     6 * @version 10.0.0
    77 */
    88
    99// Exit if accessed directly.
    function bp_nouveau_messages_adjust_admin_nav( $admin_nav ) { 
    190190}
    191191
    192192/**
     193 * Prepend a notification about the active Sitewide notice.
     194 *
    193195 * @since 3.0.0
     196 *
     197 * @param false|array $notifications False if there are no items, an array of notification items otherwise.
     198 * @param int         $user_id       The user ID.
     199 * @return false|array               False if there are no items, an array of notification items otherwise.
    194200 */
    195201function bp_nouveau_add_notice_notification_for_user( $notifications, $user_id ) {
    196202        if ( ! bp_is_active( 'messages' ) || ! doing_action( 'admin_bar_menu' ) ) {
    function bp_nouveau_add_notice_notification_for_user( $notifications, $user_id ) 
    211217                return $notifications;
    212218        }
    213219
    214         $notice_notification                    = new stdClass;
    215         $notice_notification->id                = 0;
    216         $notice_notification->user_id           = $user_id;
    217         $notice_notification->item_id           = $notice->id;
    218         $notice_notification->secondary_item_id = '';
    219         $notice_notification->component_name    = 'messages';
    220         $notice_notification->component_action  = 'new_notice';
    221         $notice_notification->date_notified     = $notice->date_sent;
    222         $notice_notification->is_new            = '1';
    223 
    224         return array_merge( $notifications, array( $notice_notification ) );
     220        $notice_notification = (object) array(
     221                'id'                => 0,
     222                'user_id'           => $user_id,
     223                'item_id'           => $notice->id,
     224                'secondary_item_id' => 0,
     225                'component_name'    => 'messages',
     226                'component_action'  => 'new_notice',
     227                'date_notified'     => $notice->date_sent,
     228                'is_new'            => 1,
     229                'total_count'       => 1,
     230                'content'           => __( 'New sitewide notice', 'buddypress' ),
     231                'href'              => bp_loggedin_user_domain(),
     232        );
     233
     234        if ( ! is_array( $notifications ) ) {
     235                $notifications = array( $notice_notification );
     236        } else {
     237                array_unshift( $notifications, $notice_notification );
     238        }
     239
     240        return $notifications;
    225241}
    226242
    227243/**
     244 * Format the notice notifications.
     245 *
    228246 * @since 3.0.0
     247 * @deprecated 10.0.0
     248 *
     249 * @param array $array.
    229250 */
    230251function bp_nouveau_format_notice_notification_for_user( $array ) {
    231         if ( ! empty( $array['text'] ) || ! doing_action( 'admin_bar_menu' ) ) {
    232                 return $array;
    233         }
    234 
    235         return array(
    236                 'text' => __( 'New sitewide notice', 'buddypress' ),
    237                 'link' => bp_loggedin_user_domain(),
    238         );
     252        _deprecated_function( __FUNCTION__, '10.0.0' );
    239253}
    240254
    241255/**
  • src/bp-templates/bp-nouveau/includes/messages/loader.php

    diff --git src/bp-templates/bp-nouveau/includes/messages/loader.php src/bp-templates/bp-nouveau/includes/messages/loader.php
    index 10cdb84b0..a7dad9f05 100644
     
    33 * BP Nouveau Messages
    44 *
    55 * @since 3.0.0
    6  * @version 3.0.0
     6 * @version 10.0.0
    77 */
    88
    99// Exit if accessed directly.
    class BP_Nouveau_Messages { 
    8888         * @since 3.0.0
    8989         */
    9090        protected function setup_filters() {
    91                 // Enqueue specific styles
     91                // Enqueue specific styles.
    9292                add_filter( 'bp_nouveau_enqueue_styles', 'bp_nouveau_messages_enqueue_styles', 10, 1 );
    9393
    94                 // Register messages scripts
     94                // Register messages scripts.
    9595                add_filter( 'bp_nouveau_register_scripts', 'bp_nouveau_messages_register_scripts', 10, 1 );
    9696
    97                 // Localize Scripts
     97                // Localize Scripts.
    9898                add_filter( 'bp_core_get_js_strings', 'bp_nouveau_messages_localize_scripts', 10, 1 );
    9999
    100                 // Notices
    101                 add_filter( 'bp_messages_single_new_message_notification', 'bp_nouveau_format_notice_notification_for_user', 10, 1 );
    102                 add_filter( 'bp_notifications_get_all_notifications_for_user', 'bp_nouveau_add_notice_notification_for_user', 10, 2 );
     100                // Notices.
     101                add_filter( 'bp_core_get_notifications_for_user', 'bp_nouveau_add_notice_notification_for_user', 10, 2 );
    103102
    104                 // Messages
     103                // Messages.
    105104                add_filter( 'bp_messages_admin_nav', 'bp_nouveau_messages_adjust_admin_nav', 10, 1 );
    106105        }
    107106}