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 / [Support-WPML]set_product_category_base_same_shop_base.php
Last active December 15, 2023 07:06
How to set product category base the same as shop base in WooCommerce
<?php
/*
Support WPML - 25/02/2019
/*
function devvn_product_category_base_same_shop_base( $flash = false ){
global $sitepress;
$languages = icl_get_languages('skip_missing=0&orderby=code');
if($languages && !empty($languages)){
$original_lang = ICL_LANGUAGE_CODE;
foreach($languages as $key=>$lang) {
@levantoan
levantoan / autocomplete.php
Last active September 14, 2023 15:04
Add price to Wp Search With Algolia
<?php
/**
* WP Search With Algolia autocomplete template file.
* Edit by levantoan.com
*
* @author WebDevStudios <contact@webdevstudios.com>
* @since 1.0.0
*
* @version 2.5.3
* @package WebDevStudios\WPSWA
@levantoan
levantoan / [OLD]-remoce-product-category-parent.php
Last active November 19, 2022 05:50
Remove product-category and all parents slug product category in link Woocommerce
<? php
// Remove product cat base
add_filter('term_link', 'devvn_no_term_parents', 1000, 3);
function devvn_no_term_parents($url, $term, $taxonomy) {
if($taxonomy == 'product_cat'){
$term_nicename = $term->slug;
$url = trailingslashit(get_option( 'home' )) . user_trailingslashit( $term_nicename, 'category' );
}
return $url;
}
<?php
/*
* Code Bỏ /product/ hoặc /cua-hang/ hoặc /shop/ ... có hỗ trợ dạng %product_cat%
* Thay /cua-hang/ bằng slug hiện tại của bạn
*/
function devvn_remove_slug( $post_link, $post ) {
if ( !in_array( get_post_type($post), array( 'product' ) ) || 'publish' != $post->post_status ) {
return $post_link;
}
if('product' == $post->post_type){
@levantoan
levantoan / Fix_vc.php
Last active November 29, 2020 12:11
Fix $template.get is not a function in VC when updated WordPress to 4.5
<?php
/*
Find html2element in
Version < 4.8: /wp-content/plugins/js_composer/assets/js/backend/composer-view.js
Version > 4.9: wp-content/plugins/js_composer/assets/js/dist/backend-actions.min.js
*/
html2element: function(html) {
var attributes = {},
$template;
if (_.isString(html)) {
@levantoan
levantoan / remove-category-and-parent-category.php
Created June 10, 2017 03:41
Remove /category/ and parent category slug
<?php
/*
* Author: Le Van Toan
* Link more update: http://levantoan.com/xoa-bo-category-va-slug-category-cha-khoi-duong-dan-category/
*/
// Remove Parent Category from Child Category URL
add_filter('term_link', 'devvn_no_category_parents', 1000, 3);
function devvn_no_category_parents($url, $term, $taxonomy) {
if($taxonomy == 'category'){
$term_nicename = $term->slug;
@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 / pmt.js
Created February 12, 2019 09:28 — forked from maarten00/pmt.js
Excel PMT in PHP and JavaScript
/**
* Copy of Excel's PMT function.
* Credit: http://stackoverflow.com/questions/2094967/excel-pmt-function-in-js
*
* @param rate_per_period The interest rate for the loan.
* @param number_of_payments The total number of payments for the loan in months.
* @param present_value The present value, or the total amount that a series of future payments is worth now;
* Also known as the principal.
* @param future_value The future value, or a cash balance you want to attain after the last payment is made.
* If fv is omitted, it is assumed to be 0 (zero), that is, the future value of a loan is 0.
@levantoan
levantoan / them_tang_giam.css
Created February 15, 2017 16:14
Thêm nút tăng giảm số lượng sản phẩm khi thêm vào giỏ hàng
/*
web: http://levantoan.com
*/
.woocommerce #quantity input::-webkit-outer-spin-button,
.woocommerce #quantity input::-webkit-inner-spin-button,
.woocommerce #content .quantity input::-webkit-outer-spin-button,
.woocommerce #content .quantity input::-webkit-inner-spin-button, .woocommerce-page #quantity input::-webkit-outer-spin-button,
.woocommerce-page #quantity input::-webkit-inner-spin-button,
.woocommerce-page #content .quantity input::-webkit-outer-spin-button,
@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