Skip to content

Instantly share code, notes, and snippets.

View jordantrizz's full-sized avatar

Jordan jordantrizz

View GitHub Profile
@erfan-ilyas
erfan-ilyas / filter-http-api.php
Created October 6, 2022 14:39
WP pre_http_request filter to disable selected premium plugins update check.
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'admin_init', function(){
add_filter( 'pre_http_request', 'july2122522_pre_http_request', 999, 3 );
@mrcave
mrcave / clear_cache_when_stock_changes.php
Last active October 25, 2023 12:12
Clear NGINX page cache when WooCommerce product inventory levels are changed (only tested on GridPane with Redis page caching enabled)
//clear entire cache when stock is reduced or replenished
function clear_cache_when_stock_changes( $order ) {
if(class_exists('PhpRedis_Purger') || class_exists('Predis_Purger')){
global $nginx_purger;
$nginx_purger->purge_all();
}
}
@anthumchris
anthumchris / README.md
Last active September 25, 2022 19:04
Clear Nginx Cache

Clearing Nginx's HTTP Cache

I recently implemented Nginx HTTP content caching on our WordPress web servers to improve page load speeds and eliminate redundant, unneeded server-side page rendering. Caching the pages was relatively straightforward, but clearing the cache required a custom workaround.

Nginx comes in two versions: free and “Nginx Plus” at $2,500/year. The free version of Nginx does not offer the needed cache-clearing features of Nginx Plus, and I wasn’t comfortable paying $20,000 for 8 instances without trying to build my own solution.

Our Nginx servers run as an HTTP proxy for multiple PHP/MySQL-backed WordPress sites. The goal was to cache the dynamic PHP HTML responses in Nginx and serve the HTML pages from Nginx to avoid redundant, CPU-intensive PHP renders.

Site Cache Configuration

The example below shows how PHP response caching is configured for a site (other nginx configuration details are excluded for brevity). A cache named cachedemo-prod is defined to store cached HTML f

@JonTheWong
JonTheWong / ovh-centos7-hostname
Last active January 30, 2020 18:25
OVH - CentOS 7 - Change Hostname
I'm writting this gist for anyone who is having problems updating their OVH Public Cloud hostname on CentOS 7
The issue:
When ordering a public cloud instance and setting the instance name to sub.domain.tld and then eventually changing that sub
the settings don't seem to update on OVH side.
It looks like systemd-hostnamed still pulls the original hostname from what i'm guessing is the datastore on OpenStack. (unconfirmed)
The solution:
<?php
// Don't disable on dev
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
// Disable core update checking
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
remove_action( 'admin_init', '_maybe_update_core' );
remove_action( 'wp_version_check', 'wp_version_check' );
@ocean90
ocean90 / fbcbfwss.php
Last active February 11, 2023 22:03
WordPress Plugin: Filename-based cache busting for scripts/styles.
<?php
/**
* Plugin Name: Filename-based cache busting
* Version: 0.3
* Description: Filename-based cache busting for WordPress scripts/styles.
* Author: Dominik Schilling
* Author URI: https://dominikschilling.de/
* Plugin URI: https://gist.github.com/ocean90/1966227/
*
* License: GPLv2 or later