Skip to content

Instantly share code, notes, and snippets.

View bradyvercher's full-sized avatar

Brady Vercher bradyvercher

View GitHub Profile
@bradyvercher
bradyvercher / wp-revisions-bookmarklet.md
Created October 25, 2013 16:18
A bookmarklet to convert [#####] text nodes on a page to links pointing to the corresponding changeset on WordPress Trac.

Bookmarklet

(function e(t){var n=/\[([0-9]{5})\]/m;if(t.childNodes.length>0){for(var r=0;r<t.childNodes.length;r++){e(t.childNodes[r])}}if(3===t.nodeType&&n.test(t.nodeValue)){var i=t.nodeValue.match(n).pop(),s=document.createElement("a");s.appendChild(document.createTextNode(i));s.setAttribute("href","http://core.trac.wordpress.org/changeset/"+i+"/trunk");t.parentNode.insertBefore(s,t.nextSibling);t.parentNode.insertBefore(document.createTextNode(" ["),t.nextSibling);t.parentNode.insertBefore(document.createTextNode("]"),s.nextSibling);t.nodeValue=t.nodeValue.replace(n,"")}})(document.body)

Source

( function traverse( node ) {
@bradyvercher
bradyvercher / hidpi-gallery-thumbnails.php
Created November 1, 2013 21:30
WordPress: Use HiDPI thumbnails with the same aspect ratio as the original image in gallery shortcodes.
@bradyvercher
bradyvercher / desaturate-menu-image-icons.php
Created December 13, 2013 16:48
WordPress: Desaturate admin menu icons added as images before WordPress 3.8 to keep them from stealing attention.
<?php
/**
* Plugin Name: Desaturate Menu Image Icons
* Description: Desaturate admin menu icons added as images before WordPress 3.8 to keep them from stealing attention.
* Version: 1.0.0
* Author: Brady Vercher
* Author URI: http://www.blazersix.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
<?php
/**
* Return a base64 encoded SVG icon for use as a data URI.
*
* @param string $path Path to SVG icon.
* @return string
*/
function audiotheme_encode_svg( $path ) {
$path = path_is_absolute( $path ) ? $path : AUDIOTHEME_DIR . $path;
@bradyvercher
bradyvercher / url-tokens.php
Last active May 21, 2016 17:46
Basic URL signing functions for WordPress
<?php
/**
* Basic URL Signing functions for WordPress.
*
* @author Brady Vercher (twitter.com/bradyvercher)
* @link http://www.blazersix.com/blog/protect-your-products-and-improve-your-systems-with-signed-urls/
*/
/**
* Sign a URL to ensure it hasn't been tampered with.
@bradyvercher
bradyvercher / bind.js
Last active October 25, 2016 16:10
Bind event listeners with optional debounce and throttle modes using vanilla JavaScript.
/**
* Bind event listeners with optional debounce and throttle modes.
*
* @param {object} el The object to bind an event to.
* @param {string} eventType The type of event to listen for.
* @param {object} handler The callback handler.
* @param {object} options Options to modify behavior.
* - delay: Time in milliseconds. Behavior depends on mode.
* - init: Whether the handler should be called when registered. Default is false.
* - mode: 'debounce' or 'throttle'. Default is false.
@bradyvercher
bradyvercher / readme.md
Created April 27, 2016 21:34
Configure WordPress to send email through an SMTP server.

WordPress SMTP Configuration

Usage

  1. Install and activate the smtp-config.php file as a plugin or drop it in /mu-plugins.
  2. Define the necessary constants in wp-config.php.

Configuration Examples

MailHog

@bradyvercher
bradyvercher / audiotheme-genesis.css
Last active March 22, 2017 08:59
Custom CSS for integrating AudioTheme with Genesis 2.0
/* General */
.archive .audiotheme {
margin-bottom: 40px;
padding: 40px 40px 20px 40px;
background: #fff;
}
.audiotheme .audiotheme-archive-title {
margin-bottom: 1.6rem;
@bradyvercher
bradyvercher / cache-post-thumbnails.php
Created January 9, 2014 17:21
WordPress: Cache post thumbnail attachments that appear in a WP_Query loop.
<?php
/**
* Plugin Name: Cache Post Thumbnails
* Description: Prime the post thumbnails cache for individual loops.
* Version: 1.0.0
* Author: Brady Vercher
* Author URI: http://www.blazersix.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@bradyvercher
bradyvercher / register-plugin-icons.php
Created October 4, 2017 22:30
Register icons to display on the Manage Plugins screen for plugins that aren't in the WordPress.org directory.
<?php
/**
* Register plugin icons.
*
* WordPress 4.9 introduced icons in the list table on the Manage Plugins
* screen. The icons are pulled from the W.org update API. If an icon isn't
* available, a generic plugin Dashicon is shown instead.
*
* @param array $value Plugin update data.
* @return array