Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@duongthanhthai
Created October 25, 2019 09:19
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 duongthanhthai/164ceae3aefac42530dcfa9e32ef924a to your computer and use it in GitHub Desktop.
Save duongthanhthai/164ceae3aefac42530dcfa9e32ef924a to your computer and use it in GitHub Desktop.
Disabling the entire 'reviews' tab on a product's WooCommmerce page, add this to your functions.php file in Wordpress.
add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 );
function wcs_woo_remove_reviews_tab($tabs) {
unset($tabs['reviews']);
return $tabs;
}
@duongthanhthai
Copy link
Author

Function validate SĐT ở Contact Form 7. Update các đầu số di động của VN

function thai_validate_sdt( $result, $tag ) {
$name = $tag->name;
$value = isset( $_POST[$name] ) ? trim( wp_unslash( strtr( (string) $_POST[$name], "\n", " " ) ) ) : '';
$errorMessage = 'Số điện thoại không hợp lệ!';
if ( 'tel' == $tag->basetype ) {
if( !preg_match('/^(032|033|034|035|036|037|038|039|086|096|097|098|081|082|083|084|085|088|091|094|056|058|092|070|076|077|078|079|089|090|093|099|059)+([0-9]{7})$/', $value ) ){
$result->invalidate( $tag, $errorMessage );
}
}
return $result;
}
add_filter('wpcf7_validate_tel*', 'tmdev_validate_sdt', 10, 2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment