Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/29/2021 01:28:50 PM (5 years ago)
Author:
imath
Message:

BP Email: introduce "unnamed" salutation

The member invites feature's goal is to invite external users to join a community. The BP Email feature uses a named salutation by default. As a result, the salutation of invitation emails was "Hi email@…,". The user's name is not yet known and using this kind of salutation is odd. The member invites feature's need is to simply use an "unnamed" salutation eg: "Hi,". To satisfy it we are updating the BP Email type schema with a new property $named_salutation which defaults to true. If this property is false, then the sent email will from now on use an unnamed salutation.

NB: to prevent potential back compatibiliy issues, each kind of salutation has their own filters

  • Use bp_email_get_unnamed_salutation to edit the unnamed one.
  • Use bp_email_get_salutation to edit the default one (named).

Props dcavins for coloring outside the lines a bit 😉

See #8139

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-template.php

    r12919 r12932  
    38013801         *
    38023802         * @since 2.5.0
     3803         * @since 8.0.0 Checks current BP Email type schema to eventually use the unnamed salutation.
    38033804         *
    38043805         * @param array $settings Email Settings.
    … …  
    38063807         */
    38073808        function bp_email_get_salutation( $settings = array() ) {
    3808                 $token = '{{recipient.name}}';
    3809 
    3810                 /**
    3811                  * Filters The Recipient Salutation inside the Email Template.
    3812                  *
    3813                  * @since 2.5.0
    3814                  *
    3815                  * @param string $value    The Recipient Salutation.
    3816                  * @param array  $settings Email Settings.
    3817                  * @param string $token    The Recipient token.
    3818                  */
    3819                 return apply_filters(
    3820                         'bp_email_get_salutation',
    3821                         sprintf(
    3822                                 /* translators: %s: the email token for the recipient name */
    3823                                 _x( 'Hi %s,', 'recipient salutation', 'buddypress' ),
     3809                $email_type = bp_email_get_type();
     3810                $saluation  = '';
     3811
     3812                if ( $email_type ) {
     3813                        $types_schema = bp_email_get_type_schema( 'named_salutation' );
     3814
     3815                        if ( isset( $types_schema[ $email_type ] ) && false === $types_schema[ $email_type ] ) {
     3816                                /**
     3817                                 * Filters The Recipient Unnamed Salutation inside the Email Template.
     3818                                 *
     3819                                 * @since 8.0.0
     3820                                 *
     3821                                 * @param string $value    The Recipient Salutation.
     3822                                 * @param array  $settings Email Settings.
     3823                                 */
     3824                                $saluation = apply_filters(
     3825                                        'bp_email_get_unnamed_salutation',
     3826                                        _x( 'Hi,', 'Unnamed recipient salutation', 'buddypress' ),
     3827                                        $settings
     3828                                );
     3829                        }
     3830                }
     3831
     3832                // Named salutations are default.
     3833                if ( ! $saluation ) {
     3834                        $token = '{{recipient.name}}';
     3835
     3836                        /**
     3837                         * Filters The Recipient Named Salutation inside the Email Template.
     3838                         *
     3839                         * @since 2.5.0
     3840                         *
     3841                         * @param string $value    The Recipient Salutation.
     3842                         * @param array  $settings Email Settings.
     3843                         * @param string $token    The Recipient token.
     3844                         */
     3845                        $saluation = apply_filters(
     3846                                'bp_email_get_salutation',
     3847                                sprintf(
     3848                                        /* translators: %s: the email token for the recipient name */
     3849                                        _x( 'Hi %s,', 'Named recipient salutation', 'buddypress' ),
     3850                                        $token
     3851                                ),
     3852                                $settings,
    38243853                                $token
    3825                         ),
    3826                         $settings,
    3827                         $token
    3828                 );
    3829         }
     3854                        );
     3855                }
     3856
     3857                return $saluation;
     3858        }
Note: See TracChangeset for help on using the changeset viewer.