Skip to content

Instantly share code, notes, and snippets.

@ControlledChaos
ControlledChaos / README.md
Last active March 7, 2024 04:41
Add srcset and sizes attributes to Advanced Custom Fields image uploads.

ACF Responsive Images

WordPress Snippet

Adds the srcset and sizes attributes to ACF image uploads. Requires installation of the Advanced Custom Fields plugin.

NOTE: ACF image field must be set to return the ID.

NOTE: WordPress needs image sizes with equal aspect ratios in order to generate the srcset, and does not use srcset when images are added as "Full Size".

// Vanilla version of FitVids
// Still licencened under WTFPL
//
// Not as robust and fault tolerant as the jQuery version.
// It's BYOCSS.
// And also, I don't support this at all whatsoever.
;(function(window, document, undefined) {
'use strict';
@richardtorres314
richardtorres314 / flexbox.scss
Last active May 4, 2024 06:31
CSS Flexbox - Sass Mixins
// --------------------------------------------------
// Flexbox SASS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
@mixin flexbox {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
@cvan
cvan / HOWTO.md
Last active April 15, 2024 04:01
get all URLs of all network requests made on a web page from the Chrome Dev Tools (from an exported HAR)

Setup

Using Homebrew on Mac OS X:

brew install jq

Add these aliases to your profile (e.g., ~/.zshrc, ~/.bashrc, ~/.profile, etc.):

alias hurlp='pbpaste | jq ".log.entries" | tee >(jq --raw-output "[.[] | .request.url] | sort | unique | .[]")'

alias hurld='pbpaste | jq ".log.entries" | jq --raw-output "[.[] | .request.url] | sort | unique | .[]" | harurls | tee >(xargs -n 1 curl -O $1)'

@popcorn245
popcorn245 / hue_colors.md
Last active December 10, 2023 03:10
XY Color Conversion

FROM HUE DESIGN DOCS

https://github.com/PhilipsHue/PhilipsHueSDK-iOS-OSX/blob/00187a3db88dedd640f5ddfa8a474458dff4e1db/ApplicationDesignNotes/RGB%20to%20xy%20Color%20conversion.md

#Conversion between RGB and xy in the CIE 1931 colorspace for hue The conversion between RGB and xy in the CIE 1931 colorspace is not something Philips invented, but we have an optimized conversion for our different light types, like hue bulbs and LivingColors. It is important to differentiate between the various light types, because they do not all support the same color gamut. For example, the hue bulbs are very good at showing nice whites, while the LivingColors are generally a bit better at colors, like green and cyan.

@johnbillion
johnbillion / wp_mail.md
Last active May 12, 2024 14:19
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@khromov
khromov / functions.php
Last active November 5, 2023 23:45
Cache a slow WP_Query in WordPress
<?php
/**
* Function that gets recent posts
*/
function get_recent_posts() {
//No cache
if(!wp_cache_get('my_complex_query_result')) {
//This is the super slow query.
@wpmark
wpmark / using-media-handle-sideload.php
Created July 10, 2015 10:32
Using Media Handle Sideload
<?php
/* set the url of the file to sideload - probably be from $_POST or something */
$url = 'http://domain.com/image.jpg';
/**
* donwload the url into wordpress
* saved temporarly for now
*/
$tmp = download_url( $url );
@wgbartley
wgbartley / proxy.php
Last active December 18, 2017 16:30
Spark PHP Proxy
<?php
// Set your access token here
define('ACCESS_TOKEN', 'your_access_token_here');
// Make sure we have an HTTP_ACCEPT header,
// and if so, make it lower-case for easier string matching
if(isset($_SERVER['HTTP_ACCEPT']))
$_SERVER['HTTP_ACCEPT'] = strtolower($_SERVER['HTTP_ACCEPT']);
else
@Shelob9
Shelob9 / pods_metabox_title.php
Created April 10, 2014 19:31
Change the heading of the Pods "More Fields" metabox in the post editor.
<?php
add_filter( 'pods_meta_default_box_title', 'slug_pods_metabox_title' );
slug_pods_metabox_title( $title ) {
$title = __( 'Return of The Jedi', 'pods' );
return $title;
}