Skip to content

Instantly share code, notes, and snippets.

@joemcgill
joemcgill / new-staff-setup.md
Last active February 4, 2016 19:53
New Developer Setup

Computer/Tooling

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
joemcgill / wp_css_tricks_images_responsive.php
Created December 28, 2015 04:36
CSS Tricks Responsive Image Filter
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.
@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' );
@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 / 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 / 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 / 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 / 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 ) {
/* Overrides the database for development URLs */
define('WP_SITEURL', 'http://my.domain.dev');
define('WP_HOME', 'http://my.domain.dev');
{
"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"
],