Skip to content

Instantly share code, notes, and snippets.

@kwcjr
Last active March 2, 2022 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwcjr/b1c4cb9dcb3a51e54b0d0d359f175eaa to your computer and use it in GitHub Desktop.
Save kwcjr/b1c4cb9dcb3a51e54b0d0d359f175eaa to your computer and use it in GitHub Desktop.
Replace WooCommerce Subject line Preview Text ( drop in /wp-content/mu-plugins/ folder.
<?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 to woocommerce.
*
* @param string 'woocommerce_email_header' Hook name to hook function into
* @param string 'klbs_custom_email_header' Function name to be hooked
*/
add_action( 'woocommerce_email_header', '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 &#847;&zwnj;&nbsp; hack after hidden preview text -->
<div style="max-height: 0px; overflow: hidden;">
&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;
</div>
';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment