Skip to content

Instantly share code, notes, and snippets.

View staylor's full-sized avatar
💭
GitHub is not a social network

Scott Taylor staylor

💭
GitHub is not a social network
View GitHub Profile
@staylor
staylor / users.php
Created October 10, 2012 19:29
Unfuck User Query
add_action( 'pre_user_query', 'fix_users' );
function fix_users( &$query ) {
global $wpdb;
if ( 'authors' !== $query->query_vars['who'] )
return;
$query->query_vars['fields'] = array( 'ID', 'display_name' );
$query->query_fields = 'ID, display_name';
@staylor
staylor / balls.php
Created December 1, 2012 01:18
Balls
function _override_home_url( $url, $path = '' ) {
if ( $path && false === strpos( $url, $path ) )
$url .= $path;
return $url;
}
add_filter( 'home_url', '_override_home_url', 10, 2 );
@staylor
staylor / wp-imagick-access.php
Created December 9, 2012 00:24
I am using a script called "test.php" in the root of WordPress with a folder for images called "test-images/*". The original image is called "scott.jpg" - change that value with your image to play along
<?php
error_reporting(-1);
require( 'wp-load.php' );
require_once( ABSPATH . WPINC . '/class-wp-image-editor.php' );
require_once( ABSPATH . WPINC . '/class-wp-image-editor-imagick.php' );
/**
* Tosses Imagick methods up the chain to WP_Image_Editor_Imagick::image.
* WP_Image_Editor_Imagick::image is protected, so you can't act on
@staylor
staylor / images.php
Created January 24, 2013 18:16
Construct eMusic Image URLs by convention
<?php
/**
* Convenience Method to construct Artist Image URL
*
* @param int $id
* @return string Returns URL for Artist Image
*/
function artist_image_url( $id ) {
$one = substr( $id, 0, 3 );
$two = substr( $id, 3, 3 );
Set-Cookie: EMID=13cbc37f7e44e825ef0c8; Domain=.emusic.com; Expires=Sun, 06-Feb-2022 23:50:50 GMT; Path=/
Set-Cookie: oatmeal=em=&rsc=&cc=&t=1000000&e=&r=&p=3&bp=170005&rv=5&pv=2&gme=false&sn=&us=&pu=&tb=&id=&bo=&ris=&purl=%2Fwelcome%2Fhome%2F%3Ffref%3D1000000%26p%3D3%26bp%3D170005&ups=true&crs=true; Domain=.emusic.com; Expires=Sun, 06-Feb-2022 23:50:50 GMT; Path=/
Set-Cookie: sugar=ftu=false&fd=false&gm=false; Domain=.emusic.com; Expires=Sun, 06-Feb-2022 23:50:50 GMT; Path=/
Set-Cookie: JSESSIONID=67A3F2A395E6D8EBB2EE5677CB9AA8AF.abv-app-04; Path=/
Set-Cookie: oatmeal=em=&rsc=US&cc=US&t=666666&e=&r=&p=111776&bp=&rv=5&pv=2&gme=false&sn=&us=-1&pu=&tb=&id=&bo=&ris=&purl=%2Fwelcome%2Femusic-trial-50-14%2F%3Ffref%3D666666%26p%3D111776%26bp%3D2&ups=true&crs=true; Domain=.emusic.com; Expires=Sun, 06-Feb-2022 23:50:50 GMT;
<?php
/*
Plugin Name: Memcached Redux
Description: The real Memcached (not Memcache) backend for the WP Object Cache.
Version: 3.0
Plugin URI: http://wordpress.org/extend/plugins/memcached/
Author: Scott Taylor - uses code from Ryan Boren, Denis de Bernardy, Matt Martz
Install this file to wp-content/object-cache.php
*/
<?php
/**
* Handle oEmbed and embedded media
*
* @param $content
*/
function the_featured_audio( &$content ) {
$url = trim( array_shift( explode( "\n", $content ) ) );
if ( 0 === strpos( $url, 'http://' ) ) {
// Create the media frame.
mediaFrame = wp.media.frames.formatMedia = wp.media({
frame : 'select',
displaySettings: true,
// Set the title of the modal.
title: $el.data('choose'),
// Tell the modal to show only items matching the current mime type.
library: {