Skip to content

Instantly share code, notes, and snippets.

View petertwise's full-sized avatar

Peter Wise petertwise

View GitHub Profile
@petertwise
petertwise / swiftmailer-example.php
Last active August 19, 2018 19:51
example of swiftmailer usage
<?php
define('SITE_EMAIL', 'no-reply@example.com');
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
petertwise / Gruntfile.js
Created May 9, 2018 00:03
My Grunt Setup - no ruby required version
// inspired by https://gist.github.com/jshawl/6225945
// Thanks @jshawl!
// now using grunt-sass to avoid Ruby dependency
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: { // sass tasks
dist: {
@petertwise
petertwise / yikes-acf-diff.diff
Created December 18, 2018 16:48
Running a diff between categories admin screen with YIKES Simple Taxonomy Ordering with and without ACF
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;
}
</style>
-<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
petertwise / favdates.md
Last active February 8, 2019 15:20
Favorite PHP Date Formats

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

long

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
petertwise / functions.php
Created November 13, 2018 19:37
Examples of extending WordPress Walker_Nav_Menu for sibling and subpage menus
<?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
petertwise / squarecandy-responsive-basics.js
Created April 11, 2017 15:14
Basic Load and Resize jQuery to start from
/***********
RESPONSIVE CALCULATIONS
**********/
// On the first time the page loads, or if the orientation changes
// (portrait to landscape, etc) call the recalculation script
$(window).on('load orientationchange', function(){
responsive_calc();
});
@petertwise
petertwise / squarecandy-test-event-filter.php
Last active August 9, 2019 16:59
test squarecandy ACF events filtering system
<?php
/*
Plugin Name: Test Event Filter
Plugin URI: https://squarecandy.net
Description:
Version: 1.0.0
Author: Square Candy Design
Author URI: http://squarecandydesign.com
Text Domain: squarecandy
*/
@petertwise
petertwise / kses-test.php
Last active August 28, 2019 19:55
WordPress kses default arrays
<?php
$allowed_html = wp_kses_allowed_html( 'strip' );
// empty array - strips all html
/*
Array();
*/
@petertwise
petertwise / subnetmasks.txt
Created October 18, 2017 01:57
Cheat Sheet for IP Address "wildcards" CIDR Notation - Subnet Mask
# These are the only common ones ever used...
# If you need a reference for anything inbetween these: https://tools.ietf.org/html/rfc4632#page-7
123.456.0.0/8 = 123.*.*.*
123.456.0.0/16 = 123.456.*.*
123.456.789.0/24 = 123.456.789.*
123.456.789.012/32 = 123.456.789.012
@petertwise
petertwise / amazon-links.php
Last active October 8, 2019 21:00
Add Amazon affiliate tag to all Amazon links in WordPress the_content