diff --git src/bp-core/admin/bp-core-admin-settings.php src/bp-core/admin/bp-core-admin-settings.php
index b36d9140f..0ef81a514 100644
|
|
function bp_admin_sanitize_callback_blogforum_comments( $value = false ) { |
201 | 201 | return $value ? 0 : 1; |
202 | 202 | } |
203 | 203 | |
| 204 | /** Notification Section *******************************************************************/ |
| 205 | |
| 206 | /** |
| 207 | * Notification settings section description for the settings page. |
| 208 | * |
| 209 | * @since 12.0.0 |
| 210 | */ |
| 211 | function bp_admin_setting_callback_notifications_section() { } |
| 212 | |
| 213 | /** |
| 214 | * Allow Private Message Notification |
| 215 | * |
| 216 | * @since 12.0.0 |
| 217 | */ |
| 218 | function bp_admin_setting_callback_private_message_notifications() { |
| 219 | ?> |
| 220 | |
| 221 | <input id="bp-enable-pm-notifications" name="bp-enable-pm-notifications" type="checkbox" value="1" <?php checked( bp_is_private_message_notification_active( true ) ); ?> /> |
| 222 | <label for="bp-enable-pm-notifications"><?php _e( 'Allow notifications for new incoming private messages', 'buddypress' ); ?></label> |
| 223 | |
| 224 | <?php |
| 225 | } |
| 226 | |
204 | 227 | /** Members *******************************************************************/ |
205 | 228 | |
206 | 229 | /** |
diff --git src/bp-core/bp-core-options.php src/bp-core/bp-core-options.php
index c0ec714dd..491c8b40a 100644
|
|
function bp_is_activity_heartbeat_active( $default = true ) { |
696 | 696 | return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $default ) ); |
697 | 697 | } |
698 | 698 | |
| 699 | /** |
| 700 | * Check whether Private Message Notifications are enabled. |
| 701 | * |
| 702 | * @since 12.0.0 |
| 703 | * |
| 704 | * @param bool $default Optional. Fallback value if not found in the database. |
| 705 | * Default: true. |
| 706 | * @return bool True if Private Message Notifications are enabled, otherwise false. |
| 707 | */ |
| 708 | function bp_is_private_message_notification_active( $default = true ) { |
| 709 | |
| 710 | /** |
| 711 | * Filters whether or not Private Message Notificatios are enabled. |
| 712 | * |
| 713 | * @since 12.0.0 |
| 714 | * |
| 715 | * @param bool $value Whether or not Private Message Notificatios are enabled. |
| 716 | */ |
| 717 | return (bool) apply_filters( 'bp_is_private_message_notifications_active', (bool) bp_get_option( 'bp-enable-pm-notifications', $default ) ); |
| 718 | } |
| 719 | |
699 | 720 | /** |
700 | 721 | * Get the current theme package ID. |
701 | 722 | * |
diff --git src/bp-core/classes/class-bp-admin.php src/bp-core/classes/class-bp-admin.php
index 54dc41037..f59459a96 100644
|
|
class BP_Admin { |
568 | 568 | register_setting( 'buddypress', '_bp_enable_akismet', 'intval' ); |
569 | 569 | } |
570 | 570 | } |
| 571 | |
| 572 | /* Notification Section **************************************************/ |
| 573 | |
| 574 | if ( bp_is_active( 'notifications' ) ) { |
| 575 | |
| 576 | // Add the main section. |
| 577 | add_settings_section( 'bp_notifications', __( 'Notifications Settings', 'buddypress' ), 'bp_admin_setting_callback_notifications_section', 'buddypress' ); |
| 578 | |
| 579 | // Enable Private Message Notification |
| 580 | add_settings_field( 'bp-enable-pm-notifications', __( 'Private Message', 'buddypress' ), 'bp_admin_setting_callback_private_message_notifications', 'buddypress', 'bp_notifications' ); |
| 581 | register_setting( 'buddypress', 'bp-enable-pm-notifications', 'intval' ); |
| 582 | } |
571 | 583 | } |
572 | 584 | |
573 | 585 | /** |
diff --git src/bp-messages/bp-messages-notifications.php src/bp-messages/bp-messages-notifications.php
index f3cf891c6..134619f99 100644
|
|
function messages_format_notifications( $action, $item_id, $secondary_item_id, $ |
194 | 194 | * @param BP_Messages_Message $message Message object. |
195 | 195 | */ |
196 | 196 | function bp_messages_message_sent_add_notification( $message ) { |
| 197 | |
| 198 | /** |
| 199 | * Enable/Disables Notification for New Private Messages |
| 200 | * |
| 201 | * @since 12.0.0 |
| 202 | * |
| 203 | */ |
| 204 | if( ! bp_is_private_message_notification_active() ) { |
| 205 | return; |
| 206 | } |
| 207 | |
197 | 208 | if ( ! empty( $message->recipients ) ) { |
198 | 209 | foreach ( (array) $message->recipients as $recipient ) { |
199 | 210 | bp_notifications_add_notification( array( |