Skip to content

Instantly share code, notes, and snippets.

Nam NCN namncn

View GitHub Profile
View google-analytics.php
add_action('wp_head', 'prefix_add_googleanalytics');
function prefix_add_googleanalytics() { ?>
// Paste your Google Analytics code from Step 4 here
<?php }
View enable-gzip-nginx.htaccess
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_vary on;
gzip_types text/plain text/css text/javascript image/svg+xml image/x-icon application/javascript application/x-javascript;
View enable-gzip-apache.htaccess
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
View woocommerce-cart-checkout-style.css
.woocommerce .col2-set .col-1, .woocommerce-page .col2-set .col-1, .woocommerce .col2-set .col-2, .woocommerce-page .col2-set .col-2 {
flex: 0 0 100%;
max-width: 100%;
/* Woocommerce Styles */
A couple things to note...
1. This code was written very specifically for my base child theme so it might not work out of the box with every theme.
View remove-category-or-custom-taxonomy-slugs-from-url.php
* Change Term Request.
function pdvn_change_term_request( $query ) {
$tax_name = 'product_cat'; // specify you taxonomy name here, it can be also 'category' or 'post_tag'
// Request for child terms differs, we should make an additional check
if ( $query['attachment'] ) :
View remove-custom-post-type-slug-from-url.php
* Remove custom post type slug from URL.
function pdvn_remove_slug( $post_link, $post, $leavename ) {
if ( 'product' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
namncn / elementor-control.php
Created Jul 10, 2018
Tổng hợp các control của Elementor
View elementor-control.php
* TEXT control.
'label' => __( 'Title', 'elementor' ),
'type' => Controls_Manager::TEXT,
'dynamic' => [
View text.html
<div class="ncn_form-control">[text* your-name placeholder "Họ và Tên"]</div>
<div class="ncn_form-control">[email* your-email placeholder "Email của bạn"]</div>
<div class="ncn_form-control">[tel your-phone placeholder "Số điện thoại"]</div>
<div class="ncn_form-control">[textarea your-message placeholder "Điền nội dung bạn muốn gửi..."]</div>
<div class="ncn_form-submit">[submit "Gửi đi"]</div>
View ex
2.2.0: 001> require './math'
=> Đúng
2.2.0: 002> multiply_by_two 2
=> 4
2.2.0: 003> multiply_by_two -2
=> -4
2.2.0: 004> multiply_by_two
ArgumentError: Xin cung cấp một số hợp lệ
from /Users/bill/dev/math.rb:3:in 'multiply_by_two'
View ex
def multiply_by_two (n = "không có giá trị cung cấp")
if (n.is_a? (Integer))
n * 2
nâng ( "Xin vui lòng cung cấp một số hợp lệ")
You can’t perform that action at this time.