I finally got it figured out. In order to see the content that I was trying to edit, I turned on debugging in wp-config.php:
define('WP_DEBUG', true); // set true
if ( WP_DEBUG ) {
define('WP_DEBUG_LOG', '../logs/debug.log' );
define('WP_DEBUG_DISPLAY', false); // don't display errors on pages
@ini_set( 'display_errors', 0 );
}
Then, in the function that does the replacing, I commented out that stuff and instead just put error_log( print_r( $content, true ) );
. When I triggered the email, the $content
then showed up in that log.
Turns out the content IS different when the filter is applied than in the final email raw source. The $content
has no html except for <a>
tags for links. Once I changed the search pattern to match what was there in the log, it worked perfectly!