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 / Default.html
Last active November 11, 2019 14:36
remove and change style wordpress admin bar
<style type="text/css" media="screen">
html { margin-top: 32px !important; }
* html body { margin-top: 32px !important; }
@media screen and ( max-width: 782px ) {
html { margin-top: 46px !important; }
* html body { margin-top: 46px !important; }
}
</style>
@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,
<?php
/*
* Add to functions.php
* Add div.videoWrapper to iframe
*/
function div_wrapper($content) {
// match any iframes
/*$pattern = '~<iframe.*</iframe>|<embed.*</embed>~'; // Add it if all iframe*/
$pattern = '~<iframe.*src=".*(youtube.com|youtu.be).*</iframe>|<embed.*</embed>~'; //only iframe youtube
preg_match_all($pattern, $content, $matches);
@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 / WP_Query_by_meta_value_date.php
Last active February 2, 2018 11:45
Query and order custom post by meta value date format
<?php
$arg = array(
'post_type' => 'events',//thay bằng post type của bạn
'posts_per_page' => 3,
'orderby' => 'meta_value',
'meta_key' => 'start_date_event',//thay bằng meta key của bạn
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'start_date_event',//thay bằng meta key của bạn
@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
}
});