Skip to content

Instantly share code, notes, and snippets.

View tiendungdev's full-sized avatar

Tien Dung Dao tiendungdev

View GitHub Profile
@faisalahammad
faisalahammad / woocommerce-login-with-phone-or-email.php
Created September 4, 2024 06:00
Enable WooCommerce users to log in using either their phone number or email address. This code snippet overrides the default WooCommerce login logic, allowing for flexible login options and improving the user experience on the account login page.
<?php
/**
* Woocommerce Add Phone Number To Login Account
* @author Faisal Ahammad
*/
// Enable login with phone number or email
add_filter( 'authenticate', 'login_with_phone_or_email', 20, 3 );
@faisalahammad
faisalahammad / woocommerce-account-signup-with-phone-number.php
Created September 4, 2024 05:57
Add a phone number field to the WooCommerce account registration form. This code snippet validates and saves the phone number during user sign-up, allowing users to register with both a phone number and email address for enhanced account creation.
<?php
/**
* Woocommerce Add Phone Number Field To Registration Form
* @author Faisal Ahammad
*/
add_action( 'woocommerce_register_form', 'add_phone_field_to_registration' );
function add_phone_field_to_registration()
@nbeguier
nbeguier / nginx.conf
Last active November 6, 2024 09:51
Nginx: TLS Security Configuration 2023
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name __REDACTED__;
ssl_certificate __REDACTED__ ;
ssl_certificate_key __REDACTED__;
# Only return Nginx in server header
server_tokens off;
@isaumya
isaumya / cf_cache_rules_implementation_guide_spcc.md
Last active April 7, 2025 10:24
Super Page Cache for Cloudflare — Guide for using Remove Cache Buster Query Parameter feature (when using Cache Everything page rule)

Implementation Guide for using "Remove Cache Buster Query Parameter" feature

The Super Page Cache for Cloudflare plugin has recently added the feature for using the Cache Everything pagerule withing the ?swcfpc=1 cache buster query paramater. This opens up so many new doors where users previously had to use the Cloudflare Workers to remove the cache buster.

With this new option now users are able to take advantage of Cloudflare Cache Everything page rule and take it to the next level by using the new Rulesets released by Cloudflare. Basically this is achived by taking advantage of the all new Cache Rules feature implemented by Cloudflare.


Setp 1 — Setting up the Cache Rules inside your Cloudflare Dashboard

The first thing that you need to do is, log-in to your Cloudflare Dahsbord and go to the domain/zone doe which you are setting up the [Super Page Cache for Cloudflare](https://wordpress.org/plug

@nfsarmento
nfsarmento / functions.php
Created October 1, 2021 10:06
Custom contact form shortcode - used for custom product enquiry on WooCommerce
/**
*
* Shortcode contact form
*/
// @codingStandardsIgnoreStart
function decorativefair_shortcode_product_form($item) {
ob_start();
global $post, $product;
$author_name = get_the_author_meta( 'user_email', $product->post->post_author );
@Prroffessorr
Prroffessorr / 1 functions.php
Created June 1, 2021 14:09
WordPress Пример фильтрации с множественными значения (Множество параметров, Отображение в начале списка в зависимости от значения, Строгое следования условиям )
<?php
//Все такосномии этом примере были созданы отедельно. в WP таких изначально нет. Имейте это в виду
//Получам все параметры (В нашем случае это все массивы, поэтому сначала их нужно будет подготовить к работе)
$clubs_city = $_POST['city'];
$clubs_metro = $_POST['metro'];
$clubs_ages = $_POST['ages'];
$clubs_price = $_POST['price'];
//Получаем _clubs_organization_adress_metro
@ylkyrg
ylkyrg / optimise-google-fonts.php
Created July 5, 2020 16:02
WordPress plugin to optimise google fonts.
<?php
/**
* Plugin Name: Optimise Google Fonts
* Description: Add optimisations for loading Google Fonts.
* Version: 0.1.0
* Author: Gary Kealy
* Author URI: https://garykealy.dev
* License: GNU General Public License v2 or later
*/
@nfsarmento
nfsarmento / nginx-wordpress.conf
Last active March 26, 2025 13:12
Harden wordpress security nginx
############ WordPress ####################
# Disable logging for favicon and robots.txt
location = /favicon.ico {
try_files /favicon.ico @empty;
access_log off;
log_not_found off;
expires max;
}
@minhazulOO7
minhazulOO7 / 0-Cloudflare DDNS using Bash Script with Crontab or Systemd Timer-readme.md
Last active April 23, 2022 01:23
Cloudflare Client API v4 DDNS IP Update Using Bash Script (IPv4/ IPv6)

Cloudflare DDNS using Bash Script with Crontab/ Systemd Timer

This script will check if external IP is changed or not and will update the external IP of A or AAAA record in Cloudflare DNS using API token/ global API key method.

Script Requirements

@bouroo
bouroo / 60-sysctl.conf
Last active March 30, 2025 05:01
Kernel tuning for dedicated linux server. /etc/sysctl.d/60-sysctl.conf
# Sysctl Configuration for High-Performance such as API/Web Server
# Kawin Viriyaprasopsook <[email protected]>
# place file in /etc/sysctl.d/60-sysctl.conf
# and run `sysctl --system`
# --------------------------------------------------------------------
# System options
# --------------------------------------------------------------------
# Reduce kernel messages on console (3 4 1 3)