Skip to content

Instantly share code, notes, and snippets.

@Volnus
Volnus / wpcom-cdn.php
Last active April 27, 2020 15:48 — forked from zacscott/wpcom-cdn.php
Use the WP.com Photon image CDN without installing JetPack
<?php
/**
* Plugin Name: Photon CDN
* Version: 1.3
* Description: Use the WP.com Photon image CDN without installing JetPack
* Author: Scott Hartley
* Credit: Original by Zachary Scott
*/
namespace zacscott;
@GeekPress
GeekPress / ajax-cache.php
Created May 3, 2018 14:17
admin-ajax.php Request Cache
<?php
$cached_ajax_requests = array(
'your-action-here',
);
$cached_ajax_expiration_time = 7 * DAY_IN_SECONDS;
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], $cached_ajax_requests ) ) {
$request_id = get_rocket_request_uniqid_171286();
$data = get_transient( 'rocket_get_ajax_cache_' . $request_id );
@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();