added validation when save the frontend colors, closes #5298

This commit is contained in:
claudiosmweb 2014-04-08 19:08:04 -03:00 committed by Mike Jolley
parent 6fa57f707d
commit a0ac62efca
1 changed files with 17 additions and 4 deletions

View File

@ -289,13 +289,26 @@ class WC_Settings_General extends WC_Settings_Page {
'subtext' => $subtext
);
// Check the colors.
$valid_colors = true;
foreach ( $colors as $color ) {
if ( ! preg_match( '/^#[a-f0-9]{6}$/i', $color ) ) {
$valid_colors = false;
WC_Admin_Settings::add_error( sprintf( __( 'Error saving the Frontend Styles, %s is not a valid color, please use only valid colors code.', 'woocommerce' ), $color ) );
break;
}
}
if ( $valid_colors ) {
$old_colors = get_option( 'woocommerce_frontend_css_colors' );
update_option( 'woocommerce_frontend_css_colors', $colors );
if ( $old_colors != $colors )
if ( $old_colors != $colors ) {
woocommerce_compile_less_styles();
}
}
}
}
}