Skip to content

Instantly share code, notes, and snippets.

View wpbullet's full-sized avatar
💭
Find me https://guides.wp-bullet.com/codeable-hire

WP Bullet wpbullet

💭
Find me https://guides.wp-bullet.com/codeable-hire
View GitHub Profile
<?php
/**
* WordPress menu cache.
*
* @package BJ\Menu
* @author bjornjohansen
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@synio-wesley
synio-wesley / sync_cf_dns.py
Last active April 9, 2023 22:34
Sync CloudFlare DNS based on JSON file
"""
This is a simple Python 3 script to sync all CloudFlare DNS records based on a JSON file.
Basically:
- It adds new domains if they aren't in CloudFlare yet
- For every domain: new DNS records will be added, existing records will be updated and records not existing in the JSON will be deleted
By default the script only does a dry run (simulation). Run the script with parameter "execute" to execute it.
If you only want to add/update some domains, fill in the "only" key in the JSON file with an array of domains you want to add/update.
@wpbullet
wpbullet / wp-profile-doctor.sh
Last active May 5, 2021 13:24
Autoinstall wp profile and doctor
#!/bin/bash
php -d memory_limit=-1 $(which wp) package install wp-cli/profile-command:@stable --allow-root
php -d memory_limit=-1 $(which wp) package install wp-cli/doctor-command:@stable --allow-root
@GeekPress
GeekPress / cache-woo-get-refreshed-fragment-request.php
Last active July 25, 2019 09:58
Cache WooCommerce Get Refreshed Fragment Request
<?php
if ( isset( $_GET['wc-ajax'] ) && 'get_refreshed_fragments' === $_GET['wc-ajax'] && ( !isset( $_COOKIE['woocommerce_cart_hash'] ) || empty( $_COOKIE['woocommerce_cart_hash'] ) ) && ( !isset( $_COOKIE['woocommerce_items_in_cart'] ) || empty( $_COOKIE['woocommerce_items_in_cart'] ) ) ) {
$data = get_transient( 'rocket_get_refreshed_fragments_cache' );
if ( ! empty( $data ) ) {
$data = json_decode( $data );
wp_send_json( $data );
}
ob_start();
@CatEntangler
CatEntangler / elasticpress_posttype_weighting.php
Last active December 2, 2020 16:40
weighting by post_type using ElasticPress
function SetSearchArgs( $formattedArgs, $args = [] ) {
if( isset( $args[ 'post_type' ] ) && ( count( $args[ 'post_type' ] ) > 1 || gettype( $args[ 'post_type' ] ) === 'string' ) ) {
if( gettype( $args[ 'post_type' ] ) === 'array' ) {
$existing_query = $formattedArgs[ 'query' ];
unset( $formattedArgs[ 'query' ] );
@lukecav
lukecav / Articles
Created February 16, 2018 17:10
Easy Digital Downloads - Performance/Caching
http://docs.easydigitaldownloads.com/article/1054-caching-issues
http://docs.easydigitaldownloads.com/article/993-cloudflare
http://docs.easydigitaldownloads.com/article/190-payments-not-marked-as-complete
http://docs.easydigitaldownloads.com/article/297-wp-super-cache
http://docs.easydigitaldownloads.com/article/1874-preventing-empty-cart-messages-with-varnish
https://wordpress.org/plugins/simple-cache/
https://deliciousbrains.com/page-caching-personalized-dynamic-content/
@lukecav
lukecav / functions.php
Created December 20, 2017 22:08
Fix a race condition in alloptions caching in WordPress
/**
* Fix a race condition in alloptions caching
*
* See https://core.trac.wordpress.org/ticket/31245
*/
function _wpcom_vip_maybe_clear_alloptions_cache( $option ) {
if ( ! wp_installing() ) {
$alloptions = wp_load_alloptions(); //alloptions should be cached at this point
if ( isset( $alloptions[ $option ] ) ) { //only if option is among alloptions
wp_cache_delete( 'alloptions', 'options' );
@lucaswerkmeister
lucaswerkmeister / dumpMemcached
Created September 25, 2017 17:03
pure Bash script to dump all keys in a memcached server
#!/bin/bash
# connect to memcached
exec 3<>/dev/tcp/"${1:-localhost}"/"${2:-11211}" || exit $?
# get slab numbers
printf 'stats slabs\r\n' >&3
slabnums=()
while IFS=' :' read -r stat slabnum _; do
if [[ $stat == $'END\r' ]]; then
<?php
define('INBOUND_FAST_AJAX' , true );
/**
* Enable Fast Ajax
*/
add_filter( 'option_active_plugins', 'ajax_disable_plugins' );
function ajax_disable_plugins($plugins){
@lukecav
lukecav / .htaccess
Last active September 18, 2017 23:08
Powered Cache - .htaccess
# BEGIN POWERED CACHE
<IfModule mod_mime.c>
AddType image/jpeg .jpg .jpeg .jpe
AddType image/gif .gif
AddType image/png .png
AddType image/bmp .bmp
AddType image/tiff .tiff .tif
AddType image/x-icon .ico
AddType video/x-ms-asf .asf .asx
AddType video/x-ms-wmv .wmv