Skip to:
Content

BuddyPress.org

Changeset 10472


Ignore:
Timestamp:
01/27/2016 06:04:30 PM (10 years ago)
Author:
djpaul
Message:

Emails: add another required function for the unit tests.

For #6592.

File:
1 edited

Legend:

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

    r10417 r10472  
    5353add_filter( 'bp_core_render_message_content', 'shortcode_unautop' );
    5454add_filter( 'bp_core_render_message_content', 'wp_kses_data', 5   );
     55
     56// Emails.
     57add_filter( 'bp_email_set_content_html', 'wp_filter_post_kses', 6 );
     58add_filter( 'bp_email_set_content_html', 'stripslashes', 8 );
     59add_filter( 'bp_email_set_content_plaintext', 'wp_strip_all_tags', 6 );
     60add_filter( 'bp_email_set_subject', 'sanitize_text_field', 6 );
     61
    5562
    5663/**
     
    10391046}
    10401047add_filter( 'dynamic_sidebar_params', '_bp_core_inject_bp_widget_css_class' );
     1048
     1049/**
     1050 * Add email link styles to rendered email template.
     1051 *
     1052 * This is only used when the email content has been merged into the email template.
     1053 *
     1054 * @since 2.5.0
     1055 *
     1056 * @param string $value Property value.
     1057 * @param string $property_name
     1058 * @param string $transform How the return value was transformed.
     1059 * @return string Updated value.
     1060 */
     1061function bp_email_add_link_color_to_template( $value, $property_name, $transform ) {
     1062    if ( $property_name !== 'template' || $transform !== 'add-content' ) {
     1063        return $value;
     1064    }
     1065
     1066    $settings    = bp_email_get_appearance_settings();
     1067    $replacement = 'style="color: ' . esc_attr( $settings['highlight_color'] ) . ';';
     1068
     1069    // Find all links.
     1070    preg_match_all( '#<a[^>]+>#i', $value, $links, PREG_SET_ORDER );
     1071    foreach ( $links as $link ) {
     1072        $new_link = $link = array_shift( $link );
     1073
     1074        // Add/modify style property.
     1075        if ( strpos( $link, 'style="' ) !== false ) {
     1076            $new_link = str_replace( 'style="', $replacement, $link );
     1077        } else {
     1078            $new_link = str_replace( '<a ', "<a {$replacement}\" ", $link );
     1079        }
     1080
     1081        if ( $new_link !== $link ) {
     1082            $value = str_replace( $link, $new_link, $value );
     1083        }
     1084    }
     1085
     1086    return $value;
     1087}
     1088add_filter( 'bp_email_get_property', 'bp_email_add_link_color_to_template', 6, 3 );
Note: See TracChangeset for help on using the changeset viewer.