Plugin Directory

Changeset 3350070


Ignore:
Timestamp:
08/26/2025 06:17:20 AM (7 months ago)
Author:
voltronik
Message:

v1.9.9

Location:
bnfw
Files:
53 added
5 edited

Legend:

Unmodified
Added
Removed
  • bnfw/trunk/README.txt

    r3240554 r3350070  
    44Tags: notification, email, alert, message, notify
    55Requires at least: 4.8
    6 Tested up to: 6.6
     6Tested up to: 6.8
    77Requires PHP: 7.4
    8 Stable tag: "1.9.8"
     8Stable tag: "1.9.9"
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    250250== Changelog ==
    251251
     252= 1.9.9 - 26th August 2025 =
     253* Fixed: The `[email_change_confirmation_link]` shortcode link now respects being overridden correctly.
     254* Fixed: Escaping in various shortcodes.
     255* Fixed: Issue where non-English dates added via shortcodes still showed in English.
     256* Fixed: Issue where a category or taxonomy term associated with a notification had been deleted.
     257* Added: Support for the upcoming Multi-language Add-on.
     258
    252259= 1.9.8 - 5th November 2024 =
    253260* Added: Support for the new 'Send Notification Only Once' feature in the [Digest add-on](https://betternotificationsforwp.com/downloads/digest/).
  • bnfw/trunk/bnfw.php

    r3240554 r3350070  
    44 * Plugin URI: https://wordpress.org/plugins/bnfw/
    55 * Description: Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Add more power with Add-ons.
    6  * Version: 1.9.8
     6 * Version: 1.9.9
    77 * Requires at least: 4.8
    88 * Requires PHP: 7.4
     
    4141         * @var string
    4242         */
    43         public $bnfw_version = '1.9.8';
     43        public $bnfw_version = '1.9.9';
    4444        /**
    4545         * Class Constructor.
     
    269269                    $args['subject'] = $subject;
    270270                }
     271
     272                /**
     273                 * Filters the subject of the email sent when a change of user email address is attempted.
     274                 *
     275                 * @param array $args An array of email TO, Subject, Message and Header.
     276                 * @param array $setting Notification settings.
     277                 *
     278                 * @since 1.9.9
     279                 */
     280                $args = apply_filters( 'bnfw_user_on_email_change_request_subject', $args, $setting );
    271281            }
    272282
     
    733743         * @since 1.1
    734744         *
    735          * @param string $title Email subject.
    736          * @param string $user_login The username for the user.
    737          * @param string $user_data WP_User object.
     745         * @param string  $title Email subject.
     746         * @param string  $user_login The username for the user.
     747         * @param WP_User $user_data WP_User object.
    738748         *
    739749         * @return string
     
    745755                // If there are multiple notification then we will read data about only the last one.
    746756                $setting = $this->notifier->read_settings( end( $notifications )->ID );
    747 
    748                 if ( '' === $user_data ) {
    749                     return $this->engine->handle_shortcodes( $setting['subject'], 'user-password', $user_data->ID );
    750                 } else {
    751                     return $this->engine->handle_shortcodes( $setting['subject'], 'user-password', $user_data->ID );
    752                 }
     757                $user_id = ! empty( $user_data->ID ) ? $user_data->ID : 0;
     758
     759                $title = $this->engine->handle_shortcodes( $setting['subject'], 'user-password', $user_id );
     760
     761                /**
     762                 * Filters the subject of the password reset email.
     763                 *
     764                 * @since 1.9.9
     765                 *
     766                 * @param string  $title      Email subject.
     767                 * @param array   $setting    Notification settings.
     768                 * @param string  $user_login The username for the user.
     769                 * @param WP_User $user_data  WP_User object.
     770                 */
     771                $title = apply_filters( 'bnfw_user_retrieve_password_title', $title, $setting, $user_login, $user_data );
    753772            }
    754773
     
    761780         * @since 1.1
    762781         *
    763          * @param string $message Email message.
    764          * @param string $key The activation key.
    765          * @param string $user_login The username for the user.
    766          * @param string $user_data WP_User object.
     782         * @param string  $message Email message.
     783         * @param string  $key The activation key.
     784         * @param string  $user_login The username for the user.
     785         * @param WP_User $user_data WP_User object.
    767786         *
    768787         * @return string
     
    774793                // If there are multiple notification then we will read data about only the last one.
    775794                $setting = $this->notifier->read_settings( end( $notifications )->ID );
     795
     796                /**
     797                 * Filters the override the notification settings.
     798                 *
     799                 * @param array   $setting    Notification settings.
     800                 * @param WP_User $user_data  WP_User object.
     801                 *
     802                 * @since 1.9.9
     803                 */
     804                $setting = apply_filters( 'bnfw_change_password_email_message_notification_settings', $setting, $user_data );
    776805
    777806                $message = $this->engine->handle_password_reset_shortcodes( $setting, $key, $user_login, $user_data );
     
    912941            return $email_data;
    913942        }
     943
    914944        /**
    915945         * Filters the text of the email sent when a change of user email address is attempted.
     
    934964                // If there are multiple notification then we will read data about only the last one.
    935965                $setting = $this->notifier->read_settings( end( $notifications )->ID );
     966
     967                /**
     968                 * Filters the override notification settings.
     969                 *
     970                 * @param array $setting Notification settings.
     971                 * @param WP_User $user Current WP_User instance.
     972                 * @param array $new_user_details {
     973                 *      Data relating to the new user email address.
     974                 *
     975                 *      @type string $hash The secure hash used in the confirmation link URL.
     976                 *      @type string $newemail The proposed new email address.
     977                 *  }
     978                 *
     979                 * @since 1.9.9
     980                 */
     981                $setting = apply_filters( 'bnfw_user_on_email_changing_notification_settings', $setting, $user, $new_user_details );
    936982
    937983                // Ensures the content type of the message.
     
    944990                $email_text = $this->engine->handle_shortcodes( $setting['message'], $setting['notification'], $new_user_details['newemail'] );
    945991                $email_text = $this->engine->handle_global_user_shortcodes( $email_text, $new_user_details['newemail'] );
    946                 $email_text = str_replace( '[email_change_confirmation_link]', esc_url( admin_url( 'profile.php?newuseremail=' . $new_user_details['hash'] ) ), $email_text );
     992                $email_text = str_replace( '[email_change_confirmation_link]', esc_url( self_admin_url( 'profile.php?newuseremail=' . $new_user_details['hash'] ) ), $email_text );
    947993                $email_text = str_replace( '[user_nicename]', $user->data->user_nicename, $email_text );
    948994                $email_text = str_replace( '[user_id]', $user->data->ID, $email_text );
     
    10341080                $setting = $this->notifier->read_settings( end( $notifications )->ID );
    10351081
     1082                /**
     1083                 * Filters the override the notification settings.
     1084                 *
     1085                 * @param array $setting Notification settings.
     1086                 * @param array $email_data Email Data.
     1087                 * @param string|int $extra_data Extra data like ID of user.
     1088                 *
     1089                 * @since 1.9.9
     1090                 */
     1091                $setting = apply_filters( 'bnfw_handle_filtered_data_notification_settings', $setting, $email_data, $extra_data );
     1092
    10361093                // Ensures the content type of the message.
    10371094                if ( 'html' === $setting['email-formatting'] ) {
     
    11531210                     *
    11541211                     * @since 1.6.5
     1212                     * @since 1.9.9 Added `$user_id` parameter.
    11551213                     */
    1156                     if ( apply_filters( 'bnfw_trigger_user-role_notification', true, $notification, $new_role, $old_roles ) ) {
     1214                    if ( apply_filters( 'bnfw_trigger_user-role_notification', true, $notification, $new_role, $old_roles, $user_id ) ) {
    11571215                        $this->engine->send_user_role_changed_email( $this->notifier->read_settings( $notification->ID ), $user_id, $old_roles[0], $new_role );
    11581216                    }
     
    11651223                     *
    11661224                     * @since 1.6.5
     1225                     * @since 1.9.9 Added `$user_id` parameter.
    11671226                     */
    1168                     if ( apply_filters( 'bnfw_trigger_admin-role_notification', true, $notification, $new_role, $old_roles ) ) {
     1227                    if ( apply_filters( 'bnfw_trigger_admin-role_notification', true, $notification, $new_role, $old_roles, $user_id ) ) {
    11691228                        $setting            = $this->notifier->read_settings( $notification->ID );
    11701229                        $setting['message'] = $this->engine->handle_user_role_shortcodes( $setting['message'], $old_roles[0], $new_role );
     
    11991258
    12001259            foreach ( $notifications as $notification ) {
    1201                 if ( apply_filters( 'bnfw_trigger_user-role_notification', true, $notification, $new_role, null ) ) {
     1260                if ( apply_filters( 'bnfw_trigger_user-role_notification', true, $notification, $new_role, null, $user_id ) ) {
    12021261                    $this->engine->send_user_role_changed_email( $this->notifier->read_settings( $notification->ID ), $user_id, null, $new_role );
    12031262                }
     
    12061265            $notifications_admin = $this->notifier->get_notifications( 'admin-role' );
    12071266            foreach ( $notifications_admin as $notification ) {
    1208                 if ( apply_filters( 'bnfw_trigger_admin-role_notification', true, $notification, $new_role, null ) ) {
     1267                if ( apply_filters( 'bnfw_trigger_admin-role_notification', true, $notification, $new_role, null, $user_id ) ) {
    12091268                    $setting            = $this->notifier->read_settings( $notification->ID );
    12101269                    $setting['message'] = $this->engine->handle_user_role_shortcodes( $setting['message'], null, $new_role );
     
    12381297
    12391298            foreach ( $notifications as $notification ) {
    1240                 if ( apply_filters( 'bnfw_trigger_user-role_notification', true, $notification, null, array( $old_role ) ) ) {
     1299                if ( apply_filters( 'bnfw_trigger_user-role_notification', true, $notification, null, array( $old_role ), $user_id ) ) {
    12411300                    $this->engine->send_user_role_changed_email( $this->notifier->read_settings( $notification->ID ), $user_id, $old_role, null );
    12421301                }
     
    12451304            $notifications_admin = $this->notifier->get_notifications( 'admin-role' );
    12461305            foreach ( $notifications_admin as $notification ) {
    1247                 if ( apply_filters( 'bnfw_trigger_admin-role_notification', true, $notification, null, array( $old_role ) ) ) {
     1306                if ( apply_filters( 'bnfw_trigger_admin-role_notification', true, $notification, null, array( $old_role ), $user_id ) ) {
    12481307                    $setting            = $this->notifier->read_settings( $notification->ID );
    12491308                    $setting['message'] = $this->engine->handle_user_role_shortcodes( $setting['message'], $old_role, null );
     
    12851344                         *
    12861345                         * @since 1.6.5
     1346                         * @since 1.9.9 Added `$user_id` parameter.
    12871347                         */
    1288                         if ( apply_filters( 'bnfw_trigger_user-role-added_notification', true, $notification, $new_roles, $old_roles ) ) {
     1348                        if ( apply_filters( 'bnfw_trigger_user-role-added_notification', true, $notification, $new_roles, $old_roles, $user_id ) ) {
    12891349                            $this->engine->send_user_role_added_email( $this->notifier->read_settings( $notification->ID ), $user_id, $old_roles, $new_roles );
    12901350                        }
     
    12981358                         *
    12991359                         * @since 1.6.5
     1360                         * @since 1.9.9 Added `$user_id` parameter.
    13001361                         */
    1301                         if ( apply_filters( 'bnfw_trigger_user-role-added_notification', true, $notification, $new_roles, $old_roles ) ) {
     1362                        if ( apply_filters( 'bnfw_trigger_admin-role-added_notification', true, $notification, $new_roles, $old_roles, $user_id ) ) {
    13021363                            $setting            = $this->notifier->read_settings( $notification->ID );
    13031364                            $setting['message'] = $this->engine->handle_user_added_role_shortcodes( $setting['message'], $old_roles, $new_roles );
     
    15001561                $setting = $this->notifier->read_settings( end( $notifications )->ID );
    15011562
     1563                /**
     1564                 * Filters the text of the email sent with a personal data export file.
     1565                 *
     1566                 * @param array $setting Setting of the notification.
     1567                 * @param array $email_data Data relating to the account action email.
     1568                 *
     1569                 * @since 1.9.9
     1570                 */
     1571                $setting = apply_filters( 'bnfw_handle_data_export_email_content_settings', $setting, $email_data );
     1572
    15021573                $new_content = $this->engine->handle_data_export_email_shortcodes( $setting[ $field ], $setting, $request_id );
    15031574                $new_content = $this->engine->handle_global_user_shortcodes( $new_content, $email_data['message_recipient'] );
     
    15471618                // Ideally there should be only one notification for this type.
    15481619                // If there are multiple notification then we will read data about only the last one.
    1549                 $setting     = $this->notifier->read_settings( end( $notifications )->ID );
     1620                $setting = $this->notifier->read_settings( end( $notifications )->ID );
     1621
     1622                /**
     1623                 * Filters the subject of the email sent when an erasure request is completed.
     1624                 *
     1625                 * @param array $setting Setting of the notification.
     1626                 * @param array $email_data Data relating to the account action email.
     1627                 *
     1628                 * @since 1.9.9
     1629                 */
     1630                $setting = apply_filters( 'bnfw_handle_erasure_complete_email_notification_settings', $setting, $email_data );
     1631
    15501632                $new_content = $this->engine->handle_shortcodes( $setting[ $field ], $notification_name, $email_data );
    15511633            }
     
    16231705                $setting = $this->notifier->read_settings( end( $notifications )->ID );
    16241706
     1707                /**
     1708                 * Filters the text of the email sent when an account action is attempted.
     1709                 *
     1710                 * @param array $setting Setting of the notification.
     1711                 * @param array $email_data Data relating to the account action email.
     1712                 *
     1713                 * @since 1.9.9
     1714                 */
     1715                $setting = apply_filters( 'bnfw_handle_user_request_notification_settings', $setting, $email_data );
     1716
    16251717                return $this->engine->handle_user_request_email_shortcodes( $setting[ $field ], $setting, $email_data );
    16261718            }
     
    16451737                $setting = $this->notifier->read_settings( end( $notifications )->ID );
    16461738
     1739                /**
     1740                 * Filters the body of the user request confirmation email.
     1741                 *
     1742                 * @param array $setting Setting of the notification.
     1743                 * @param array $email_data Data relating to the account action email.
     1744                 *
     1745                 * @since 1.9.9
     1746                 */
     1747                $setting = apply_filters( 'bnfw_handle_user_confirmed_action_notification_settings', $setting, $email_data );
     1748
    16471749                return $this->engine->handle_user_confirmed_action_email_shortcodes( $setting[ $field ], $setting, $email_data );
    16481750            }
  • bnfw/trunk/includes/admin/class-bnfw-notification.php

    r3182351 r3350070  
    710710            </table>
    711711            <?php
     712            /**
     713             * Fires after render all notification setting fields.
     714             *
     715             * @param array $setting Notification settings.
     716             *
     717             * @since 1.9.9
     718             */
     719            do_action( 'bnfw_after_setting_fields', $setting );
    712720        }
    713721
     
    10151023                    </div>
    10161024
    1017                     <br>
    1018                     <br>
     1025                    <?php
     1026                    /**
     1027                     * Fires after notification meta setting fields.
     1028                     *
     1029                     * @param array $setting Notification settings.
     1030                     *
     1031                     * @since 1.9.9
     1032                     */
     1033                    do_action( 'bnfw_after_notification_disabled_field', $setting );
     1034                    ?>
    10191035
    10201036                    <?php if ( 'publish' === $post->post_status ) { ?>
     
    11881204            $columns['excluded'] = esc_html__( 'Excluded User Roles / Users', 'bnfw' );
    11891205
    1190             return $columns;
     1206            /**
     1207             * Invoked while displaying a custom column in the notification table.
     1208             *
     1209             * @param array $column Array of column names.
     1210             *
     1211             * @since 1.9.9
     1212             */
     1213            return apply_filters( 'bnfw_notification_table_columns', $columns );
    11911214        }
    11921215
  • bnfw/trunk/includes/engine/class-bnfw-engine.php

    r3110258 r3350070  
    7474                }
    7575
    76 
    7776                $subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $id );
    7877                $message = $this->handle_shortcodes( $setting['message'], $setting['notification'], $id );
     
    104103                if ( isset( $emails['to'] ) && is_array( $emails['to'] ) ) {
    105104                    foreach ( $emails['to'] as $email ) {
    106                         wp_mail( $email, stripslashes( $this->handle_global_user_shortcodes( $subject, $email ) ), $this->handle_global_user_shortcodes( $message, $email ), $headers );
     105
     106                        $subject = wp_specialchars_decode( stripslashes( $this->handle_global_user_shortcodes( $subject, $email ) ) );
     107                        $message = $this->handle_global_user_shortcodes( $message, $email );
     108
     109                        /**
     110                         * Filter to apply before send notification to user.
     111                         *
     112                         * @param bool $is_send Boolean. Default true.
     113                         * @param int $id ID.
     114                         * @param string $email Email of user.
     115                         * @param array $setting Notification settings.
     116                         * @param string $subject Notification subject.
     117                         * @param string $message Notification content.
     118                         * @param string|string[] $headers Additional headers.
     119                         *
     120                         * @since 1.9.9
     121                         */
     122                        if ( apply_filters( 'bnfw_can_send_user_locale_email', true, $id, $email, $setting, $subject, $message, $headers ) ) {
     123                            wp_mail( $email, $subject, $message, $headers );
     124                        }
    107125                    }
    108126                }
     
    124142             *
    125143             * @since 1.7
     144             * @since 1.9.9 Added `$password_url` parameter.
    126145             */
    127             $trigger_notification = apply_filters( 'bnfw_trigger_welcome-email_notification', true, $setting, $user );
     146            $trigger_notification = apply_filters( 'bnfw_trigger_welcome-email_notification', true, $setting, $user, $password_url );
    128147
    129148            if ( ! $trigger_notification ) {
     
    165184            $subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
    166185            $message = $this->handle_global_user_shortcodes( $message, $user->user_email );
    167             wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
     186            wp_mail( $user->user_email, wp_specialchars_decode( stripslashes( $subject ) ), $message, $headers );
    168187        }
    169188
     
    205224            $message = $this->handle_global_user_shortcodes( $message, $user->user_email );
    206225
    207             wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
     226            wp_mail( $user->user_email, wp_specialchars_decode( stripslashes( $subject ) ), $message, $headers );
    208227        }
    209228
     
    246265            $notification_disabled = apply_filters( 'bnfw_notification_disabled', false, $comment_id, $setting );
    247266
    248             if ( ! $notification_disabled ) {
     267            /**
     268             * Filter to apply before send notification to user.
     269             *
     270             * @param bool $is_send Boolean. Default true.
     271             * @param int $comment_id Comment ID.
     272             * @param array $setting Notification settings.
     273             * @param object $parent_comment Parent comment object.
     274             *
     275             * @since 1.9.9
     276             */
     277            if ( ! $notification_disabled && apply_filters( 'bnfw_trigger_comments_reply_notification', true, $comment_id, $setting, $parent_comment ) ) {
    249278                $subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $comment_id );
    250279                $message = $this->handle_shortcodes( $setting['message'], $setting['notification'], $comment_id );
     
    262291                $subject = $this->handle_global_user_shortcodes( $subject, $parent_comment->comment_author_email );
    263292                $message = $this->handle_global_user_shortcodes( $message, $parent_comment->comment_author_email );
    264                 wp_mail( $parent_comment->comment_author_email, stripslashes( $subject ), $message, $headers );
     293                wp_mail( $parent_comment->comment_author_email, wp_specialchars_decode( stripslashes( $subject ) ), $message, $headers );
    265294            }
    266295        }
     
    298327            $subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
    299328            $message = $this->handle_global_user_shortcodes( $message, $user->user_email );
    300             wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
     329            wp_mail( $user->user_email, wp_specialchars_decode( stripslashes( $subject ) ), $message, $headers );
    301330        }
    302331
     
    335364            $subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
    336365            $message = $this->handle_global_user_shortcodes( $message, $user->user_email );
    337             wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
     366            wp_mail( $user->user_email, wp_specialchars_decode( stripslashes( $subject ) ), $message, $headers );
    338367        }
    339368
     
    444473         */
    445474        public function handle_core_updated_notification( $email_data, $setting, $type ) {
     475
     476            $emails  = $this->get_emails( $setting, $type );
     477            $headers = $this->get_headers( $emails );
     478
     479            /**
     480             * Filters the contents of the email sent when core updated.
     481             *
     482             * @param array $setting Notification settings.
     483             * @param array $email_data Used to build wp_mail().
     484             * @param array $emails Email addresses to send email.
     485             * @param string $type Result of update.
     486             *
     487             * @since 1.9.9
     488             */
     489            $setting = apply_filters( 'bnfw_handle_core_updated_notification', $setting, $email_data, $emails, $type );
     490
    446491            $email_data['body']    = $this->handle_shortcodes( $setting['message'], $setting['notification'], $type );
    447492            $email_data['subject'] = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $type );
    448 
    449             $emails  = $this->get_emails( $setting, $type );
    450             $headers = $this->get_headers( $emails );
    451493
    452494            $email_data['body']    = $this->handle_global_user_shortcodes( $email_data['body'], $emails['to'][0] );
     
    474516         * Handle shortcode for password reset email message.
    475517         *
    476          * @param string $setting Notification settings.
    477          * @param string $key The activation key.
    478          * @param string $user_login The username for the user.
     518         * @param array  $setting Notification settings.
     519         * @param string  $key The activation key.
     520         * @param string  $user_login The username for the user.
    479521         * @param WP_User $user_data WP_User object.
    480522         *
    481523         * @return mixed|string
    482524         * @since 1.1
    483          *
    484525         */
    485526        public function handle_password_reset_shortcodes( $setting, $key, $user_login, $user_data ) {
     
    506547        public function send_password_changed_email( $setting, $user ) {
    507548            $user_id = $user->ID;
     549
     550            /**
     551             * Filters the Send Password Changed email.
     552             *
     553             * @param array $setting Notification settings.
     554             * @param WP_User $user WP_User object.
     555             *
     556             * @since 1.9.9
     557             */
     558            $setting = apply_filters( 'bnfw_user_send_password_changed_email', $setting, $user );
    508559
    509560            $subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $user_id );
     
    523574            $subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
    524575            $message = $this->handle_global_user_shortcodes( $message, $user->user_email );
    525             wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
     576            wp_mail( $user->user_email, wp_specialchars_decode( stripslashes( $subject ) ), $message, $headers );
    526577        }
    527578
     
    844895            $message = str_replace( '[post_category]', implode( ', ', wp_list_pluck( $categories, 'name' ) ), $message );
    845896
    846             if ( count( $categories ) > 0 ) {
     897            if ( ! is_wp_error( $categories ) && count( $categories ) > 0 ) {
    847898                $message = str_replace(
    848899                    array(
  • bnfw/trunk/includes/helpers/helpers.php

    r3110258 r3350070  
    247247        $time_format = get_option( 'time_format' );
    248248
    249         return date( $date_format . ' ' . $time_format, strtotime( $date ) );
     249        return date_i18n( $date_format . ' ' . $time_format, strtotime( $date ) );
    250250    }
    251251}
Note: See TracChangeset for help on using the changeset viewer.