Skip to content

Instantly share code, notes, and snippets.

View levantoan's full-sized avatar

Lê Văn Toản levantoan

View GitHub Profile
@levantoan
levantoan / remove text (free) if cost 0.php
Last active October 17, 2015 05:15
Hides the 'Free!' price notice woocomerce
<?php
//Remove (Free) label on cart page for "Shipping and Handling" if cost is $0
function sv_change_cart_shipping_free_label( $label ) {
$label = str_replace( "(Free)", " ", $label );
return $label;
}
add_filter( 'woocommerce_cart_shipping_method_full_label' , 'sv_change_cart_shipping_free_label' );
@levantoan
levantoan / ShortCode-Gist.php
Last active October 17, 2015 16:40
Add gist to wordpress. single and multi file
<?php
//add shortoce gist to wordpress
//Use [gist id="" file=""]
/*
EX: https://gist.github.com/fae35ed5bf667d968a68#file-shortcode-gist-php
=> shortcode: [gist id="fae35ed5bf667d968a68" file="ShortCode-Gist.php"]
*/
function gist_func( $atts ){
$atts = shortcode_atts( array(
php_value max_input_vars 7000
into my .htaccess file and all works now.
@levantoan
levantoan / functions.php
Created October 20, 2015 03:52
Thêm style cho IE trong wordpress
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
function enqueue_my_styles() {
global $wp_styles;
// Load the main stylesheet
wp_enqueue_style( 'my-theme', get_stylesheet_uri() );
/**
@levantoan
levantoan / Add span to each word.html
Created October 21, 2015 07:37
Add span to each word
<div class="text">123456</div>
<style>
span{
color: red;
}
</style>
<script>
$('.text').each(function(){
var text = $(this).html().split(''),
len = text.length,
@levantoan
levantoan / Remove_Admin_Menu_Set_User_Special.php
Created October 22, 2015 15:02
Ẩn menu đối với một số user nhất định
<?php
/*
Add this code to functions.php
*/
function remove_admin_menu()
{
//except list user
$admins = array(
'admin',
);
@levantoan
levantoan / Scroll_to_element.js
Created October 30, 2015 09:35
Scroll to element to active
$(window).scroll(function(){
var window_top = $(window).scrollTop();
var div_top = $(".number_counter").offset().top + 50; // Change class .number_counter
var window_height = $(window).height();
if (window_top + window_height >= div_top) {
//Code here
}
});
<?php
/*
Add to functions.php
*/
function comment_validation_init() {
if(is_singular() && comments_open() ) { ?>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#commentform').validate({
@levantoan
levantoan / wp_redirect_has_shortcode.php
Created November 6, 2015 03:13
Chuyển hướng tới trang khác khi post có shortcode nào đó
<?php
function my_page_template_redirect(){
global $post;
if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'your_short_code') && ! is_user_logged_in() ) {
wp_redirect(URL_IN_HERE);
exit();
}
}
add_action( 'template_redirect', 'my_page_template_redirect' );
@levantoan
levantoan / fancybox_jump_to_top.txt
Created December 30, 2015 02:29
Sửa lỗi khi click vào fancybox bị nhảy lên top
/*Nếu khi click vào thẻ a bật fancybox mà bị nhảy lên đầu trang thì bạn thêm đoạn script này vào là ok*/
helpers: {
overlay: {
locked: false
}
}
Ví dụ thực tế: