Skip to content

Instantly share code, notes, and snippets.

View mikeschinkel's full-sized avatar

Mike Schinkel mikeschinkel

View GitHub Profile
@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 / posts-by-taxonomy.php
Created November 6, 2010 01:50
Class to extended WordPress' 3.0.x WP_Query to allow querying for all terms in a taxonomy.
<?php
/*
PostsByTaxonomy class that extends WP_Query and filters to includes all posts that have any term of a taxonomy.
Author: Mike Schinkel (http://mikeschinkel.com)
This example works, just drop into the root of your website and call directly.
Use the class in your plugins or themes.
See:
@mikeschinkel
mikeschinkel / posts-ordered-by-meta.php
Created November 6, 2010 09:05
Class to extended WordPress' 3.0.x WP_Query to allow sorting by a meta_key.
<?php
/*
PostsOrderedByMetaQuery class that extends WP_Query and sorts posts meta_key
Author: Mike Schinkel (http://mikeschinkel.com)
This example works, just drop into the root of your website and call directly.
Use the class in your plugins or themes.
See: http://stackoverflow.com/questions/4111255/how-to-sort-a-query-posts-function-by-custom-field-while-limiting-posts-by-ano
@mikeschinkel
mikeschinkel / news-items-instead-of-posts.php
Created November 12, 2010 09:58
Changes WordPress "Posts" to be called "News Items" instead.
<?php
/*
news-items-instead-of-posts.php
Changes WordPress "Posts" to be called "News Items" instead.
Copy this code into your theme's functions.php file.
See comments here: http://markjaquith.wordpress.com/2010/11/12/post-formats-vs-custom-post-types/
@mikeschinkel
mikeschinkel / list-custom-post-type-posts-with-ajax.PHP
Created November 13, 2010 10:04
Shows how to create a widget with a dropdown list of posts for a given post type and then retrieve HTML specific to the selected post via AJAX to insert into the page.
<?php
/*
List_Custom_Post_Type_Posts_with_AJAX class.
Shows how to create a widget with a dropdown list of posts for a given post type and
then retrieve HTML specific to the selected post via AJAX to insert into the page.
Yes, the name of the class is insanely long in hopes that you'll be forced to think
about what would be a better name.
@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 / hide-taxonomy-in-admin-menu.php
Created November 27, 2010 06:24
Hide a Taxonomy in the WordPress Admin Menu
<?php
/*
See http://lists.automattic.com/pipermail/wp-hackers/2010-November/036174.html
Also: http://mikeschinkel.com/websnaps/skitched-20101127-012515.png
Author: Mike Schinkel
*/
add_action('admin_menu','yoursite_admin_menu');
function yoursite_admin_menu() {
global $submenu;
@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 / admin-menu-challenge.php
Created January 15, 2011 05:03
The Great WordPress Admin Menu Challenge of Jan 2011
<?php
/*
Plugin Name: The Great WordPress Admin Menu Challenge of Jan 2011
Description: <em>"The Great WordPress Admin Menu Challenge of Jan 2011"</em> was inspired by the WordPress team's apparent lack of understanding of the problems addressed by trac tickets <a href="http://core.trac.wordpress.org/ticket/16048">#16048</a> and <a href="http://core.trac.wordpress.org/ticket/16050">#16050</a> <em>(See also: <a href="http://core.trac.wordpress.org/ticket/16204">#16204</a>)</em> and suggestion that the <a href="http://wordpress.org/extend/plugins/admin-menu-editor/>Admin Menu Editor</a> plugin handles the use-cases that the tickets address. Debate spilled over onto Twitter with participation from <a href="http://twitter.com/nacin">@nacin</a>, <a href="http://twitter.com/aaronjorbin">@aaronjorbin</a>, <a href="http://twitter.com/petemall">@petemall</a>, <a href="http://twitter.com/westi">@westi</a>, <a href="http://twitter.com/janeforshort">@janeforshort</a>, <a href="http://twitter.com/PatchesWelcome">@PatchesW