Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/11/2018 06:46:30 PM (18 months ago)
Author:
boonebgorges
Message:

Move notification settings callbacks out of lazyloaded screen function files.

Loading these add_action() callbacks conditionally caused the
has_action() check in bp_settings_remove_email_subnav() to think
that no components had registered notification settings.

Props r-a-y.
Fixes #7822.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/bp-friends-notifications.php

    r11022 r12087  
    231231}
    232232add_action( 'friends_remove_data', 'bp_friends_remove_notifications_data', 10, 1 );
     233
     234/**
     235 * Add Friends-related settings to the Settings > Notifications page.
     236 *
     237 * @since 1.0.0
     238 */
     239function friends_screen_notification_settings() {
     240
     241    if ( !$send_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_request', true ) )
     242        $send_requests   = 'yes';
     243
     244    if ( !$accept_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_accepted', true ) )
     245        $accept_requests = 'yes'; ?>
     246
     247    <table class="notification-settings" id="friends-notification-settings">
     248        <thead>
     249            <tr>
     250                <th class="icon"></th>
     251                <th class="title"><?php _ex( 'Friends', 'Friend settings on notification settings page', 'buddypress' ) ?></th>
     252                <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
     253                <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     254            </tr>
     255        </thead>
     256
     257        <tbody>
     258            <tr id="friends-notification-settings-request">
     259                <td></td>
     260                <td><?php _ex( 'A member sends you a friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td>
     261                <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" id="notification-friends-friendship-request-yes" value="yes" <?php checked( $send_requests, 'yes', true ) ?>/><label for="notification-friends-friendship-request-yes" class="bp-screen-reader-text"><?php
     262                    /* translators: accessibility text */
     263                    _e( 'Yes, send email', 'buddypress' );
     264                ?></label></td>
     265                <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" id="notification-friends-friendship-request-no" value="no" <?php checked( $send_requests, 'no', true ) ?>/><label for="notification-friends-friendship-request-no" class="bp-screen-reader-text"><?php
     266                    /* translators: accessibility text */
     267                    _e( 'No, do not send email', 'buddypress' );
     268                ?></label></td>
     269            </tr>
     270            <tr id="friends-notification-settings-accepted">
     271                <td></td>
     272                <td><?php _ex( 'A member accepts your friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td>
     273                <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" id="notification-friends-friendship-accepted-yes" value="yes" <?php checked( $accept_requests, 'yes', true ) ?>/><label for="notification-friends-friendship-accepted-yes" class="bp-screen-reader-text"><?php
     274                    /* translators: accessibility text */
     275                    _e( 'Yes, send email', 'buddypress' );
     276                ?></label></td>
     277                <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" id="notification-friends-friendship-accepted-no" value="no" <?php checked( $accept_requests, 'no', true ) ?>/><label for="notification-friends-friendship-accepted-no" class="bp-screen-reader-text"><?php
     278                    /* translators: accessibility text */
     279                    _e( 'No, do not send email', 'buddypress' );
     280                ?></label></td>
     281            </tr>
     282
     283            <?php
     284
     285            /**
     286             * Fires after the last table row on the friends notification screen.
     287             *
     288             * @since 1.0.0
     289             */
     290            do_action( 'friends_screen_notification_settings' ); ?>
     291
     292        </tbody>
     293    </table>
     294
     295<?php
     296}
     297add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
Note: See TracChangeset for help on using the changeset viewer.