Skip to content

Instantly share code, notes, and snippets.

View trangsihung's full-sized avatar
🏠
Working from home

Trang Sĩ Hưng trangsihung

🏠
Working from home
View GitHub Profile
@trangsihung
trangsihung / phone_check.js
Created October 26, 2022 03:24
Check đầu số di động việt nam
function checkPhoneFormat (phone) {
var prefix = [
'086',
'096',
'097',
'098',
'032',
'033',
'034',
'035',
@trangsihung
trangsihung / _blank.js
Created March 2, 2020 01:16 — forked from CrocoDillon/_blank.js
Automatically open external links in new tab or window.
// vanilla JavaScript
var links = document.links;
for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if (links[i].hostname != window.location.hostname) {
links[i].target = '_blank';
}
}
// or in jQuery
<?php
add_filter( 'vc_autocomplete_[shortcode_base]_[param_name]_callback', 'vc_autocomplete_taxonomies_field_search', 10, 1 );
add_filter( 'vc_autocomplete_[shortcode_base]_[param_name]_render', 'vc_autocomplete_taxonomies_field_render', 10, 1 );
$args = array(
'name' => 'Shortcode Name',
'base' => 'shortcode_base',
'category' => __( 'Themes Elements', 'vtm' ),
'params' => array(
array(
@trangsihung
trangsihung / disable_right_click.js
Last active March 8, 2019 09:18
reset masonry after ajax called
document.addEventListener('contextmenu', event => event.preventDefault());
@trangsihung
trangsihung / gist:bb5b420400eefdc16fb8517630ad602e
Last active October 14, 2018 03:41
WPML Enable Capabilities
<?php
function wpmlsupp_1706_reset_wpml_capabilities() {
if ( function_exists( 'icl_enable_capabilities' ) ) {
icl_enable_capabilities();
}
}
add_action( 'shutdown', 'wpmlsupp_1706_reset_wpml_capabilities' );
@trangsihung
trangsihung / woo_min_max_price.php
Created September 4, 2018 03:33
Get filtered min price for products
<?php
/* Source: woocommerce\includes\widgets\class-wc-widget-price-filter.php:119 */
function woo_get_filtered_price() {
global $wpdb;
$args = wc()->query->get_main_query()->query_vars;
$tax_query = isset( $args['tax_query'] ) ? $args['tax_query'] : array();
$meta_query = isset( $args['meta_query'] ) ? $args['meta_query'] : array();
if ( ! is_post_type_archive( 'product' ) && ! empty( $args['taxonomy'] ) && ! empty( $args['term'] ) ) {
<?php
// Upload image from url
// Returns an array (attachment_id, url), or false
function media_import_from_url( $url ) {
$filename = basename($url);
global $wpdb;
$query = "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%/$filename'";
$count = intval($wpdb->get_var($query));
<?php
// visual composer is enabled for a post/page
$vc_enabled = get_post_meta($post_id, '_wpb_vc_js_status', true);
@trangsihung
trangsihung / back-to-top.js
Last active December 7, 2017 02:35
jQuery Scripts
//Check to see if the window is top if not then display button
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('.scrollToTop').fadeIn();
} else {
$('.scrollToTop').fadeOut();
}
});
//Click event to scroll to top
@trangsihung
trangsihung / checkbox.css
Created December 4, 2017 07:23
css style
.checkbox {
input[type="checkbox"], input[type="radio"] { display: none; }
label {
position: relative;
padding-left: 20px;
&:before {
content: '';
width: 15px; height: 15px;
border: 1px solid #fff;