Skip to:
Content

BuddyPress.org

Changeset 10647


Ignore:
Timestamp:
03/09/2016 08:32:09 PM (8 years ago)
Author:
djpaul
Message:

Emails: fix situations not being correctly assigned to email posts.

Previously, we were using wp_set_post_terms() to fetch the terms to assign to an email post. However, it turns that that function returns term taxonomy IDs, not term IDs. Generally, term_id and term_taxonomy_id will be the same for newly created terms like these, but not when the database still contains shared taxonomy terms.

Fixes #6936

Props chherbst, boonebgorges

Location:
trunk
Files:
3 edited

Legend:

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

    r10605 r10647  
    539539    );
    540540
    541     $emails = array(
    542         'activity-comment' => array(
    543             /* translators: do not remove {} brackets or translate its contents. */
    544             'post_title'   => __( '[{{{site.name}}}] {{poster.name}} replied to one of your updates', 'buddypress' ),
    545             /* translators: do not remove {} brackets or translate its contents. */
    546             'post_content' => __( "{{poster.name}} replied to one of your updates:\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{thread.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
    547             /* translators: do not remove {} brackets or translate its contents. */
    548             'post_excerpt' => __( "{{poster.name}} replied to one of your updates:\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{thread.url}}}", 'buddypress' ),
    549         ),
    550         'activity-comment-author' => array(
    551             /* translators: do not remove {} brackets or translate its contents. */
    552             'post_title'   => __( '[{{{site.name}}}] {{poster.name}} replied to one of your comments', 'buddypress' ),
    553             /* translators: do not remove {} brackets or translate its contents. */
    554             'post_content' => __( "{{poster.name}} replied to one of your comments:\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{thread.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
    555             /* translators: do not remove {} brackets or translate its contents. */
    556             'post_excerpt' => __( "{{poster.name}} replied to one of your comments:\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{thread.url}}}", 'buddypress' ),
    557         ),
    558         'activity-at-message' => array(
    559             /* translators: do not remove {} brackets or translate its contents. */
    560             'post_title'   => __( '[{{{site.name}}}] {{poster.name}} mentioned you in a status update', 'buddypress' ),
    561             /* translators: do not remove {} brackets or translate its contents. */
    562             'post_content' => __( "{{poster.name}} mentioned you in a status update:\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{mentioned.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
    563             /* translators: do not remove {} brackets or translate its contents. */
    564             'post_excerpt' => __( "{{poster.name}} mentioned you in a status update:\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{mentioned.url}}}", 'buddypress' ),
    565         ),
    566         'groups-at-message' => array(
    567             /* translators: do not remove {} brackets or translate its contents. */
    568             'post_title'   => __( '[{{{site.name}}}] {{poster.name}} mentioned you in an update', 'buddypress' ),
    569             /* translators: do not remove {} brackets or translate its contents. */
    570             'post_content' => __( "{{poster.name}} mentioned you in the group \"{{group.name}}\":\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{mentioned.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
    571             /* translators: do not remove {} brackets or translate its contents. */
    572             'post_excerpt' => __( "{{poster.name}} mentioned you in the group \"{{group.name}}\":\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{mentioned.url}}}", 'buddypress' ),
    573         ),
    574         'core-user-registration' => array(
    575             /* translators: do not remove {} brackets or translate its contents. */
    576             'post_title'   => __( '[{{{site.name}}}] Activate your account', 'buddypress' ),
    577             /* translators: do not remove {} brackets or translate its contents. */
    578             'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link: <a href=\"{{{activate.url}}}\">{{{activate.url}}}</a>", 'buddypress' ),
    579             /* translators: do not remove {} brackets or translate its contents. */
    580             'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link: {{{activate.url}}}", 'buddypress' ),
    581         ),
    582         'core-user-registration-with-blog' => array(
    583             /* translators: do not remove {} brackets or translate its contents. */
    584             'post_title'   => __( '[{{{site.name}}}] Activate {{{user-site.url}}}', 'buddypress' ),
    585             /* translators: do not remove {} brackets or translate its contents. */
    586             'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: <a href=\"{{{activate-site.url}}}\">{{{activate-site.url}}}</a>.\n\nAfter you activate, you can visit your site at <a href=\"{{{user-site.url}}}\">{{{user-site.url}}}</a>.", 'buddypress' ),
    587             /* translators: do not remove {} brackets or translate its contents. */
    588             'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: {{{activate-site.url}}}\n\nAfter you activate, you can visit your site at {{{user-site.url}}}.", 'buddypress' ),
    589         ),
    590         'friends-request' => array(
    591             /* translators: do not remove {} brackets or translate its contents. */
    592             'post_title'   => __( '[{{{site.name}}}] New friendship request from {{initiator.name}}', 'buddypress' ),
    593             /* translators: do not remove {} brackets or translate its contents. */
    594             'post_content' => __( "<a href=\"{{{initiator.url}}}\">{{initiator.name}}</a> wants to add you as a friend.\n\nTo accept this request and manage all of your pending requests, visit: <a href=\"{{{friend-requests.url}}}\">{{{friend-requests.url}}}</a>", 'buddypress' ),
    595             /* translators: do not remove {} brackets or translate its contents. */
    596             'post_excerpt' => __( "{{initiator.name}} wants to add you as a friend.\n\nTo accept this request and manage all of your pending requests, visit: {{{friend-requests.url}}}\n\nTo view {{initiator.name}}'s profile, visit: {{{initiator.url}}}", 'buddypress' ),
    597         ),
    598         'friends-request-accepted' => array(
    599             /* translators: do not remove {} brackets or translate its contents. */
    600             'post_title'   => __( '[{{{site.name}}}] {{friend.name}} accepted your friendship request', 'buddypress' ),
    601             /* translators: do not remove {} brackets or translate its contents. */
    602             'post_content' => __( "<a href=\"{{{friendship.url}}}\">{{friend.name}}</a> accepted your friend request.", 'buddypress' ),
    603             /* translators: do not remove {} brackets or translate its contents. */
    604             'post_excerpt' => __( "{{friend.name}} accepted your friend request.\n\nTo learn more about them, visit their profile: {{{friendship.url}}}", 'buddypress' ),
    605         ),
    606         'groups-details-updated' => array(
    607             /* translators: do not remove {} brackets or translate its contents. */
    608             'post_title'   => __( '[{{{site.name}}}] Group details updated', 'buddypress' ),
    609             /* translators: do not remove {} brackets or translate its contents. */
    610             'post_content' => __( "Group details for the group &quot;<a href=\"{{{group.url}}}\">{{group.name}}</a>&quot; were updated:\n<blockquote>{{changed_text}}</blockquote>", 'buddypress' ),
    611             /* translators: do not remove {} brackets or translate its contents. */
    612             'post_excerpt' => __( "Group details for the group &quot;{{group.name}}&quot; were updated:\n\n{{changed_text}}\n\nTo view the group, visit: {{{group.url}}}", 'buddypress' ),
    613         ),
    614         'groups-invitation' => array(
    615             /* translators: do not remove {} brackets or translate its contents. */
    616             'post_title'   => __( '[{{{site.name}}}] You have an invitation to the group: "{{group.name}}"', 'buddypress' ),
    617             /* translators: do not remove {} brackets or translate its contents. */
    618             'post_content' => __( "<a href=\"{{{inviter.url}}}\">{{inviter.name}}</a> has invited you to join the group: &quot;{{group.name}}&quot;.\n<a href=\"{{{invites.url}}}\">Go here to accept your invitation</a> or <a href=\"{{{group.url}}}\">visit the group</a> to learn more.", 'buddypress' ),
    619             /* translators: do not remove {} brackets or translate its contents. */
    620             'post_excerpt' => __( "{{inviter.name}} has invited you to join the group: &quot;{{group.name}}&quot;.\n\nTo accept your invitation, visit: {{{invites.url}}}\n\nTo learn more about the group, visit {{{group.url}}}.\nTo view {{inviter.name}}'s profile, visit: {{{inviter.url}}}", 'buddypress' ),
    621         ),
    622         'groups-member-promoted' => array(
    623             /* translators: do not remove {} brackets or translate its contents. */
    624             'post_title'   => __( '[{{{site.name}}}] You have been promoted in the group: "{{group.name}}"', 'buddypress' ),
    625             /* translators: do not remove {} brackets or translate its contents. */
    626             'post_content' => __( "You have been promoted to <b>{{promoted_to}}</b> in the group &quot;<a href=\"{{{group.url}}}\">{{group.name}}</a>&quot;.", 'buddypress' ),
    627             /* translators: do not remove {} brackets or translate its contents. */
    628             'post_excerpt' => __( "You have been promoted to {{promoted_to}} in the group: &quot;{{group.name}}&quot;.\n\nTo visit the group, go to: {{{group.url}}}", 'buddypress' ),
    629         ),
    630         'groups-membership-request' => array(
    631             /* translators: do not remove {} brackets or translate its contents. */
    632             'post_title'   => __( '[{{{site.name}}}] Membership request for group: {{group.name}}', 'buddypress' ),
    633             /* translators: do not remove {} brackets or translate its contents. */
    634             'post_content' => __( "<a href=\"{{{profile.url}}}\">{{requesting-user.name}}</a> wants to join the group &quot;{{group.name}}&quot;. As you are an administrator of this group, you must either accept or reject the membership request.\n\n<a href=\"{{{group-requests.url}}}\">Go here to manage this</a> and all other pending requests.", 'buddypress' ),
    635             /* translators: do not remove {} brackets or translate its contents. */
    636             'post_excerpt' => __( "{{requesting-user.name}} wants to join the group &quot;{{group.name}}&quot;. As you are the administrator of this group, you must either accept or reject the membership request.\n\nTo manage this and all other pending requests, visit: {{{group-requests.url}}}\n\nTo view {{requesting-user.name}}'s profile, visit: {{{profile.url}}}", 'buddypress' ),
    637         ),
    638         'messages-unread' => array(
    639             /* translators: do not remove {} brackets or translate its contents. */
    640             'post_title'   => __( '[{{{site.name}}}] New message from {{sender.name}}', 'buddypress' ),
    641             /* translators: do not remove {} brackets or translate its contents. */
    642             'post_content' => __( "{{sender.name}} sent you a new message: &quot;{{usersubject}}&quot;\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{message.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
    643             /* translators: do not remove {} brackets or translate its contents. */
    644             'post_excerpt' => __( "{{sender.name}} sent you a new message: &quot;{{usersubject}}&quot;\n\n&quot;{{usermessage}}&quot;\n\nGo to the discussion to reply or catch up on the conversation: {{{message.url}}}", 'buddypress' ),
    645         ),
    646         'settings-verify-email-change' => array(
    647             /* translators: do not remove {} brackets or translate its contents. */
    648             'post_title'   => __( '[{{{site.name}}}] Verify your new email address', 'buddypress' ),
    649             /* translators: do not remove {} brackets or translate its contents. */
    650             'post_content' => __( "You recently changed the email address associated with your account on {{site.name}}. If this is correct, <a href=\"{{{verify.url}}}\">go here to confirm the change</a>.\n\nOtherwise, you can safely ignore and delete this email if you have changed your mind, or if you think you have received this email in error.", 'buddypress' ),
    651             /* translators: do not remove {} brackets or translate its contents. */
    652             'post_excerpt' => __( "You recently changed the email address associated with your account on {{site.name}}. If this is correct, go to the following link to confirm the change: {{{verify.url}}}\n\nOtherwise, you can safely ignore and delete this email if you have changed your mind, or if you think you have received this email in error.", 'buddypress' ),
    653         ),
    654         'groups-membership-request-accepted' => array(
    655             /* translators: do not remove {} brackets or translate its contents. */
    656             'post_title'   => __( '[{{{site.name}}}] Membership request for group "{{group.name}}" accepted', 'buddypress' ),
    657             /* translators: do not remove {} brackets or translate its contents. */
    658             'post_content' => __( "Your membership request for the group &quot;<a href=\"{{{group.url}}}\">{{group.name}}</a>&quot; has been accepted.", 'buddypress' ),
    659             /* translators: do not remove {} brackets or translate its contents. */
    660             'post_excerpt' => __( "Your membership request for the group &quot;{{group.name}}&quot; has been accepted.\n\nTo view the group, visit: {{{group.url}}}", 'buddypress' ),
    661         ),
    662         'groups-membership-request-rejected' => array(
    663             /* translators: do not remove {} brackets or translate its contents. */
    664             'post_title'   => __( '[{{{site.name}}}] Membership request for group "{{group.name}}" rejected', 'buddypress' ),
    665             /* translators: do not remove {} brackets or translate its contents. */
    666             'post_content' => __( "Your membership request for the group &quot;<a href=\"{{{group.url}}}\">{{group.name}}</a>&quot; has been rejected.", 'buddypress' ),
    667             /* translators: do not remove {} brackets or translate its contents. */
    668             'post_excerpt' => __( "Your membership request for the group &quot;{{group.name}}&quot; has been rejected.\n\nTo request membership again, visit: {{{group.url}}}", 'buddypress' ),
    669         ),
    670     );
    671 
    672     $descriptions = array(
    673         'activity-comment'                   => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ),
    674         'activity-comment-author'            => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ),
    675         'activity-at-message'                => __( 'Recipient was mentioned in an activity update.', 'buddypress' ),
    676         'groups-at-message'                  => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ),
    677         'core-user-registration'             => __( 'Recipient has registered for an account.', 'buddypress' ),
    678         'core-user-registration-with-blog'   => __( 'Recipient has registered for an account and site.', 'buddypress' ),
    679         'friends-request'                    => __( 'A member has sent a friend request to the recipient.', 'buddypress' ),
    680         'friends-request-accepted'           => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ),
    681         'groups-details-updated'             => __( "A group's details were updated.", 'buddypress' ),
    682         'groups-invitation'                  => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ),
    683         'groups-member-promoted'             => __( "Recipient's status within a group has changed.", 'buddypress' ),
    684         'groups-membership-request'          => __( 'A member has requested permission to join a group.', 'buddypress' ),
    685         'messages-unread'                    => __( 'Recipient has received a private message.', 'buddypress' ),
    686         'settings-verify-email-change'       => __( 'Recipient has changed their email address.', 'buddypress' ),
    687         'groups-membership-request-accepted' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ),
    688         'groups-membership-request-rejected' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ),
    689     );
     541    $emails       = bp_email_get_schema();
     542    $descriptions = bp_email_get_type_schema();
    690543
    691544    // Add these emails to the database.
     
    696549        }
    697550
    698         $term_ids = wp_set_post_terms( $post_id, $id, bp_get_email_tax_type() );
    699         foreach ( $term_ids as $term_id ) {
    700             wp_update_term( (int) $term_id, bp_get_email_tax_type(), array(
     551        $tt_ids = wp_set_object_terms( $post_id, $id, bp_get_email_tax_type() );
     552        foreach ( $tt_ids as $tt_id ) {
     553            $term = get_term_by( 'term_taxonomy_id', (int) $tt_id, bp_get_email_tax_type() );
     554            wp_update_term( (int) $term->term_id, bp_get_email_tax_type(), array(
    701555                'description' => $descriptions[ $id ],
    702556            ) );
  • trunk/src/bp-core/bp-core-functions.php

    r10614 r10647  
    31253125    return apply_filters( 'bp_core_replace_tokens_in_text', $text, $tokens );
    31263126}
     3127
     3128/**
     3129 * Get a list of emails for populating the email post type.
     3130 *t
     3131 * @since 2.5.1
     3132 *
     3133 * @return array
     3134 */
     3135function bp_email_get_schema() {
     3136    return array(
     3137        'activity-comment' => array(
     3138            /* translators: do not remove {} brackets or translate its contents. */
     3139            'post_title'   => __( '[{{{site.name}}}] {{poster.name}} replied to one of your updates', 'buddypress' ),
     3140            /* translators: do not remove {} brackets or translate its contents. */
     3141            'post_content' => __( "{{poster.name}} replied to one of your updates:\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{thread.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
     3142            /* translators: do not remove {} brackets or translate its contents. */
     3143            'post_excerpt' => __( "{{poster.name}} replied to one of your updates:\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{thread.url}}}", 'buddypress' ),
     3144        ),
     3145        'activity-comment-author' => array(
     3146            /* translators: do not remove {} brackets or translate its contents. */
     3147            'post_title'   => __( '[{{{site.name}}}] {{poster.name}} replied to one of your comments', 'buddypress' ),
     3148            /* translators: do not remove {} brackets or translate its contents. */
     3149            'post_content' => __( "{{poster.name}} replied to one of your comments:\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{thread.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
     3150            /* translators: do not remove {} brackets or translate its contents. */
     3151            'post_excerpt' => __( "{{poster.name}} replied to one of your comments:\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{thread.url}}}", 'buddypress' ),
     3152        ),
     3153        'activity-at-message' => array(
     3154            /* translators: do not remove {} brackets or translate its contents. */
     3155            'post_title'   => __( '[{{{site.name}}}] {{poster.name}} mentioned you in a status update', 'buddypress' ),
     3156            /* translators: do not remove {} brackets or translate its contents. */
     3157            'post_content' => __( "{{poster.name}} mentioned you in a status update:\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{mentioned.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
     3158            /* translators: do not remove {} brackets or translate its contents. */
     3159            'post_excerpt' => __( "{{poster.name}} mentioned you in a status update:\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{mentioned.url}}}", 'buddypress' ),
     3160        ),
     3161        'groups-at-message' => array(
     3162            /* translators: do not remove {} brackets or translate its contents. */
     3163            'post_title'   => __( '[{{{site.name}}}] {{poster.name}} mentioned you in an update', 'buddypress' ),
     3164            /* translators: do not remove {} brackets or translate its contents. */
     3165            'post_content' => __( "{{poster.name}} mentioned you in the group \"{{group.name}}\":\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{mentioned.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
     3166            /* translators: do not remove {} brackets or translate its contents. */
     3167            'post_excerpt' => __( "{{poster.name}} mentioned you in the group \"{{group.name}}\":\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{mentioned.url}}}", 'buddypress' ),
     3168        ),
     3169        'core-user-registration' => array(
     3170            /* translators: do not remove {} brackets or translate its contents. */
     3171            'post_title'   => __( '[{{{site.name}}}] Activate your account', 'buddypress' ),
     3172            /* translators: do not remove {} brackets or translate its contents. */
     3173            'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link: <a href=\"{{{activate.url}}}\">{{{activate.url}}}</a>", 'buddypress' ),
     3174            /* translators: do not remove {} brackets or translate its contents. */
     3175            'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link: {{{activate.url}}}", 'buddypress' ),
     3176        ),
     3177        'core-user-registration-with-blog' => array(
     3178            /* translators: do not remove {} brackets or translate its contents. */
     3179            'post_title'   => __( '[{{{site.name}}}] Activate {{{user-site.url}}}', 'buddypress' ),
     3180            /* translators: do not remove {} brackets or translate its contents. */
     3181            'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: <a href=\"{{{activate-site.url}}}\">{{{activate-site.url}}}</a>.\n\nAfter you activate, you can visit your site at <a href=\"{{{user-site.url}}}\">{{{user-site.url}}}</a>.", 'buddypress' ),
     3182            /* translators: do not remove {} brackets or translate its contents. */
     3183            'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: {{{activate-site.url}}}\n\nAfter you activate, you can visit your site at {{{user-site.url}}}.", 'buddypress' ),
     3184        ),
     3185        'friends-request' => array(
     3186            /* translators: do not remove {} brackets or translate its contents. */
     3187            'post_title'   => __( '[{{{site.name}}}] New friendship request from {{initiator.name}}', 'buddypress' ),
     3188            /* translators: do not remove {} brackets or translate its contents. */
     3189            'post_content' => __( "<a href=\"{{{initiator.url}}}\">{{initiator.name}}</a> wants to add you as a friend.\n\nTo accept this request and manage all of your pending requests, visit: <a href=\"{{{friend-requests.url}}}\">{{{friend-requests.url}}}</a>", 'buddypress' ),
     3190            /* translators: do not remove {} brackets or translate its contents. */
     3191            'post_excerpt' => __( "{{initiator.name}} wants to add you as a friend.\n\nTo accept this request and manage all of your pending requests, visit: {{{friend-requests.url}}}\n\nTo view {{initiator.name}}'s profile, visit: {{{initiator.url}}}", 'buddypress' ),
     3192        ),
     3193        'friends-request-accepted' => array(
     3194            /* translators: do not remove {} brackets or translate its contents. */
     3195            'post_title'   => __( '[{{{site.name}}}] {{friend.name}} accepted your friendship request', 'buddypress' ),
     3196            /* translators: do not remove {} brackets or translate its contents. */
     3197            'post_content' => __( "<a href=\"{{{friendship.url}}}\">{{friend.name}}</a> accepted your friend request.", 'buddypress' ),
     3198            /* translators: do not remove {} brackets or translate its contents. */
     3199            'post_excerpt' => __( "{{friend.name}} accepted your friend request.\n\nTo learn more about them, visit their profile: {{{friendship.url}}}", 'buddypress' ),
     3200        ),
     3201        'groups-details-updated' => array(
     3202            /* translators: do not remove {} brackets or translate its contents. */
     3203            'post_title'   => __( '[{{{site.name}}}] Group details updated', 'buddypress' ),
     3204            /* translators: do not remove {} brackets or translate its contents. */
     3205            'post_content' => __( "Group details for the group &quot;<a href=\"{{{group.url}}}\">{{group.name}}</a>&quot; were updated:\n<blockquote>{{changed_text}}</blockquote>", 'buddypress' ),
     3206            /* translators: do not remove {} brackets or translate its contents. */
     3207            'post_excerpt' => __( "Group details for the group &quot;{{group.name}}&quot; were updated:\n\n{{changed_text}}\n\nTo view the group, visit: {{{group.url}}}", 'buddypress' ),
     3208        ),
     3209        'groups-invitation' => array(
     3210            /* translators: do not remove {} brackets or translate its contents. */
     3211            'post_title'   => __( '[{{{site.name}}}] You have an invitation to the group: "{{group.name}}"', 'buddypress' ),
     3212            /* translators: do not remove {} brackets or translate its contents. */
     3213            'post_content' => __( "<a href=\"{{{inviter.url}}}\">{{inviter.name}}</a> has invited you to join the group: &quot;{{group.name}}&quot;.\n<a href=\"{{{invites.url}}}\">Go here to accept your invitation</a> or <a href=\"{{{group.url}}}\">visit the group</a> to learn more.", 'buddypress' ),
     3214            /* translators: do not remove {} brackets or translate its contents. */
     3215            'post_excerpt' => __( "{{inviter.name}} has invited you to join the group: &quot;{{group.name}}&quot;.\n\nTo accept your invitation, visit: {{{invites.url}}}\n\nTo learn more about the group, visit {{{group.url}}}.\nTo view {{inviter.name}}'s profile, visit: {{{inviter.url}}}", 'buddypress' ),
     3216        ),
     3217        'groups-member-promoted' => array(
     3218            /* translators: do not remove {} brackets or translate its contents. */
     3219            'post_title'   => __( '[{{{site.name}}}] You have been promoted in the group: "{{group.name}}"', 'buddypress' ),
     3220            /* translators: do not remove {} brackets or translate its contents. */
     3221            'post_content' => __( "You have been promoted to <b>{{promoted_to}}</b> in the group &quot;<a href=\"{{{group.url}}}\">{{group.name}}</a>&quot;.", 'buddypress' ),
     3222            /* translators: do not remove {} brackets or translate its contents. */
     3223            'post_excerpt' => __( "You have been promoted to {{promoted_to}} in the group: &quot;{{group.name}}&quot;.\n\nTo visit the group, go to: {{{group.url}}}", 'buddypress' ),
     3224        ),
     3225        'groups-membership-request' => array(
     3226            /* translators: do not remove {} brackets or translate its contents. */
     3227            'post_title'   => __( '[{{{site.name}}}] Membership request for group: {{group.name}}', 'buddypress' ),
     3228            /* translators: do not remove {} brackets or translate its contents. */
     3229            'post_content' => __( "<a href=\"{{{profile.url}}}\">{{requesting-user.name}}</a> wants to join the group &quot;{{group.name}}&quot;. As you are an administrator of this group, you must either accept or reject the membership request.\n\n<a href=\"{{{group-requests.url}}}\">Go here to manage this</a> and all other pending requests.", 'buddypress' ),
     3230            /* translators: do not remove {} brackets or translate its contents. */
     3231            'post_excerpt' => __( "{{requesting-user.name}} wants to join the group &quot;{{group.name}}&quot;. As you are the administrator of this group, you must either accept or reject the membership request.\n\nTo manage this and all other pending requests, visit: {{{group-requests.url}}}\n\nTo view {{requesting-user.name}}'s profile, visit: {{{profile.url}}}", 'buddypress' ),
     3232        ),
     3233        'messages-unread' => array(
     3234            /* translators: do not remove {} brackets or translate its contents. */
     3235            'post_title'   => __( '[{{{site.name}}}] New message from {{sender.name}}', 'buddypress' ),
     3236            /* translators: do not remove {} brackets or translate its contents. */
     3237            'post_content' => __( "{{sender.name}} sent you a new message: &quot;{{usersubject}}&quot;\n\n<blockquote>&quot;{{usermessage}}&quot;</blockquote>\n\n<a href=\"{{{message.url}}}\">Go to the discussion</a> to reply or catch up on the conversation.", 'buddypress' ),
     3238            /* translators: do not remove {} brackets or translate its contents. */
     3239            'post_excerpt' => __( "{{sender.name}} sent you a new message: &quot;{{usersubject}}&quot;\n\n&quot;{{usermessage}}&quot;\n\nGo to the discussion to reply or catch up on the conversation: {{{message.url}}}", 'buddypress' ),
     3240        ),
     3241        'settings-verify-email-change' => array(
     3242            /* translators: do not remove {} brackets or translate its contents. */
     3243            'post_title'   => __( '[{{{site.name}}}] Verify your new email address', 'buddypress' ),
     3244            /* translators: do not remove {} brackets or translate its contents. */
     3245            'post_content' => __( "You recently changed the email address associated with your account on {{site.name}}. If this is correct, <a href=\"{{{verify.url}}}\">go here to confirm the change</a>.\n\nOtherwise, you can safely ignore and delete this email if you have changed your mind, or if you think you have received this email in error.", 'buddypress' ),
     3246            /* translators: do not remove {} brackets or translate its contents. */
     3247            'post_excerpt' => __( "You recently changed the email address associated with your account on {{site.name}}. If this is correct, go to the following link to confirm the change: {{{verify.url}}}\n\nOtherwise, you can safely ignore and delete this email if you have changed your mind, or if you think you have received this email in error.", 'buddypress' ),
     3248        ),
     3249        'groups-membership-request-accepted' => array(
     3250            /* translators: do not remove {} brackets or translate its contents. */
     3251            'post_title'   => __( '[{{{site.name}}}] Membership request for group "{{group.name}}" accepted', 'buddypress' ),
     3252            /* translators: do not remove {} brackets or translate its contents. */
     3253            'post_content' => __( "Your membership request for the group &quot;<a href=\"{{{group.url}}}\">{{group.name}}</a>&quot; has been accepted.", 'buddypress' ),
     3254            /* translators: do not remove {} brackets or translate its contents. */
     3255            'post_excerpt' => __( "Your membership request for the group &quot;{{group.name}}&quot; has been accepted.\n\nTo view the group, visit: {{{group.url}}}", 'buddypress' ),
     3256        ),
     3257        'groups-membership-request-rejected' => array(
     3258            /* translators: do not remove {} brackets or translate its contents. */
     3259            'post_title'   => __( '[{{{site.name}}}] Membership request for group "{{group.name}}" rejected', 'buddypress' ),
     3260            /* translators: do not remove {} brackets or translate its contents. */
     3261            'post_content' => __( "Your membership request for the group &quot;<a href=\"{{{group.url}}}\">{{group.name}}</a>&quot; has been rejected.", 'buddypress' ),
     3262            /* translators: do not remove {} brackets or translate its contents. */
     3263            'post_excerpt' => __( "Your membership request for the group &quot;{{group.name}}&quot; has been rejected.\n\nTo request membership again, visit: {{{group.url}}}", 'buddypress' ),
     3264        ),
     3265    );
     3266}
     3267
     3268/**
     3269 * Get a list of emails for populating email type taxonomy terms.
     3270 *
     3271 * @since 2.5.1
     3272 *
     3273 * @return array
     3274 */
     3275function bp_email_get_type_schema() {
     3276    return array(
     3277        'activity-comment'                   => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ),
     3278        'activity-comment-author'            => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ),
     3279        'activity-at-message'                => __( 'Recipient was mentioned in an activity update.', 'buddypress' ),
     3280        'groups-at-message'                  => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ),
     3281        'core-user-registration'             => __( 'Recipient has registered for an account.', 'buddypress' ),
     3282        'core-user-registration-with-blog'   => __( 'Recipient has registered for an account and site.', 'buddypress' ),
     3283        'friends-request'                    => __( 'A member has sent a friend request to the recipient.', 'buddypress' ),
     3284        'friends-request-accepted'           => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ),
     3285        'groups-details-updated'             => __( "A group's details were updated.", 'buddypress' ),
     3286        'groups-invitation'                  => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ),
     3287        'groups-member-promoted'             => __( "Recipient's status within a group has changed.", 'buddypress' ),
     3288        'groups-membership-request'          => __( 'A member has requested permission to join a group.', 'buddypress' ),
     3289        'messages-unread'                    => __( 'Recipient has received a private message.', 'buddypress' ),
     3290        'settings-verify-email-change'       => __( 'Recipient has changed their email address.', 'buddypress' ),
     3291        'groups-membership-request-accepted' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ),
     3292        'groups-membership-request-rejected' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ),
     3293    );
     3294}
  • trunk/tests/phpunit/testcases/admin/functions.php

    r9819 r10647  
    219219        $bp->admin->notices = $reset_admin_notices;
    220220    }
     221
     222    /**
     223     * @ticket BP6936
     224     */
     225    public function test_email_type_descriptions_should_match_when_split_terms_exist() {
     226        global $wpdb;
     227
     228        // Delete all existing email types and descriptions.
     229        $emails = get_posts( array(
     230            'fields' => 'ids',
     231            'post_type' => bp_get_email_post_type(),
     232        ) );
     233        foreach ( $emails as $email ) {
     234            wp_delete_post( $email, true );
     235        }
     236
     237        $descriptions = get_terms( bp_get_email_tax_type(), array(
     238            'fields' => 'ids',
     239            'hide_empty' => false,
     240        ) );
     241        foreach ( $descriptions as $description ) {
     242            wp_delete_term( (int) $description, bp_get_email_tax_type() );
     243        }
     244
     245        // Fake the existence of split terms by offsetting the term_taxonomy table.
     246        $wpdb->insert( $wpdb->term_taxonomy, array( 'term_id' => 9999, 'taxonomy' => 'post_tag', 'description' => 'foo description', 'parent' => 0, 'count' => 0 ) );
     247
     248        require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin-schema.php' );
     249        bp_core_install_emails();
     250
     251        $d_terms = get_terms( bp_get_email_tax_type(), array(
     252            'hide_empty' => false,
     253        ) );
     254
     255        $correct_descriptions = bp_email_get_type_schema();
     256        foreach ( $d_terms as $d_term ) {
     257            $correct_description = $correct_descriptions[ $d_term->slug ];
     258            $this->assertSame( $correct_description, $d_term->description );
     259        }
     260    }
    221261}
Note: See TracChangeset for help on using the changeset viewer.