Skip to content

Instantly share code, notes, and snippets.


Peter Wise petertwise

View GitHub Profile
petertwise /
Created Oct 23, 2019
A small script for quickly whipping up a new WordPress site on localhost
# Don't forget to enter your own email on line 19 and user Sites dir path on line 20
# set the slug
read -p "Enter the slug for the new site:" SLUG
# set the mysql password
read -s -p "Enter a MySQL password:" MYSQLPASS
# setup the directory and basic settings
petertwise / kses-test.php
Last active Aug 28, 2019
WordPress kses default arrays
View kses-test.php
$allowed_html = wp_kses_allowed_html( 'strip' );
// empty array - strips all html
petertwise / squarecandy-test-event-filter.php
Last active Aug 9, 2019
test squarecandy ACF events filtering system
View squarecandy-test-event-filter.php
Plugin Name: Test Event Filter
Plugin URI:
Version: 1.0.0
Author: Square Candy Design
Author URI:
Text Domain: squarecandy
petertwise /
Last active Feb 8, 2019
Favorite PHP Date Formats

U.S. clients with mostly U.S. users


Used whenever there is room to display a long form date. These are the prefered format whenever possible.

Sunday, January 10, 2010 - 9:30pm
l, F j, Y - g:ia

Sunday, January 10 - 9:30pm

petertwise / yikes-acf-diff.diff
Created Dec 18, 2018
Running a diff between categories admin screen with YIKES Simple Taxonomy Ordering with and without ACF
View yikes-acf-diff.diff
diff --git a/test-yikes-drag-drop.html b/test-yikes-drag-drop-withACF.html
index 90c9158..c3b6358 100644
--- a/test-yikes-drag-drop.html
+++ b/test-yikes-drag-drop-withACF.html
@@ -34,10 +34,15 @@ img.emoji {
padding: 0 !important;
-<link rel='stylesheet' href='http://testwp.localhost/wp-admin/load-styles.php?c=1&amp;dir=ltr&amp;load%5B%5D=dashicons,admin-bar,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menus,wp-pointer,widgets&amp;load%5B%5D=,site-icon,l10n,buttons,wp-auth-check&amp;ver=5.0.1' type='text/css' media='all' />
+<link rel='stylesheet' href='http://testwp.localhost/wp-admin/load-styles.php?c=1&amp;dir=ltr&amp;load%5B%5D=dashicons,admin-bar,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menus,wp-pointer,widgets&amp;load%5B%5D=,site-icon,l10n,buttons,wp-auth-check,wp-color-picker&amp;ver=5.0.1' type='text/css' media='all' />
petertwise / functions.php
Created Nov 13, 2018
Examples of extending WordPress Walker_Nav_Menu for sibling and subpage menus
View functions.php
* Custom Walker to extract current sister-sub-menu
class Custom_Walker_Nav_Sister_Menu extends Walker_Nav_Menu {
var $found_parents = array();
function start_el(&$output, $item, $depth, $args) {
petertwise / swiftmailer-example.php
Last active Aug 19, 2018
example of swiftmailer usage
View swiftmailer-example.php
define('SITE_EMAIL', '');
define('SITE_NAME', 'My Project');
function send_password_reset($email, $name, $resetlink) {
require_once( 'swiftmailer/swift_required.php' );
$subject = 'Resetting your password for ' . SITE_NAME;
petertwise / youtube-cover-art.php
Last active Jul 31, 2020
Get the best version of youtube cover image without using the API
View youtube-cover-art.php
function url_exists( $url ) {
$headers = get_headers($url);
return stripos( $headers[0], "200 OK" ) ? true : false;
function get_youtube_id( $url ) {
$youtubeid = explode('v=', $url);
$youtubeid = explode('&', $youtubeid[1]);
petertwise / Gruntfile.js
Created May 9, 2018
My Grunt Setup - no ruby required version
View Gruntfile.js
// inspired by
// Thanks @jshawl!
// now using grunt-sass to avoid Ruby dependency
module.exports = function(grunt) {
pkg: grunt.file.readJSON('package.json'),
sass: { // sass tasks
dist: {
petertwise / amazon-links.php
Last active Oct 8, 2019
Add Amazon affiliate tag to all Amazon links in WordPress the_content
View amazon-links.php