Skip to content

Instantly share code, notes, and snippets.

View mfields's full-sized avatar

Michael Fields mfields

  • Portland, Oregon, USA
View GitHub Profile
<a href="http://trunk/?p=65"><img class="attachment-thumbnail wp-post-image" title="alaska-1" src="http://wp-content/uploads/2012/05/alaska-1-150x150.jpg" alt="alaska-1" width="150" height="150" />
<a href="http://trunk/?p=65">Alas</a>
<a href="http://trunk/?p=64"><img class="attachment-thumbnail wp-post-image" title="Red flower" src="http://wp-content/uploads/2012/05/flower-red-150x150.jpg" alt="Red flower" width="150" height="150" />
<a href="http://trunk/?p=64">Red Flower</a>
<a href="http://trunk/?p=122"><img class="attachment-thumbnail wp-post-image" title="meow" src="http://wp-content/uploads/2012/05/meow-150x150.jpg" alt="meow" width="150" height="150" />
<a href="http://trunk/?p=122">Meow!</a>
<a href="http://trunk/?p=57"><img class="attachment-thumbnail wp-post-image" title="rhino" src="http://wp-content/uploads/2012/05/rhino-150x150.jpg" alt="rhino" width="150" height="150" />
<?php
$x11 = array(
'aliceblue' => array( 240, 248, 255 ),
'antiquewhite' => array( 250, 235, 215 ),
'aqua' => array( 0, 255, 255 ),
'aquamarine' => array( 127, 255, 212 ),
'azure' => array( 240, 255, 255 ),
'beige' => array( 245, 245, 220 ),
'bisque' => array( 255, 228, 196 ),
'black' => array( 0, 0, 0 ),
/**
* Loads a Flash Audio Player if browser does not support HTML5 audio element.
* http://wpaudioplayer.com/
*
* @uses wp-includes/js/swfobject.js
*/
var AudioPlayer=function(){var H=[];var D;var F="";var A={};var E=-1;var G="9";function B(I){if(document.all&&!window[I]){for(var J=0;J<document.forms.length;J++){if(document.forms[J][I]){return document.forms[J][I];break}}}return document.all?window[I]:document[I]}function C(I,J,K){B(I).addListener(J,K)}return{setup:function(J,I){F=J;A=I;if(swfobject.hasFlashPlayerVersion(G)){swfobject.switchOffAutoHideShow();swfobject.createCSS("p.audioplayer_container span","visibility:hidden;height:24px;overflow:hidden;padding:0;border:none;")}},getPlayer:function(I){return B(I)},addListener:function(I,J,K){C(I,J,K)},embed:function(I,K){var N={};var L;var J={};var O={};var M={};for(L in A){N[L]=A[L]}for(L in K){N[L]=K[L]}if(N.transparentpagebg=="yes"){J.bgcolor="#FFFFFF";J.wmode="transparent"}else{if(N.pagebg){J.bgcolor="#"+N.pagebg}J.wmode="opaque"}J.menu="false";for(
<?php
$images = get_children( array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
) );
if ( $images ) {
@mfields
mfields / gist:1456066
Created December 10, 2011 19:34
Is RGB(A)?
function is_rgb( $x ) {
if ( is_int( $x ) )
$x = strval( $x );
if ( ! is_string( $x ) )
return false;
$x = preg_replace( '/\s*/', '', $x );
$x = strtolower( $x );
$x = trim( $x );
@mfields
mfields / gist:1403263
Created November 29, 2011 03:30
sudfglkusdfglksdfkghj
<?php
/*
Plugin Name: sudfglkusdfglksdfkghj
*/
function sudfglkusdfglksdfkghj( $content ) {
global $wp_version;
$version = '3.3-beta4';
if ( $wp_version == $version )
if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
$template = false;
if ( is_404() && $template = get_404_template() ) :
elseif ( is_search() && $template = get_search_template() ) :
elseif ( is_tax() && $template = get_taxonomy_template() ) :
elseif ( is_front_page() && $template = get_front_page_template() ) :
elseif ( is_home() && $template = get_home_template() ) :
elseif ( is_attachment() && $template = get_attachment_template() ) :
remove_filter('the_content', 'prepend_attachment');
elseif ( is_single() && $template = get_single_template() ) :
@mfields
mfields / gist:1203408
Created September 8, 2011 13:38
Get Background Color
<?php
function mytheme_get_background_color() {
$color = get_background_color();
if ( ! ctype_xdigit( $color ) )
return 'transparent';
if ( ! in_array( strlen( $color ), array( 3, 6 ) ) )
return 'transparent';
return '#' . $color;
}
@mfields
mfields / gist:1184759
Created August 31, 2011 21:27
Enqueue css for a custom post_type in edit.php
<?php
add_action( 'load-edit.php', 'myplugin_setup_edit_screen' );
function myplugin_setup_edit_screen() {
$screen = get_current_screen();
if ( 'my_post_type' != $screen->post_type ) {
return;
}
add_action( 'admin_print_styles', 'myplugin_edit_screen_css' );
@mfields
mfields / gist:1079539
Created July 13, 2011 01:05
Sticky Posts
<?php
if ( ! have_posts() ) {
/**
* @todo Some kinda 404 stuff here...
*/
}
/*
* Loop for Sticky Posts.
*/