Last active
March 2, 2022 23:36
-
-
Save kwcjr/5922524b6c068e7b6ea5e5643d12b5db to your computer and use it in GitHub Desktop.
Add custom preview text to wp_mail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Replace Pre-Header Email Text. | |
* Description: Replace Line 27 with what text you want. This will replace the text just after your Subject - "Your text". | |
* Author: Keith Crain ( Kronoslabs.io ) | |
* License: GNU General Public License v3 or later | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
/** | |
* Pass custom email header preview text. | |
* | |
* @param string 'wp_mail' Hook name to hook function into | |
* @param string 'klbs_custom_email_header' Function name to be hooked | |
*/ | |
add_action( 'wp_mail', 'klbs_custom_email_header', 10, 2 ); | |
/** | |
* Add preview text after subject line. | |
*/ | |
function klbs_custom_email_header( $email_heading, $email ) { | |
echo ' | |
<div style="max-height: 0px; overflow: hidden;"> | |
Insert hidden preheader text here. | |
</div> | |
<!-- Insert ͏‌ hack after hidden preview text --> | |
<div style="max-height: 0px; overflow: hidden;"> | |
͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ | |
</div> | |
'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment