Skip to content

Instantly share code, notes, and snippets.

View trongcong's full-sized avatar
🏠
Working from home

Nguyen Trong Cong trongcong

🏠
Working from home
View GitHub Profile
@trongcong
trongcong / trace.js
Created October 24, 2020 08:36 — forked from mikesmullin/trace.js
Node.JS print filename and line number prefixed to console log output
const path = require('path');
function trace(s) {
const orig = Error.prepareStackTrace;
Error.prepareStackTrace = (_, stack) => stack;
const err = new Error();
Error.captureStackTrace(err, arguments.callee);
Error.prepareStackTrace = orig;
const callee = err.stack[0];
process.stdout.write(`${path.relative(process.cwd(), callee.getFileName())}:${callee.getLineNumber()}: ${s}\n`);
//============
//Add woo custom field
add_action( 'woocommerce_product_options_advanced', 'ntc_add_custom_field_product_dashboard_advanced_tab' );
function ntc_add_custom_field_product_dashboard_advanced_tab() {
global $post;
$custom_price_form_product_option = get_post_meta( $post->ID, '_custom_price_form_of_product', true );
echo '<div class="options_group ">';
// Checkbox Field
woocommerce_wp_checkbox( array(
@trongcong
trongcong / functions.php
Created February 7, 2020 07:15 — forked from maddisondesigns/functions.php
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@trongcong
trongcong / .gitignore
Created June 13, 2018 10:21 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@trongcong
trongcong / custom-past-events.php
Created February 1, 2018 02:53 — forked from jo-snips/custom-past-events.php
The Events Calendar: Custom Query for Past Events
<?php
global $post;
$get_posts = tribe_get_events(array('posts_per_page'=>-1, 'eventDisplay'=>'past') );
foreach($get_posts as $post) { setup_postdata($post);
?>
<?php if ( has_post_thumbnail() ) { ?>
@trongcong
trongcong / gist:065904f0d88a39d9fba5928aab29f190
Created September 25, 2017 10:05 — forked from thachpham92/gist:d57b18cf02e3550acdb5
Tất cả các tham số trong WP_Query
// Source: https://gist.github.com/luetkemj/2023628
// Xem hướng dẫn WP_Query toàn tập: http://goo.gl/kRpzTz
<?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ả
@trongcong
trongcong / .htaccess
Last active January 22, 2019 15:35
Wordpress login to download uploaded files | Protect uploaded files with login | Edit by trongcong
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^wp-content/uploads/(.*)$ dl-file.php?file=$1 [QSA,L]