bp_email_add_link_color_to_template( string $value, string $property_name, string $transform )
Add email link styles to rendered email template.
Description
This is only used when the email content has been merged into the email template.
Parameters
- $value
-
(Required) Property value.
- $property_name
-
(Required) Email template property name.
- $transform
-
(Required) How the return value was transformed.
Return
(string) Updated value.
Source
File: bp-core/bp-core-filters.php
function bp_email_add_link_color_to_template( $value, $property_name, $transform ) {
if ( $property_name !== 'template' || $transform !== 'add-content' ) {
return $value;
}
$settings = bp_email_get_appearance_settings();
$replacement = 'style="color: ' . esc_attr( $settings['link_text_color'] ) . ';';
// Find all links.
preg_match_all( '#<a[^>]+>#i', $value, $links, PREG_SET_ORDER );
foreach ( $links as $link ) {
$new_link = $link = array_shift( $link );
// Add/modify style property.
if ( strpos( $link, 'style="' ) !== false ) {
$new_link = str_replace( 'style="', $replacement, $link );
} else {
$new_link = str_replace( '<a ', "<a {$replacement}\" ", $link );
}
if ( $new_link !== $link ) {
$value = str_replace( $link, $new_link, $value );
}
}
return $value;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.5.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.