Skip to content

Instantly share code, notes, and snippets.

View petertwise's full-sized avatar

Peter Wise petertwise

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / swiftmailer-example.php
Last active August 19, 2018 19:51
example of swiftmailer usage
<?php
define('SITE_EMAIL', '[email protected]');
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 / youtube-cover-art.php
Last active July 31, 2020 07:52
Get the best version of youtube cover image without using the API
<?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
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 / amazon-links.php
Last active October 8, 2019 21:00
Add Amazon affiliate tag to all Amazon links in WordPress the_content
@petertwise
petertwise / all-kinds-of-acf-fields.json
Last active March 9, 2018 03:33
ACF all fields for testing
[
{
"key": "group_5aa17612b7168",
"title": "Page Fields with Gutenberg",
"fields": [
{
"key": "field_5aa1807a67935",
"label": "Message",
"name": "",
"type": "message",