Skip to content

Instantly share code, notes, and snippets.

View gizalink's full-sized avatar

Nguyễn Phúc Gia Linh gizalink

View GitHub Profile
<?php
/*
Đặt code này vào file functions.php của theme
Tác giả: klihelp
Fixed by: alexandreleroux
Chức năng: hiển thị phân trang cho sản phẩm WooCommerce khi dùng shortcode riêng lẻ
*/
if ( ! is_admin() ) {
// ---------------------- FRONTPAGE -------------------
@gizalink
gizalink / gist:f14c0b02cd307eec4ef5
Last active October 13, 2015 09:22 — forked from thachpham92/gist:d57b18cf02e3550acdb5
Tất cả các tham số trong WP_Query
// Source: https://gist.github.com/luetkemj/2023628
<?php
$args = array(
//////Author Parameters - Tham số lấy bài viết theo tác giả
//http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters
'author' => '1,2,3,', //(int) - Các ID tác giả cần lấy bài viết (thêm dấu - vào để loại trừ tác giả, ví dụ: -14, -20)
'author_name' => 'luetkemj', //(string) - Lấy bài viết dựa theo tên nick name của tác giả
'author__in' => array( 2, 6 ), //(array) - Lấy bài dựa theo ID của tác giả
'author__not_in' => array( 2, 6 ), //(array)' - Các ID của tác giả không muốn lấy bài
@gizalink
gizalink / check_new_product_woocommerce_wordpress.php
Last active September 22, 2015 13:06
Check Product is new (recent product)
<?php
// Function check product in woocommerce is new //
// Label "New" added after title product . Product on archive//
// Author: Nguyen Phuc Gia Linh //
// Contact: nguyenphucgialinh@gmail.com //
function check_id_last()
{
$args = array( 'numberposts' => '1' ,
'post_type' => 'product',
'orderby' => 'ID',
<?php
/*
Plugin Name: Default to GD
Plugin URI: http://wordpress.org/extend/plugins/default-to-gd
Description: Sets GD as default WP_Image_Editor class.
Author: Mike Schroder
Version: 1.0
Author URI: http://www.getsource.net/
*/
function ms_image_editor_default_to_gd( $editors ) {
@gizalink
gizalink / auto_cpanel_backup.php
Created October 25, 2015 06:47
Auto Backup Cpanel
<?php
/*
cPanel Backup Script
Author: Xeroday
*/
$auth = base64_encode("userhost:passhost");
$domain = "chi16.stablehost.com";
$theme = "paper_lantern";
$secure = true;
@gizalink
gizalink / delete-targz.php
Created October 25, 2015 06:47 — forked from Xeroday/delete-targz.php
Deletes .tar.gz files older than 7 days.
<?php
$files = glob("*.tar.gz");
foreach($files as $file) {
if(is_file($file)
&& time() - filemtime($file) >= 7*24*60*60) { // 7 days
unlink($file);
}
}
?>
@gizalink
gizalink / content-list_2_column.php
Last active October 26, 2015 01:47
Display post two column in archive and category page. Theme used Layerswp.
<?php
/**
* This template is used for displaying posts in post lists
* Path file: /childe-theme/partials
* Note: File name just content-list.php , remove _2_column
* View demo: https://drive.google.com/file/d/0B2Hg2fExEQHHQlRGLVRoZDNkVzA/view
* @package Layers
* @since Layers 1.0.0
*/
<?php
//Ham kiem tra, neu san pham khong co mieu ta se thay the bang tab mieu ta custom
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$id_product = get_the_id(); //get id product
$temp = get_post($id_product)->post_content; //get content
if($temp){ //kiem tra
return $tabs;
}else{
$tabs['description'] = array(
<?php
/*
* Remove button add to cart on Shop or Category product page
*/
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
add_action( 'woocommerce_after_shop_loop_item', 'callback_function' );
function callback_function()
{
<pre>
<?php echo var_dump(get_post_custom($post->ID)); ?>
</pre>