Skip to:
Content

BuddyPress.org

Changeset 12087


Ignore:
Timestamp:
05/11/2018 06:46:30 PM (17 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.

Location:
trunk/src
Files:
4 deleted
8 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 );
  • trunk/src/bp-activity/classes/class-bp-activity-component.php

    r11958 r12087  
    137137            // Theme compatibility.
    138138            new BP_Activity_Theme_Compat();
    139         }
    140 
    141         // Activity notifications HTML table.
    142         if ( bp_is_user_settings_notifications() ) {
    143             require $this->path . 'bp-activity/screens/settings-email.php';
    144139        }
    145140    }
  • 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' );
  • trunk/src/bp-friends/classes/class-bp-friends-component.php

    r11932 r12087  
    9292                require $this->path . 'bp-friends/screens/requests.php';
    9393            }
    94         }
    95 
    96         // Settings.
    97         if ( bp_is_user_settings_notifications() ) {
    98             require $this->path . 'bp-friends/screens/settings-email.php';
    9994        }
    10095    }
  • trunk/src/bp-groups/bp-groups-notifications.php

    r11606 r12087  
    10531053}
    10541054add_action( 'groups_remove_data_for_user', 'bp_groups_remove_data_for_user_notifications', 10 );
     1055
     1056/**
     1057 * Render the group settings fields on the Notification Settings page.
     1058 *
     1059 * @since 1.0.0
     1060 */
     1061function groups_screen_notification_settings() {
     1062
     1063    if ( !$group_invite = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_invite', true ) )
     1064        $group_invite  = 'yes';
     1065
     1066    if ( !$group_update = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_group_updated', true ) )
     1067        $group_update  = 'yes';
     1068
     1069    if ( !$group_promo = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_admin_promotion', true ) )
     1070        $group_promo   = 'yes';
     1071
     1072    if ( !$group_request = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_membership_request', true ) )
     1073        $group_request = 'yes';
     1074
     1075    if ( ! $group_request_completed = bp_get_user_meta( bp_displayed_user_id(), 'notification_membership_request_completed', true ) ) {
     1076        $group_request_completed = 'yes';
     1077    }
     1078    ?>
     1079
     1080    <table class="notification-settings" id="groups-notification-settings">
     1081        <thead>
     1082            <tr>
     1083                <th class="icon"></th>
     1084                <th class="title"><?php _ex( 'Groups', 'Group settings on notification settings page', 'buddypress' ) ?></th>
     1085                <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
     1086                <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     1087            </tr>
     1088        </thead>
     1089
     1090        <tbody>
     1091            <tr id="groups-notification-settings-invitation">
     1092                <td></td>
     1093                <td><?php _ex( 'A member invites you to join a group', 'group settings on notification settings page','buddypress' ) ?></td>
     1094                <td class="yes"><input type="radio" name="notifications[notification_groups_invite]" id="notification-groups-invite-yes" value="yes" <?php checked( $group_invite, 'yes', true ) ?>/><label for="notification-groups-invite-yes" class="bp-screen-reader-text"><?php
     1095                    /* translators: accessibility text */
     1096                    _e( 'Yes, send email', 'buddypress' );
     1097                ?></label></td>
     1098                <td class="no"><input type="radio" name="notifications[notification_groups_invite]" id="notification-groups-invite-no" value="no" <?php checked( $group_invite, 'no', true ) ?>/><label for="notification-groups-invite-no" class="bp-screen-reader-text"><?php
     1099                    /* translators: accessibility text */
     1100                    _e( 'No, do not send email', 'buddypress' );
     1101                ?></label></td>
     1102            </tr>
     1103            <tr id="groups-notification-settings-info-updated">
     1104                <td></td>
     1105                <td><?php _ex( 'Group information is updated', 'group settings on notification settings page', 'buddypress' ) ?></td>
     1106                <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" id="notification-groups-group-updated-yes" value="yes" <?php checked( $group_update, 'yes', true ) ?>/><label for="notification-groups-group-updated-yes" class="bp-screen-reader-text"><?php
     1107                    /* translators: accessibility text */
     1108                    _e( 'Yes, send email', 'buddypress' );
     1109                ?></label></td>
     1110                <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" id="notification-groups-group-updated-no" value="no" <?php checked( $group_update, 'no', true ) ?>/><label for="notification-groups-group-updated-no" class="bp-screen-reader-text"><?php
     1111                    /* translators: accessibility text */
     1112                    _e( 'No, do not send email', 'buddypress' );
     1113                ?></label></td>
     1114            </tr>
     1115            <tr id="groups-notification-settings-promoted">
     1116                <td></td>
     1117                <td><?php _ex( 'You are promoted to a group administrator or moderator', 'group settings on notification settings page', 'buddypress' ) ?></td>
     1118                <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" id="notification-groups-admin-promotion-yes" value="yes" <?php checked( $group_promo, 'yes', true ) ?>/><label for="notification-groups-admin-promotion-yes" class="bp-screen-reader-text"><?php
     1119                    /* translators: accessibility text */
     1120                    _e( 'Yes, send email', 'buddypress' );
     1121                ?></label></td>
     1122                <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" id="notification-groups-admin-promotion-no" value="no" <?php checked( $group_promo, 'no', true ) ?>/><label for="notification-groups-admin-promotion-no" class="bp-screen-reader-text"><?php
     1123                    /* translators: accessibility text */
     1124                    _e( 'No, do not send email', 'buddypress' );
     1125                ?></label></td>
     1126            </tr>
     1127            <tr id="groups-notification-settings-request">
     1128                <td></td>
     1129                <td><?php _ex( 'A member requests to join a private group for which you are an admin', 'group settings on notification settings page', 'buddypress' ) ?></td>
     1130                <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" id="notification-groups-membership-request-yes" value="yes" <?php checked( $group_request, 'yes', true ) ?>/><label for="notification-groups-membership-request-yes" class="bp-screen-reader-text"><?php
     1131                    /* translators: accessibility text */
     1132                    _e( 'Yes, send email', 'buddypress' );
     1133                ?></label></td>
     1134                <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" id="notification-groups-membership-request-no" value="no" <?php checked( $group_request, 'no', true ) ?>/><label for="notification-groups-membership-request-no" class="bp-screen-reader-text"><?php
     1135                    /* translators: accessibility text */
     1136                    _e( 'No, do not send email', 'buddypress' );
     1137                ?></label></td>
     1138            </tr>
     1139            <tr id="groups-notification-settings-request-completed">
     1140                <td></td>
     1141                <td><?php _ex( 'Your request to join a group has been approved or denied', 'group settings on notification settings page', 'buddypress' ) ?></td>
     1142                <td class="yes"><input type="radio" name="notifications[notification_membership_request_completed]" id="notification-groups-membership-request-completed-yes" value="yes" <?php checked( $group_request_completed, 'yes', true ) ?>/><label for="notification-groups-membership-request-completed-yes" class="bp-screen-reader-text"><?php
     1143                    /* translators: accessibility text */
     1144                    _e( 'Yes, send email', 'buddypress' );
     1145                ?></label></td>
     1146                <td class="no"><input type="radio" name="notifications[notification_membership_request_completed]" id="notification-groups-membership-request-completed-no" value="no" <?php checked( $group_request_completed, 'no', true ) ?>/><label for="notification-groups-membership-request-completed-no" class="bp-screen-reader-text"><?php
     1147                    /* translators: accessibility text */
     1148                    _e( 'No, do not send email', 'buddypress' );
     1149                ?></label></td>
     1150            </tr>
     1151
     1152            <?php
     1153
     1154            /**
     1155             * Fires at the end of the available group settings fields on Notification Settings page.
     1156             *
     1157             * @since 1.0.0
     1158             */
     1159            do_action( 'groups_screen_notification_settings' ); ?>
     1160
     1161        </tbody>
     1162    </table>
     1163
     1164<?php
     1165}
     1166add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
  • trunk/src/bp-groups/classes/class-bp-groups-component.php

    r11924 r12087  
    210210            // Theme compatibility.
    211211            new BP_Groups_Theme_Compat();
    212         }
    213 
    214         // Groups notifications HTML table.
    215         if ( bp_is_user_settings_notifications() ) {
    216             require $this->path . 'bp-groups/screens/user/settings-email.php';
    217212        }
    218213    }
  • trunk/src/bp-messages/bp-messages-notifications.php

    r11800 r12087  
    240240}
    241241add_action( 'bp_messages_thread_after_delete', 'bp_messages_message_delete_notifications', 10, 2 );
     242
     243/**
     244 * Render the markup for the Messages section of Settings > Notifications.
     245 *
     246 * @since 1.0.0
     247 */
     248function messages_screen_notification_settings() {
     249
     250    if ( bp_action_variables() ) {
     251        bp_do_404();
     252        return;
     253    }
     254
     255    if ( !$new_messages = bp_get_user_meta( bp_displayed_user_id(), 'notification_messages_new_message', true ) ) {
     256        $new_messages = 'yes';
     257    } ?>
     258
     259    <table class="notification-settings" id="messages-notification-settings">
     260        <thead>
     261            <tr>
     262                <th class="icon"></th>
     263                <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th>
     264                <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
     265                <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     266            </tr>
     267        </thead>
     268
     269        <tbody>
     270            <tr id="messages-notification-settings-new-message">
     271                <td></td>
     272                <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td>
     273                <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" id="notification-messages-new-messages-yes" value="yes" <?php checked( $new_messages, 'yes', true ) ?>/><label for="notification-messages-new-messages-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_messages_new_message]" id="notification-messages-new-messages-no" value="no" <?php checked( $new_messages, 'no', true ) ?>/><label for="notification-messages-new-messages-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 inside the closing </tbody> tag for messages screen notification settings.
     287             *
     288             * @since 1.0.0
     289             */
     290            do_action( 'messages_screen_notification_settings' ); ?>
     291        </tbody>
     292    </table>
     293
     294<?php
     295}
     296add_action( 'bp_notification_settings', 'messages_screen_notification_settings', 2 );
  • trunk/src/bp-messages/classes/class-bp-messages-component.php

    r11925 r12087  
    138138                }
    139139            }
    140         }
    141 
    142         // Groups notifications HTML table.
    143         if ( bp_is_user_settings_notifications() ) {
    144             require $this->path . 'bp-messages/screens/settings-email.php';
    145140        }
    146141    }
Note: See TracChangeset for help on using the changeset viewer.