<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][12932] trunk/src/bp-core: BP Email: introduce "unnamed" salutation</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/12932">12932</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/12932","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-04-29 13:28:50 +0000 (Thu, 29 Apr 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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@domain.tld,". 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 {U+01F609}
See <a href="http://buddypress.trac.wordpress.org/ticket/8139">#8139</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcorebpcorefunctionsphp">trunk/src/bp-core/bp-core-functions.php</a></li>
<li><a href="#trunksrcbpcorebpcoretemplatephp">trunk/src/bp-core/bp-core-template.php</a></li>
<li><a href="#trunksrcbpcoreclassesclassbpemailphp">trunk/src/bp-core/classes/class-bp-email.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpcorebpcorefunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/bp-core-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-functions.php 2021-04-29 10:20:39 UTC (rev 12931)
+++ trunk/src/bp-core/bp-core-functions.php 2021-04-29 13:28:50 UTC (rev 12932)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3977,133 +3977,152 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function bp_email_get_type_schema( $field = 'description' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $activity_comment = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_activity_new_reply',
- 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_activity_new_reply',
+ 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $activity_comment_author = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_activity_new_reply',
- 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_activity_new_reply',
+ 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $activity_at_message = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient was mentioned in an activity update.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_activity_new_mention',
- 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient was mentioned in an activity update.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_activity_new_mention',
+ 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $groups_at_message = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_activity_new_mention',
- 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_activity_new_mention',
+ 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $core_user_registration = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient has registered for an account.', 'buddypress' ),
- 'unsubscribe' => false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient has registered for an account.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => false,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $core_user_registration_with_blog = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient has registered for an account and site.', 'buddypress' ),
- 'unsubscribe' => false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient has registered for an account and site.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => false,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $friends_request = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'A member has sent a friend request to the recipient.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_friends_friendship_request',
- 'message' => __( 'You will no longer receive emails when someone sends you a friend request.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'A member has sent a friend request to the recipient.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_friends_friendship_request',
+ 'message' => __( 'You will no longer receive emails when someone sends you a friend request.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $friends_request_accepted = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_friends_friendship_accepted',
- 'message' => __( 'You will no longer receive emails when someone accepts your friendship request.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_friends_friendship_accepted',
+ 'message' => __( 'You will no longer receive emails when someone accepts your friendship request.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $groups_details_updated = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( "A group's details were updated.", 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_groups_group_updated',
- 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( "A group's details were updated.", 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_groups_group_updated',
+ 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $groups_invitation = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_groups_invite',
- 'message' => __( 'You will no longer receive emails when you are invited to join a group.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_groups_invite',
+ 'message' => __( 'You will no longer receive emails when you are invited to join a group.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $groups_member_promoted = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_groups_admin_promotion',
- 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_groups_admin_promotion',
+ 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $groups_membership_request = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'A member has requested permission to join a group.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_groups_membership_request',
- 'message' => __( 'You will no longer receive emails when someone requests to be a member of your group.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'A member has requested permission to join a group.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_groups_membership_request',
+ 'message' => __( 'You will no longer receive emails when someone requests to be a member of your group.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $messages_unread = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient has received a private message.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_messages_new_message',
- 'message' => __( 'You will no longer receive emails when someone sends you a message.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient has received a private message.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_messages_new_message',
+ 'message' => __( 'You will no longer receive emails when someone sends you a message.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $settings_verify_email_change = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient has changed their email address.', 'buddypress' ),
- 'unsubscribe' => false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient has changed their email address.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => false,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $groups_membership_request_accepted = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_membership_request_completed',
- 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_membership_request_completed',
+ 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $groups_membership_request_rejected = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_membership_request_completed',
- 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_membership_request_completed',
+ 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $core_user_activation = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'Recipient has successfully activated an account.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'Recipient has successfully activated an account.', 'buddypress' ),
+ 'named_salutation' => true,
+ 'unsubscribe' => false,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $members_invitation = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => __( 'A site member has sent a site invitation to the recipient.', 'buddypress' ),
- 'unsubscribe' => array(
- 'meta_key' => 'notification_bp_members_invite',
- 'message' => __( 'You will no longer receive emails when you are invited to join this site.', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => __( 'A site member has sent a site invitation to the recipient.', 'buddypress' ),
+ 'named_salutation' => false,
+ 'unsubscribe' => array(
+ 'meta_key' => 'notification_bp_members_invite',
+ 'message' => __( 'You will no longer receive emails when you are invited to join this site.', 'buddypress' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4350,6 +4369,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the BP Email type of a BP Email ID or object.
+ *
+ * @since 8.0.0
+ *
+ * @param int|WP_Post $email Optional. BP Email ID or BP Email object. Defaults to global $post.
+ * @return string The type of the BP Email object.
+ */
+function bp_email_get_type( $email = null ) {
+ $email = get_post( $email );
+
+ if ( ! $email ) {
+ return '';
+ }
+
+ $types = bp_get_object_terms( $email->ID, bp_get_email_tax_type(), array( 'fields' => 'slugs' ) );
+ $type = reset( $types );
+
+ return $type;
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Get BuddyPress content allowed tags.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.0.0
</span></span></pre></div>
<a id="trunksrcbpcorebpcoretemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/bp-core-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-template.php 2021-04-29 10:20:39 UTC (rev 12931)
+++ trunk/src/bp-core/bp-core-template.php 2021-04-29 13:28:50 UTC (rev 12932)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3800,30 +3800,59 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Gets the Recipient Salutation.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 8.0.0 Checks current BP Email type schema to eventually use the unnamed salutation.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $settings Email Settings.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string The Recipient Salutation.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function bp_email_get_salutation( $settings = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $token = '{{recipient.name}}';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $email_type = bp_email_get_type();
+ $saluation = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Filters The Recipient Salutation inside the Email Template.
- *
- * @since 2.5.0
- *
- * @param string $value The Recipient Salutation.
- * @param array $settings Email Settings.
- * @param string $token The Recipient token.
- */
- return apply_filters(
- 'bp_email_get_salutation',
- sprintf(
- /* translators: %s: the email token for the recipient name */
- _x( 'Hi %s,', 'recipient salutation', 'buddypress' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $email_type ) {
+ $types_schema = bp_email_get_type_schema( 'named_salutation' );
+
+ if ( isset( $types_schema[ $email_type ] ) && false === $types_schema[ $email_type ] ) {
+ /**
+ * Filters The Recipient Unnamed Salutation inside the Email Template.
+ *
+ * @since 8.0.0
+ *
+ * @param string $value The Recipient Salutation.
+ * @param array $settings Email Settings.
+ */
+ $saluation = apply_filters(
+ 'bp_email_get_unnamed_salutation',
+ _x( 'Hi,', 'Unnamed recipient salutation', 'buddypress' ),
+ $settings
+ );
+ }
+ }
+
+ // Named salutations are default.
+ if ( ! $saluation ) {
+ $token = '{{recipient.name}}';
+
+ /**
+ * Filters The Recipient Named Salutation inside the Email Template.
+ *
+ * @since 2.5.0
+ *
+ * @param string $value The Recipient Salutation.
+ * @param array $settings Email Settings.
+ * @param string $token The Recipient token.
+ */
+ $saluation = apply_filters(
+ 'bp_email_get_salutation',
+ sprintf(
+ /* translators: %s: the email token for the recipient name */
+ _x( 'Hi %s,', 'Named recipient salutation', 'buddypress' ),
+ $token
+ ),
+ $settings,
</ins><span class="cx" style="display: block; padding: 0 10px"> $token
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ),
- $settings,
- $token
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ );
+ }
+
+ return $saluation;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcbpcoreclassesclassbpemailphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/classes/class-bp-email.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/classes/class-bp-email.php 2021-04-29 10:20:39 UTC (rev 12931)
+++ trunk/src/bp-core/classes/class-bp-email.php 2021-04-29 13:28:50 UTC (rev 12932)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -790,8 +790,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Load the template.
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'bp_locate_template_and_load', '__return_true' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set up the `$post` global.
+ global $post;
+ $reset_post = $post;
+ $post = $this->post_object;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> bp_locate_template( bp_email_get_template( $this->post_object ), true, false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Reset the `$post` global.
+ $post = $reset_post;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'bp_locate_template_and_load', '__return_true' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->set_template( ob_get_contents() );
</span></span></pre>
</div>
</div>
</body>
</html>