Skip to content

Instantly share code, notes, and snippets.

View sawwd's full-sized avatar
💭
What's happening?

Aprier sawwd

💭
What's happening?
View GitHub Profile
@sawwd
sawwd / class-walker-menu.php
Last active November 27, 2017 00:36
Standalone version of WordPress Menu Walker
<?php
class Walker_Menu {
public function __construct($elements) {
return $this->walk($elements, 0, array(
'menu' => '',
'container' => 'div',
'container_class' => 'menu-container',
'container_id' => '',
'menu_class' => 'menu',
@sawwd
sawwd / wp_mail.md
Created November 20, 2017 21:50 — forked from johnbillion/wp_mail.md
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This is accurate as of WordPress 4.9.

There are a few TODOs left. Please bear with me.

INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@sawwd
sawwd / gist:68a672e4bbb66fe1651e8cc7eb26cc69
Created November 20, 2017 22:04
Filters that you should add to Gmail to filter stuff from Trac out of your inbox and into a 'wp-trac' label.
Matches: subject:([WordPress Trac]) "added -- Ticket URL:"
Do this: Mark as read
Matches: subject:([WordPress Trac]) "Changes (by johnbillion)"
Do this: Mark as read
Matches: subject:([WordPress Trac]) "Comment (by johnbillion)"
Do this: Mark as read
@sawwd
sawwd / plugin.php
Created November 20, 2017 22:05 — forked from johnbillion/plugin.php
First pass at removing the vulnerabilities from this plugin. Untested. *bites nails*
<?php
/* Plugin Name: Damn Vulnerable WordPress Plugin
* Description: Intentionally vulnerable plugin for plugin author education
* Version: 0.1
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
* Author: Jon Cave
* Author URI: http://joncave.co.uk
* License: GPLv2+
*
* DO NOT RUN THIS PLUGIN ON AN INTERNET ACCESSIBLE SITE
@sawwd
sawwd / hierarchy.php
Created November 21, 2017 09:22 — forked from johnbillion/hierarchy.php
ASCII WordPress Template Hierarchy
<?php
/*
WordPress Template Hierarchy (as of WordPress 4.8)
is_404() -------------------------------------------------------------------------------------------------> 404.php
is_search() ----------------------------------------------------------------------------------------------> search.php
is_front_page() ------------------------------------------------------------------------------------------> front-page.php
is_home() ------------------------------------------------------------------------------------------------> home.php
@sawwd
sawwd / http_streaming.md
Created January 24, 2018 16:11 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@sawwd
sawwd / curl.md
Created January 28, 2018 07:39 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@sawwd
sawwd / gitdiffzip.sh
Created May 30, 2018 17:39
Git: archive only the changes between two commits.
#!/bin/bash
IFS=$'\n'
files=($(git diff --name-only $1 $2))
git archive -o $3 $2 "${files[@]}"
@sawwd
sawwd / git-clear-cache.sh
Created June 23, 2018 13:19 — forked from joemaffia/git-clear-cache.sh
Clear git cache
git rm -r --cached .
git add .
git commit -am 'git cache cleared'
git push