Changeset 10474 for trunk/src/bp-core/bp-core-filters.php
- Timestamp:
- 01/27/2016 08:23:37 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-filters.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-filters.php
r10472 r10474 1087 1087 } 1088 1088 add_filter( 'bp_email_get_property', 'bp_email_add_link_color_to_template', 6, 3 ); 1089 1090 /** 1091 * Find and render the template for Email posts (the Customizer and admin previews). 1092 * 1093 * Misuses the `template_include` filter which expects a string, but as we need to replace 1094 * the `{{{content}}}` token with the post's content, we use object buffering to load the 1095 * template, replace the token, and render it. 1096 * 1097 * The function returns an empty string to prevent WordPress rendering another template. 1098 * 1099 * @since 2.5.0 1100 * 1101 * @param string $template Path to template (probably single.php). 1102 * @return string 1103 */ 1104 function bp_core_render_email_template( $template ) { 1105 if ( get_post_type() !== bp_get_email_post_type() || ! is_single() ) { 1106 return $template; 1107 } 1108 1109 /** 1110 * Filter template used to display Email posts. 1111 * 1112 * @since 2.5.0 1113 * 1114 * @param string $template Path to current template (probably single.php). 1115 */ 1116 $email_template = apply_filters( 'bp_core_render_email_template', 1117 bp_locate_template( bp_email_get_template( get_queried_object() ), false ), 1118 $template 1119 ); 1120 1121 if ( ! $email_template ) { 1122 return $template; 1123 } 1124 1125 ob_start(); 1126 include( $email_template ); 1127 $template = ob_get_contents(); 1128 ob_end_clean(); 1129 1130 echo str_replace( '{{{content}}}', nl2br( get_post()->post_content ), $template ); 1131 1132 /* 1133 * Link colours are applied directly in the email template before sending, so we 1134 * need to add an extra style here to set the colour for the Customizer or preview. 1135 */ 1136 $settings = bp_email_get_appearance_settings(); 1137 printf( 1138 '<style>a { color: %s; }</style>', 1139 esc_attr( $settings['highlight_color'] ) 1140 ); 1141 1142 return ''; 1143 } 1144 add_action( 'bp_template_include', 'bp_core_render_email_template', 12 );
Note: See TracChangeset
for help on using the changeset viewer.