Woocommerce: Validating email colors settings

Created on 12 Oct 2017  Â·  3Comments  Â·  Source: woocommerce/woocommerce

Steps to reproduce the issue

  1. Change one of the emails colors at WooCommerce Settings -> Emails -> Base color to some invalid (or empty) value.
  2. Trigger an email or simply view email template preview.

Expected/actual behavior

Email colors input values should be validated to be the right HEX format.

Invalid color values (like ie. missing 6th character form HEX; some random text; empty string) cause invalid email template displaying. This means wrong css values are injected to email inline styles.

Also if WP_DEBUG constant is set to true, email template inline styles are not inserted to message HTML at all. Emails displays only simple browser-build styles, nothing fancy. Done some research and this looks like Emogrifier can't handle those styles to be injected having PHP notice like:

Notice: Uninitialized string offset: 5 in (…)/wp-content/plugins/woocommerce/includes/wc-formatting-functions.php on line 703

This bug exists in all of 4 email colors in admin settings screen.

Isolating the problem

  • [x] This bug happens with only WooCommerce plugin active
  • [x] This bug happens with a default WordPress theme active, or Storefront
  • [x] I can reproduce this bug consistently using the steps above
bug

Most helpful comment

@claudiulodro This is not new and minor. No rush to fix in 3.2.

All 3 comments

@claudiulodro This is not new and minor. No rush to fix in 3.2.

Function added for validate hexa color code PR : https://github.com/woocommerce/woocommerce/pull/17202

Thanks

Was this page helpful?
0 / 5 - 0 ratings