Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/11/2018 06:46:30 PM (8 years 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-activity/bp-activity-notifications.php

    r11764 r12087  
    340340}
    341341add_action( 'bp_blogs_comment_sync_activity_comment', 'bp_activity_add_notification_for_synced_blog_comment', 10, 4 );
     342
     343/**
     344 * Add activity notifications settings to the notifications settings page.
     345 *
     346 * @since 1.2.0
     347 */
     348function bp_activity_screen_notification_settings() {
     349        if ( bp_activity_do_mentions() ) {
     350                if ( ! $mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) ) {
     351                        $mention = 'yes';
     352                }
     353        }
     354
     355        if ( ! $reply = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_reply', true ) ) {
     356                $reply = 'yes';
     357        }
     358
     359        ?>
     360
     361        <table class="notification-settings" id="activity-notification-settings">
     362                <thead>
     363                        <tr>
     364                                <th class="icon">&nbsp;</th>
     365                                <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
     366                                <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
     367                                <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     368                        </tr>
     369                </thead>
     370
     371                <tbody>
     372                        <?php if ( bp_activity_do_mentions() ) : ?>
     373                                <tr id="activity-notification-settings-mentions">
     374                                        <td>&nbsp;</td>
     375                                        <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) ) ?></td>
     376                                        <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-yes" value="yes" <?php checked( $mention, 'yes', true ) ?>/><label for="notification-activity-new-mention-yes" class="bp-screen-reader-text"><?php
     377                                                /* translators: accessibility text */
     378                                                _e( 'Yes, send email', 'buddypress' );
     379                                        ?></label></td>
     380                                        <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-no" value="no" <?php checked( $mention, 'no', true ) ?>/><label for="notification-activity-new-mention-no" class="bp-screen-reader-text"><?php
     381                                                /* translators: accessibility text */
     382                                                _e( 'No, do not send email', 'buddypress' );
     383                                        ?></label></td>
     384                                </tr>
     385                        <?php endif; ?>
     386
     387                        <tr id="activity-notification-settings-replies">
     388                                <td>&nbsp;</td>
     389                                <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td>
     390                                <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-yes" value="yes" <?php checked( $reply, 'yes', true ) ?>/><label for="notification-activity-new-reply-yes" class="bp-screen-reader-text"><?php
     391                                        /* translators: accessibility text */
     392                                        _e( 'Yes, send email', 'buddypress' );
     393                                ?></label></td>
     394                                <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-no" value="no" <?php checked( $reply, 'no', true ) ?>/><label for="notification-activity-new-reply-no" class="bp-screen-reader-text"><?php
     395                                        /* translators: accessibility text */
     396                                        _e( 'No, do not send email', 'buddypress' );
     397                                ?></label></td>
     398                        </tr>
     399
     400                        <?php
     401
     402                        /**
     403                         * Fires inside the closing </tbody> tag for activity screen notification settings.
     404                         *
     405                         * @since 1.2.0
     406                         */
     407                        do_action( 'bp_activity_screen_notification_settings' ) ?>
     408                </tbody>
     409        </table>
     410
     411<?php
     412}
     413add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
Note: See TracChangeset for help on using the changeset viewer.