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
$('.mobile-toggle a').on('click', function(e) {
e.preventDefault();
$('.mobile-nav-overlay').fadeIn(400, function() {
$('.mobile-nav-outer').addClass('opened');
});
});
$('.mobile-nav-overlay .close-button').on('click', function(e) {
e.preventDefault();
$('.mobile-nav-outer').removeClass('opened');
<?php if (!defined('FW')) die('Forbidden');
$cfg = array();
$cfg['page_builder'] = array(
'title' => __('Danh sách Đại Lý', 'fw'),
'title_template' => '{{- title}}: {{- o.title}}',
'tab' => __('DTA', 'fw'),
);
<?php
// Add to cart checkout redirect
function custom_add_to_cart_redirect() {
$checkout_ = get_permalink( get_option( 'woocommerce_checkout_page_id' ) );
return $checkout_
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
@trangsihung
trangsihung / zip.php
Created October 10, 2016 07:19
PHP Scritps
<?php
$dir = 'uploads';
$zip_file = 'uploads.zip';
// Get real path for our folder
$rootPath = realpath($dir);
// Initialize archive object
$zip = new ZipArchive();
@trangsihung
trangsihung / gist:8a9b7efea7226879393adbcbb431dc5f
Created August 23, 2016 02:29 — forked from mikejolley/gist:2176823
WooCommerce - Show products from current product category (when viewing a single product)
<?php
if ( is_singular('product') ) {
global $post;
// get categories
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $cats_array[] = $term->term_id;
<?php
function _split_product_size() {
$term_need_delete = array();
$q = new WP_Query(array(
'post_type' => 'product',
'posts_per_page' => -1,
'order' => 'DESC',
'meta_query' => array(
@trangsihung
trangsihung / wp_update_term.php
Created December 29, 2015 03:11 — forked from hinnerk-a/wp_update_term.php
Using wp_update_term properly for setting parent terms in hierarchical taxonomies
<?php
// set terms
wp_set_object_terms( $post_id, $object_types, 'immomakler_object_type', true );
// make terms hierarchial by objektart
$term_parent = get_term_by( 'slug', $openimmo_data['objektart'], 'immomakler_object_type' );
$term_child = get_term_by( 'slug', $openimmo_data['objektart_detail'], 'immomakler_object_type' );
delete_option( 'immomakler_object_type_children' ); // workaround for WordPress not updating this option properly
@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
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@trangsihung
trangsihung / gist:8054574
Created December 20, 2013 13:11 — forked from Dimox/dimox_breadcrumbs.php
dimox breadcrumbs
<?php
function dimox_breadcrumbs() {
/* === OPTIONS === */
$text['home'] = 'Home'; // text for the 'Home' link
$text['category'] = 'Archive by Category "%s"'; // text for a category page
$text['search'] = 'Search Results for "%s" Query'; // text for a search results page
$text['tag'] = 'Posts Tagged "%s"'; // text for a tag page
$text['author'] = 'Articles Posted by %s'; // text for an author page