Skip to:
Content

bbPress.org

Changeset 5409


Ignore:
Timestamp:
06/17/2014 04:04:29 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Introduce bbp_get_do_not_reply_address() function, and use in subscription notification functions. Also add filters to make changing these values easier for advanced setups. Fixes #2618.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r5311 r5409  
    983983
    984984/**
     985 * Get the "Do Not Reply" email address to use when sending subscription emails.
     986 *
     987 * We make some educated guesses here based on the home URL. Filters are
     988 * available to customize this address further. In the future, we may consider
     989 * using `admin_email` instead, though this is not normally publicized.
     990 *
     991 * @since bbPress (r5409)
     992 *
     993 * @return string
     994 */
     995function bbp_get_do_not_reply_address() {
     996    $email = 'noreply@' . str_replace( 'www.', '', ltrim( get_home_url(), '^(http|https)://' ) );
     997    return apply_filters( 'bbp_get_do_not_reply_address', $email );
     998}
     999
     1000/**
    9851001 * Sends notification emails for new replies to subscribed topics
    9861002 *
     
    10631079    $reply_url     = bbp_get_reply_url( $reply_id );
    10641080    $blog_name     = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1065     $do_not_reply  = '<noreply@' . ltrim( get_home_url(), '^(http|https)://' ) . '>';
    10661081
    10671082    // For plugins to filter messages per reply/topic/user
     
    10961111    /** Users *****************************************************************/
    10971112
    1098     // Array to hold BCC's
    1099     $headers = array();
     1113    // Get the noreply@ address
     1114    $no_reply   = bbp_get_do_not_reply_address();
     1115
     1116    // Setup "From" email address
     1117    $from_email = apply_filters( 'bbp_subscription_from_email', $no_reply );
    11001118
    11011119    // Setup the From header
    1102     $headers[] = 'From: ' . get_bloginfo( 'name' ) . ' ' . $do_not_reply;
     1120    $headers = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' );
    11031121
    11041122    // Get topic subscribers and bail if empty
     
    11231141
    11241142    // Custom headers
    1125     $headers = apply_filters( 'bbp_subscription_mail_headers', $headers );
     1143    $headers  = apply_filters( 'bbp_subscription_mail_headers', $headers  );
     1144    $to_email = apply_filters( 'bbp_subscription_to_email',     $no_reply );
    11261145
    11271146    do_action( 'bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids );
    11281147
    11291148    // Send notification email
    1130     wp_mail( $do_not_reply, $subject, $message, $headers );
     1149    wp_mail( $to_email, $subject, $message, $headers );
    11311150
    11321151    do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids );
     
    12031222    $topic_url     = get_permalink( $topic_id );
    12041223    $blog_name     = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1205     $do_not_reply  = '<noreply@' . ltrim( get_home_url(), '^(http|https)://' ) . '>';
    12061224
    12071225    // For plugins to filter messages per reply/topic/user
     
    12361254    /** User ******************************************************************/
    12371255
    1238     // Array to hold BCC's
    1239     $headers = array();
     1256    // Get the noreply@ address
     1257    $no_reply   = bbp_get_do_not_reply_address();
     1258
     1259    // Setup "From" email address
     1260    $from_email = apply_filters( 'bbp_subscription_from_email', $no_reply );
    12401261
    12411262    // Setup the From header
    1242     $headers[] = 'From: ' . get_bloginfo( 'name' ) . ' ' . $do_not_reply;
     1263    $headers[] = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' );
    12431264
    12441265    // Get topic subscribers and bail if empty
     
    12631284
    12641285    // Custom headers
    1265     $headers = apply_filters( 'bbp_subscription_mail_headers', $headers );
     1286    $headers  = apply_filters( 'bbp_subscription_mail_headers', $headers  );
     1287    $to_email = apply_filters( 'bbp_subscription_to_email',     $no_reply );
    12661288
    12671289    do_action( 'bbp_pre_notify_forum_subscribers', $topic_id, $forum_id, $user_ids );
    12681290
    12691291    // Send notification email
    1270     wp_mail( $do_not_reply, $subject, $message, $headers );
     1292    wp_mail( $to_email, $subject, $message, $headers );
    12711293
    12721294    do_action( 'bbp_post_notify_forum_subscribers', $topic_id, $forum_id, $user_ids );
Note: See TracChangeset for help on using the changeset viewer.