Skip to content

Instantly share code, notes, and snippets.

View mikeschinkel's full-sized avatar

Mike Schinkel mikeschinkel

View GitHub Profile
case (n)
{
when 0:
echo "You typed zero.";
when 1:
when 4:
when 9:
echo "n is a perfect square.";
when 2:
echo "n is an even number.";
switch (n)
{
case 0:
echo "You typed zero.";
case 1:
case 4:
case 9:
echo "n is a perfect square.";
case 2:
echo "n is an even number.";
<?php
/*
* Adds "tax_terms" to WP_Query()
*
* See: http://lists.automattic.com/pipermail/wp-hackers/2010-October/035258.html
*
* Author: Mike Schinkel (http://mikeschinkel.com)
*
*/
<?php
/*
blog-from-flickr.php
Allows the WordPress blog owner to blog a recent photo from a Flickr Photoset just by clicking a button.
Author: Mike Schinkel (http://mikeschinkel.com)
Just drop this example into the root of your website and call directly to see it work.
@mikeschinkel
mikeschinkel / posts-by-category-with-price.php
Created October 26, 2010 05:58
Query for a list of WordPress posts by category, but only those with a postmeta->meta_key='Price' that's >0 and NOT NULL.
<?php
/*
posts-by-category-with-price.php
Query for a list of WordPress posts by category,
but only those with a postmeta->meta_key='Price' that's >0 and NOT NULL.
Author: Mike Schinkel (http://mikeschinkel.com)
@mikeschinkel
mikeschinkel / orphaned-post-types.php
Created November 2, 2010 22:35
Starting point class for Managing Orphaned Post Types in WordPress
<?php
/*
orphaned-post-types.php
View the list at http://yoursite.com/wp-admin/edit.php?orphans=true
In response to: http://lists.automattic.com/pipermail/wp-hackers/2010-November/035682.html
Not yet complete.
@mikeschinkel
mikeschinkel / admin-parse-output.php
Created November 27, 2010 02:56
Plugin for WordPress: Adds a 'admin_parse_output' hook to allow you to parse and modify the HTML generated by the admin.
<?php
/*
Plugin Name: Admin Parse Output
Description: Adds a 'admin_parse_output' hook to allow you to parse and modify the HTML generated by the admin when other hooks are not available. Starts HTML capture with the 'admin_init' hook and ends with the 'admin_footer' hook so it will miss anything that comes after 'admin_footer' (see the last lines of /wp-admin/admin-footer.php to see what this hook will miss.)
Version: 0.1
Author: Mike Schinkel
Author URI: http://mikeschinkel.com
Notes: Written for http://lists.automattic.com/pipermail/wp-hackers/2010-November/036150.html
Example Usage: See https://gist.github.com/717515
*/
@mikeschinkel
mikeschinkel / functions.php
Created November 27, 2010 02:59
Using the Admin Parse Output plugin for WordPress
/*
functions.php - Plugin that this example uses: https://gist.github.com/717514
*/
add_action('admin_parse_output', 'yoursite_admin_parse_output');
function yoursite_admin_parse_output($html) {
global $pagenow;
if ($pagenow=='themes.php' && isset($_GET['page']) && $_GET['page']=='custom-header') {
@mikeschinkel
mikeschinkel / yoursite-image-header.php
Created November 28, 2010 00:08
Alternate approach to removing custom image header upload in WP 3.0.
<?php
/*
* This approach is what Andrew Nacin suggested[1] instead of [2] and requested via email by Steve Wolfson.
* Given it's complexity I can't advise te use of [1] and still recomment [2]. See also: [3][4].
*
* Author: Mike Schinkel (http://mikeschinkel.com)
*
* [1] http://lists.automattic.com/pipermail/wp-hackers/2010-November/036172.html
* [2] http://lists.automattic.com/pipermail/wp-hackers/2010-November/036170.html
* [3] https://gist.github.com/717514
@mikeschinkel
mikeschinkel / TCB_JSON_API.php
Created November 2, 2011 16:44
Creates JSON class for Tom C. Barret to load tickets via a RESTful API
<?php
/**
* Creates JSON class for Tom C. Barrett to load tickets via a RESTful API:
*
* @example:
*
* URL: http://example.com/api/ticket/12345
*
* @see:
*