Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Inline styling for own email templates WooCommerce before version 2.3.x, after version 2.3.x just use the new email template for styles email-styles.php, see Github issue https://github.com/woothemes/woocommerce/issues/5512 and must have gotten some help from a developer per e-mail.
function kill_defaults($tags) {
return array();
}
add_filter( 'woocommerce_email_style_inline_tags', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_h1_tag', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_h2_tag', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_h3_tag', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_a_tag', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_img_tag', 'kill_defaults', 20 );
function my_email_style_inline_tags($tags) {
if (!in_array('h2', $tags)) $tags[] = 'h2';
if (!in_array('h3', $tags)) $tags[] = 'h3';
if (!in_array('ul', $tags)) $tags[] = 'ul';
if (!in_array('li', $tags)) $tags[] = 'li';
return $tags;
}
add_filter('woocommerce_email_style_inline_tags', 'my_email_style_inline_tags', 30);
function my_email_style_inline_h2_tag($styles) {
$styles['font-size'] = '1em';
$styles['font-family'] = 'Arial, sans-serif';
$styles['font-weight'] = 'bold';
return $styles;
}
function my_email_style_inline_ul_tag($styles) {
$styles['margin-left'] = '1em';
$styles['padding-left'] = '0';
$styles['list-style'] = 'none';
return $styles;
}
function my_email_style_inline_h3_tag($styles) {
$styles['font-size'] = '1em';
$styles['margin-bottom'] = '0';
$styles['font-weight'] = 'normal';
$styles['font-family'] = 'Arial, sans-serif';
return $styles;
}
function my_email_style_inline_li_tag($styles) {
$styles['margin-left'] = '0';
return $styles;
}
add_filter('woocommerce_email_style_inline_h2_tag', 'my_email_style_inline_h2_tag', 30);
add_filter('woocommerce_email_style_inline_h3_tag', 'my_email_style_inline_h3_tag', 30);
add_filter('woocommerce_email_style_inline_ul_tag', 'my_email_style_inline_ul_tag', 30);
add_filter('woocommerce_email_style_inline_li_tag', 'my_email_style_inline_li_tag', 30);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment