Skip to content

Instantly share code, notes, and snippets.

Mike Schinkel mikeschinkel

Block or report user

Report or block mikeschinkel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mikeschinkel
mikeschinkel / register-form-benchmark.php
Last active Aug 29, 2015
Benchmark for different approaches to registering forms.
View register-form-benchmark.php
<?php
include( __DIR__ . '/wp-load.php' );
const MAXTIMES = 10000;
class WP_Form {
static $forms = array();
var $object_id;
var $form_name;
@mikeschinkel
mikeschinkel / class-object-classifier.php
Last active Aug 29, 2015
Proposed WP_Object_Classifier for WordPress #metadata.
View class-object-classifier.php
<?php
/**
* Class WP_Object_Classifier
*/
final class WP_Object_Classifier {
/**
* @var bool
*/
var $object_type = false;
@mikeschinkel
mikeschinkel / post-meta-api-proposal.md
Created May 14, 2014
Proposal for interface of Post Meta in the WordPress REST API. - Make comment at: http://wpapiteam.wordpress.com/2014/05/12/handling-post-meta/#comment-435
View post-meta-api-proposal.md

##Data: { "post_meta": [ { "ID": 33, "key": "my_key", "value": "value1" }, { "ID": 34,

@mikeschinkel
mikeschinkel / unused-in-foo.php
Last active Aug 29, 2015
PhpStorm Inspection Claim Variable is Unused when it is Used
View unused-in-foo.php
<?php
function get_foo( $state, $method ) {
$value = null;
if ( method_exists( $this, $method ) ) {
/**
* PhpStorm INCORRECTLY identifies $value as NOT being used later.
@mikeschinkel
mikeschinkel / object-fail.php
Created Jun 21, 2015
PhpStorm incorrect flags class "Object" inside a Namespace with "Expected Object, got Object"
View object-fail.php
namespace Whatever {
class Object {
/**
* @param Object $object
*/
function foo( $object ) {
}
@mikeschinkel
mikeschinkel / 1-example.php
Last active Aug 29, 2015
Examples of implementing helper methods for WPLib as instance methods (vs. static methods)
View 1-example.php
<?php
if ( WPLib::is_development() ) {
define( 'WP_DEBUG', true );
} else {
define( 'WP_DEBUG', false );
View vimeo-shortcode-for-wordpress-pressthis.php
/*
Makes WordPress' PressThis use vimeo short code instead of <object>/<embed> tags.
Add this to the WordPress theme's function.php file.
Addresses the Vimeo question from StackExchange here:
http://webapps.stackexchange.com/questions/3834/customizing-press-this-quick-posting-for-wordpress
*/
add_action('admin_print_footer_scripts','greatjakes_admin_print_footer_scripts');
function greatjakes_admin_print_footer_scripts() {
if ($_SERVER['PHP_SELF']=='/wp-admin/press-this.php') {
$script=<<<SCRIPT
View wp-all-posts-for-any-term-in-a-taxonomy.php
<?php
/*
wp-all-posts-for-any-term-in-a-taxonomy.php
This is an example showing a hook used to add the ability to use "any" as a term to match all terms for a taxonomy.
It will run as a standalone file in the root of a WordPress 3.0 install with a URL that looks like:
http://example.com/wp-all-posts-for-any-term-in-a-taxonomy.php
It was written to address this question:
@mikeschinkel
mikeschinkel / gist:493178
Created Jul 28, 2010
Sample SQL file to return menu items for a post in WordPress 3.0
View gist:493178
<?php
include "wp-load.php";
$post_id = $_GET['post'];
$menu_id = $_GET['menu'];
global $wpdb;
$result = $wpdb->get_results($wpdb->prepare("SELECT t.term_id as menu_id,
t.name AS menu_name,
View gist:493195
<?php
include "wp-load.php";
$post_id = $_GET['post'];
$menu_id = $_GET['menu'];
$term = get_term($menu_id, 'nav_menu');
$menu_items = new WP_Query(
You can’t perform that action at this time.