Skip to content

Instantly share code, notes, and snippets.

Joe McGill joemcgill

Block or report user

Report or block joemcgill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
joemcgill / axe-report.js
Created Dec 11, 2018
A11y test example for axe-puppeteer.
View axe-report.js
const colors = require('colors');
const link =;
const error =;
function selectorToString(selectors, separator) {
separator = separator || ' '
return selectors
.reduce((prev, curr) => prev.concat(curr), [])
joemcgill / attachment_fields_to_edit_demo.php
Last active Nov 9, 2018
Attachment Fields to Edit Demo
View attachment_fields_to_edit_demo.php
add_filter( 'attachment_fields_to_edit', 'attachment_location_field', 10, 2 );
add_filter( 'attachment_fields_to_save', 'save_location_field', null, 2 );
function attachment_location_field( $form_fields, $post ) {
$field_value = get_post_meta( $post->ID, 'location', true );
$form_fields['location'] = array(
joemcgill /
Last active Jan 29, 2016
Ideas for a WP_Image Class in WordPress


  • Mimic the properties of WP_Post, and include additional metadata that's stored for images
    • _wp_attached_file
    • _wp_attachement_metadata
    • _wp_attachment_is_custom_background (maybe?)
  • Include methods for retrieving data associated with an image, possibly replacing the wp_get_attachment_image_ family of functions.
  • Save any reused data that would be used across functions so it's not calculated multiple times (e.g., wp_upload_dir(), see: #34359).
  • Maintain backwards compatability with the media.php image functions.
joemcgill /
Created Jan 9, 2016
WUSTL Server Load Testing 1/8/2015

1st Test – 40 users/1-4 sec/5min

40 concurrent users requesting every 1-4 seconds for 5 minutes avg was 1438 requests in 5 min (28,760/hr or 287.6/min or 4.8/sec)

  • First load is really slow ~7–9s
  • Once cache is warm things are really fast 11ms
  • Cache breaks are happening on every publish.
  • PHP seems to be the bottleneck
View gist:e245a8bf39d05b9589ca
* Recurrence is kind of wierd/confusing. Some tutorials might be nice.
* We need to double check venues and some other
* Everyone is going through stories.
* Slideshows are cumbersome and requires a bunch of extra work.
* Do we need to add promos to old med school stories
joemcgill /
Last active Feb 4, 2016
New Developer Setup


Much of the software that we use will be installed by Jeff/Galen on your new computer. This includes MS Office, Adobe Creative Suite, Etc. This is a list of things you will need to install yourself.

joemcgill / wp_css_tricks_images_responsive.php
Created Dec 28, 2015
CSS Tricks Responsive Image Filter
View wp_css_tricks_images_responsive.php
function wp_css_tricks_images_responsive( $content ) {
* Find all instanced of your custom image markup in the content and bail early
* if none are found.
if ( ! preg_match_all( '/<figure [^>]+>\s+<img [^>]+>/', $content, $matches ) ) {
return $content;
// Set up arrays to hold your images and a set of IDs that we'll cache later.
View remove_max_srcset_image_width.php
// Remove max_srcset_image_width.
function remove_max_srcset_image_width( $max_width ) {
return false;
add_filter( 'max_srcset_image_width', 'remove_max_srcset_image_width' );
joemcgill / ssl_srcset.php
Created Dec 11, 2015
Force WordPress `srcset` to HTTPS
View ssl_srcset.php
* Force URLs in srcset attributes into HTTPS scheme.
* This is particularly useful when you're running a Flexible SSL frontend like Cloudflare
function ssl_srcset( $sources ) {
foreach ( $sources as &$source ) {
$source['url'] = set_url_scheme( $source['url'], 'https' );
return $sources;
joemcgill /
Created Dec 10, 2015
Random notes while thinking about the RICG merge into 4.4

WP RICG Images merge notes

  • Consider merging get_image_tag() and wp_get_attachment_image().
    • Nah, bad idea. While get_image_tag() is only used in the media editor, it probably makes sense to keep the image generation on the back end and front end separated because of how people are likely filtering display.
  • Add an event listener to the editor if we can't do a content filter.
    • Look into adding needed metadata directly to to avoid the ajax request
  • Add caching to attachment_url_to_postid to speed up multiple requests.
  • Add smart ways to filter sizes globally w/o inducing another wp_get_attachment_image() call.
You can’t perform that action at this time.