added validation when save the frontend colors, closes #5298
This commit is contained in:
parent
6fa57f707d
commit
a0ac62efca
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue