Skip to content

Instantly share code, notes, and snippets.

View jaredwilli's full-sized avatar
🏄‍♂️

Jared Williams jaredwilli

🏄‍♂️
View GitHub Profile
@remy
remy / details.js
Created April 18, 2010 22:28
Add <details> support - includes stylesheet
/**
* Note that this script is intended to be included at the *end* of the document, before </body>
*/
(function (window, document) {
if ('open' in document.createElement('details')) return;
// made global by myself to be reused elsewhere
var addEvent = (function () {
if (document.addEventListener) {
return function (el, type, fn) {
// Console arguments testing
var apc = [].slice;
(function(){
console.log( apc.call(arguments) );
})( "false", 1, undefined, null, ["foo","bar","baz"], {a:1,b:2}, false );
(function(){
console.log.call( console, apc.call(arguments) );
<?php
/*
Plugin Name: WP Comments by Post Type
Description: Enables PHP Developers to filter the comment admin at edit-comments.php by post type using a $_GET parameter. Use the "comment_admin_menu_post_types" hook to filter the array of post_type names to limit the admin menus that get a "Comments" option.
Version: 0.1
Author: Mike Schinkel
Author URI: http://mikeschinkel.com/custom-wordpress/plugins
*/
add_action('query', 'hook_to_filter_comment_admin_by_post_type');
function hook_to_filter_comment_admin_by_post_type($sql) {
<?php
/*
Description: Adds a taxonomy filter in the admin list page for a custom post type.
Written for: http://wordpress.stackexchange.com/posts/582/
By: Mike Schinkel - http://mikeschinkel.com/custom-workpress-plugins
Instructions: Put this code in your theme's functions.php file or inside your own plugin. Edit to suite your post types and taxonomies. Hope this helps...
*/
add_filter('manage_listing_posts_columns', 'add_businesses_column_to_listing_list');
function add_businesses_column_to_listing_list( $posts_columns ) {
if (!isset($posts_columns['author'])) {
<?php
/*
Plugin Name: Eliminate Plugin Clutter
Plugin URI: http://mikeschinkel.com/wordpress-plugins/eliminate-plugin-clutter/
Description: Provides an "Archiving" feature that allows you to clear currently unused plugins from view without having to delete them yet having all of your archived plugins only one "Unarchive" click away.
Version: 0.1
Author: Mike Schinkel
Author URI: http://mikeschinkel.com
*/
/*
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// HOWTO: load LABjs itself dynamically!
// inline this code in your page to load LABjs itself dynamically, if you're so inclined.
(function (global, oDOC, handler) {
var head = oDOC.head || oDOC.getElementsByTagName("head");
function LABjsLoaded() {
// do cool stuff with $LAB here
}
@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.