Skip to content

Instantly share code, notes, and snippets.

@joemcgill
joemcgill / svgTest.js
Last active August 29, 2015 14:04
SVG Test w/o Modernizr
// SVG Test
(function () {
function supportsSVG() {
return !!document.createElementNS && !! document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect;
}
if (!supportsSVG()) {
document.documentElement.className += ' no-svg';
// optional .png fallback for .svg files inlined as <img> elements
$("img[src$='.svg']").attr("src", function() {
return $(this).attr('src').replace('.svg', '.png');
@joemcgill
joemcgill / widow_buster.php
Created September 3, 2014 17:55
Wordpress Widow Busting Function
<?php
/**
* Avoid widows in text by replacing the final space in each paragraph with a &nbsp;
*
* Inspired by David Walsh (http://davidwalsh.name/word-wrap-mootools-php)
*
* @param string $content Content passed into the filter
* @return string the filtered content
*/
function wustl_widow_buster ($content) {
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/base16-ocean.dark (SL).tmTheme",
"detect_slow_plugins": false,
"folder_exclude_patterns":
[
".git",
".sass-cache",
"bower_components"
],
/* Overrides the database for development URLs */
define('WP_SITEURL', 'http://my.domain.dev');
define('WP_HOME', 'http://my.domain.dev');
@joemcgill
joemcgill / gist:89629cd4ac3cd975db89
Created February 21, 2015 21:31
A WordPress filter to avoid widows in your titles
<?php
/**
* A WordPress filter to avoid widows in your titles
*/
function avoid_title_widows( $title ) {
// Find the last space.
$last_space = strrpos($title, ' ');
// Replace it with a non-breaking space.
if ( $last_space ) {
@joemcgill
joemcgill / no_responsive_image_feeds.php
Created December 3, 2015 04:00
Remove responsive images from feeds.
function no_responsive_image_feeds() {
add_filter( 'max_srcset_image_width', function() {
return 1;
} );
}
add_action('rss2_head', 'no_responsive_image_feeds' );
add_action('atom_head', 'no_responsive_image_feeds' );
add_action('rss_head', 'no_responsive_image_feeds' );
@joemcgill
joemcgill / wcus2015-notes.md
Created December 10, 2015 16:45
WordCamp US 2015 Notes

Tolman and Jorbin

  • list functions assign variables in reverse order in PHP7
  • HTTP/2
    • makes things faster by managing latency
    • introduces multiplexing in single TCP connections
    • #core-http on slack (working group)
  • CSS4
    • CSS color() function coming soon
    • varables in CSS
@joemcgill
joemcgill / ricg-merge-notes.md
Created December 10, 2015 16:47
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 wp.media 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.
@joemcgill
joemcgill / ssl_srcset.php
Created December 11, 2015 03:23
Force WordPress `srcset` to HTTPS
/*
* 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
joemcgill / remove_max_srcset_image_width.php
Created December 12, 2015 06:25
remove_max_srcset_image_width
// 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' );