Skip to content

Instantly share code, notes, and snippets.

View tiendungdev's full-sized avatar

Tien Dung Dao tiendungdev

View GitHub Profile
@nbeguier
nbeguier / nginx.conf
Last active June 26, 2024 16:13
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 July 2, 2024 10:04
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 July 6, 2024 20:26
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

@holmberd
holmberd / php-pools.md
Last active July 22, 2024 01:42
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@bjornjohansen
bjornjohansen / maintenance.php
Created August 31, 2017 11:57
Custom WordPress maintenance mode page
<?php
wp_load_translations_early();
$protocol = wp_get_server_protocol();
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Retry-After: 30' );
?>
<!DOCTYPE html>
<html>
@keesiemeijer
keesiemeijer / wp-update
Last active June 25, 2024 03:23
A bash script to update everything WordPress (core, plugins, themes and comments).
#!/usr/bin/env bash
# =============================================================================
#
# *** WARNING: THIS SCRIPT IS NO LONGER MAINTAINED ***
#
# use https://github.com/keesiemeijer/wp-update instead
#
# =============================================================================