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 / 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 / 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 / add-metabox-to-taxonomy.php
Created July 14, 2017 09:16 — forked from ms-studio/add-metabox-to-taxonomy.php
simple but complete example of adding metabox to taxonomy - using WP 4.4 term meta functions
<?php
// source: http://wordpress.stackexchange.com/questions/211703/need-a-simple-but-complete-example-of-adding-metabox-to-taxonomy
// code authored by jgraup - http://wordpress.stackexchange.com/users/84219/jgraup
// REGISTER TERM META
add_action( 'init', '___register_term_meta_text' );
function ___register_term_meta_text() {
@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 / [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;
}
@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 / 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,
<?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){
<?php
/*
Array
(
[name] => Array
(
[0] => 0as
[1] => 1as
[2] => 2as
[3] => 3as
@levantoan
levantoan / instagram_get_recent_images_from_user_v1.php
Created May 28, 2016 02:12
Lấy ảnh mới nhất từ instagram của user thông qua access_token
<?php
/*instagram shortcode
* Get access_token to http://instagram.pixelunion.net/
* Or place [CLIENT_ID_HERE] to your Client ID => https://instagram.com/oauth/authorize/?client_id=[CLIENT_ID_HERE]&redirect_uri=http://localhost&response_type=token
Used: [instagram_widget access_token="_Your Access Token_" show="20"]
by: www.levantoan.com
* */
function scrape_instagram($access_token = '', $slice = 20, $type = "image") {