Skip to content

Instantly share code, notes, and snippets.

View mikeschinkel's full-sized avatar

Mike Schinkel mikeschinkel

View GitHub Profile
@mikeschinkel
mikeschinkel / sr-file-changed.php
Created January 18, 2012 00:27
File Changed function from Sunrise.
<?php
/**
* Used where you might want to use an activation function but where it's not convenient or possible (like in a theme.)
* Accepts __FILE__ for the a unique key to identify the file.
*
* @param string $file
* @return bool
*
* Author: Mike Schinkel
* Author URI: http://about.me/mikeschinkel/
@mikeschinkel
mikeschinkel / wp-autohook.php
Created January 18, 2012 01:29
Proposing an add_autohook_support() function for WordPress.
<?php
/**
* Simplifies addition of WordPress hooks to a class.
*
* Simplifies addition of WordPress hooks to a class by adding any method and using WordPress-specific PHPDoc tags
* including @wp-autohook, @wp-nohook, @wp-action, @wp-filter and @wp-priority.
*
* Props Ryan McCue (https://gist.github.com/rmccue) for suggestion to use $method->getDocComment() instead of
* passing in method properties via array arguments.
@mikeschinkel
mikeschinkel / autohook-example.php
Created January 18, 2012 03:52
Example showing how to use proposed add_autohook_support() for WordPress.
<?php
/**
* Example for use of proposed add_autohook_support() for WordPress.
*
* @see: https://gist.github.com/1630212
*
* @author Mike Schinkel - http://about.me/mikeschinkel/
*
* @wp-autohook implicit
*
@mikeschinkel
mikeschinkel / functions.php
Created February 3, 2012 07:43
Master WordPress Custom Post Types - WordCamp Atlanta 2012
<?php
/*
* Code Examples for Master WordPress Custom Post Types - WordCamp Atlanta 2012
*
* Author: Mike Schinkel
* Author URI: http://about.me/mikeschinkel
*
*/
add_action( 'init', 'mikes_theme_init' );
function mikes_theme_init() {
@mikeschinkel
mikeschinkel / sync-plugin-info.php
Created February 21, 2012 22:14
WordPress plugin to download list of WordPress' plugins into the WordPress database (written pre-Custom Post Types)
<?php
/*
Plugin Name: Sync Plugin Info
Plugin URI: http://mikeschinkel.com/wordpress-plugins/sync-plugin-info
Description: Synchronizes Plugin Info from <a href="http://api.wordpress.org" target="_blank">api.wordpress.org</a> to tables in the local MySQL database
Version: 0.1
Author: Mike Schinkel
Author URI: http://mikeschinkel.com
*/
@mikeschinkel
mikeschinkel / must-have-mac-apps.txt
Created February 22, 2012 01:05
List of Mac OS X Apps I've Found indispensable coming from Windows
Here's a list of Mac OS X Apps I've found indispensable coming from Windows.
It's not the complete list of apps I used or cannot live without as it doesn't
include ones Windows users would already know about.
-Mike Schinkel
http://about.me/mikeschinkel
Last Updated: Feb 21, 2012
Must Have
@mikeschinkel
mikeschinkel / rootbased-taxonomy-urls.php
Created March 26, 2012 04:29
Root-based Taxonomy URLs Plugin for WordPress
<?php
/*
* Plugin Name: Root-based Taxonomy URLs for WordPress
* Description: Enables root-based Taxonomy URLs, i.e. Makes /taxonomy/my-taxonomy/ URLs route as /my-taxonomy/
* Author: Mike Schinkel
* Author URI: http://about.me/mikeschinkel
* Plugin URI: https://gist.github.com/1421235
* Version: 0.1
* License: GPL 2+
* Notes: Must use register_root_based_taxonomy_url( $taxonomy[, $priority] ) in an 'init' hook to specify root_based taxonomy.
<?php
/**
* Written to help @Frump with https://github.com/Frumph/comic-easel/issues/2
*/
class Comics_URL_Class {
static function on_load() {
add_filter( 'init', array( __CLASS__, 'init' ) );
add_filter( 'request', array( __CLASS__, 'request' ) );
add_filter( 'feed_link', array( __CLASS__, 'feed_link' ) );
/comic/{$chapter_slug}/{$post_slug}/ -> display a post whose parent is a chapter
/feed/ -> displays 'post' and 'comic'
/comic/feed/ -> displays 'comic'
/comic/{$chapter_slug}/feed/ -> displays all comic posts for a chapter?
/comic/{$year}/ -> displays all comic posts for that year
/comic/{$year}/{$month}/ -> displays all comic posts for that year/month
/comic/{$year}/{$month}/{$day}/ -> displays all comic posts for that year/month/day
@mikeschinkel
mikeschinkel / WP_Deprecated_Menu_Array.php
Created June 22, 2012 21:57
Proof of concept work for replacing WordPress' $menu variable with a class that implements ArrayAccess and Iterator.
<?php
class Array_Simulator implements ArrayAccess, Iterator {
protected $menu;
public function offsetUnset( $key ) {
if ( $this->offsetExists( $key ) )
unset( $this->menu[$key] );
}