Skip to:
Content

BuddyPress.org

Ticket #8997: 8997.patch

File 8997.patch, 8.3 KB (added by plugindevs, 12 months ago)
  • src/bp-core/admin/bp-core-admin-settings.php

    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 ) { 
    201201        return $value ? 0 : 1;
    202202}
    203203
     204/** Notification Section *******************************************************************/
     205
     206/**
     207 * Notification settings section description for the settings page.
     208 *
     209 * @since 12.0.0
     210 */
     211function bp_admin_setting_callback_notifications_section() { }
     212
     213/**
     214 * Allow Private Message Notification
     215 *
     216 * @since 12.0.0
     217 */
     218function 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
    204227/** Members *******************************************************************/
    205228
    206229/**
  • src/bp-core/bp-core-options.php

    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 ) { 
    696696        return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $default ) );
    697697}
    698698
     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 */
     708function 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
    699720/**
    700721 * Get the current theme package ID.
    701722 *
  • src/bp-core/classes/class-bp-admin.php

    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 { 
    568568                                register_setting( 'buddypress', '_bp_enable_akismet', 'intval' );
    569569                        }
    570570                }
     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                }
    571583        }
    572584
    573585        /**
  • src/bp-messages/bp-messages-notifications.php

    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, $ 
    194194 * @param BP_Messages_Message $message Message object.
    195195 */
    196196function 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
    197208        if ( ! empty( $message->recipients ) ) {
    198209                foreach ( (array) $message->recipients as $recipient ) {
    199210                        bp_notifications_add_notification( array(