Skip to content

Instantly share code, notes, and snippets.

View minimal-analytics-snippet.js
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
cp6 / bunnycdn_storage.php
Last active Jan 3, 2021
Bunny CDN Storage API format
View bunnycdn_storage.php
function storage($key, $dir = '')
return json_decode(file_get_contents("" . $dir . "/?AccessKey=" . $key . ""), true);
$items = array('data' => array());
foreach ($array as $value) {
jay7793 /
Last active May 5, 2021
Install Laravel 5.6 With PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa
sudo apt-get update
# Install nginx
AnthumChris /
Last active Jul 8, 2021
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

isuke01 / custom-wp.ajax
Last active Nov 18, 2019
Custom WP ajax, capable of using SHORTINIT, and much faster than standard WP
View custom-wp.ajax
If you use short init by passing argument shortinit.
You have base and a bit more wp components loaded, like get_meta, current user .. etc.
if (!isset( $_POST['action']))
if ( isset( $_POST['shortinit']) ){
$type = trim($_POST['shortinit']);
View Custom List Table With Database Example.php
Plugin Name: Custom List Table With Database Example
Description: A highly documented plugin that demonstrates how to create custom admin list-tables from database using WP_List_Table class.
Version: 1.0
Author: Viramgami Jignesh
Author URI:
License: GPL2
heiswayi / fm.php
Created Oct 25, 2017
Single PHP File Manager Script - Screenshot:
View fm.php
* File Manager Script
// Default language ('en' and other from 'filemanager-l10n.php')
$lang = 'en';
// Auth with login/password (set true/false to enable/disable it)
$use_auth = true;
hanshsieh /
Last active Jun 10, 2020
Google Sign-in Example
import java.util.Collections;
* Hello world!
View admin.js
$('#update-cat-featured-img, #add-cat-featured-img').click(function(e) {
var custom_uploader ={
title: 'Featured Image',
button: {
text: 'Insert image'
multiple: false // Set this to "add" to allow multiple files to be selected
ahmadawais / upload-a-file.MD
Created Jun 18, 2017 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API
View upload-a-file.MD

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle: