Skip to content

Instantly share code, notes, and snippets.

{
"name": "johnpbloch/test-4",
"license": "MIT",
"authors": [
{
"name": "John P Bloch",
"email": "me@johnpbloch.com"
}
],
"repositories":[
{
"name": "10up",
"hostname": [
"10up.dev",
"www.10up.dev"
],
"maintainers": [
{
"name": "Taylor Lovett",
"email": "taylor.lovett@10up.com"
@johnpbloch
johnpbloch / short-circuit.php
Created November 21, 2011 20:10
Short Circuit a post save in WordPress and give the user a notice saying why.
<?php
namespace JPB;
function wp_insert_post_data( $data, $postarr ){
if($data['foo'] !== 'bar' || $data['baz'] !== 'bat'){
wp_redirect( add_query_arg( array( 'post' => $data['ID'], 'action' => 'edit', 'message' => 11 ), admin_url( 'post.php' ) ) );
exit;
}
return $data;
@johnpbloch
johnpbloch / tadv-ms-fixer.php
Created December 9, 2011 00:30
TinyMCE Advanced Network Fixer
<?php
/*
* Plugin Name: TinyMCE Advanced Multisite Fixer
* Description: Forces TinyMCE Advanced to use site options for its settings when it's network activated.
* Version: 0.1
* Author: John P. Bloch
* Author URI: http://www.johnpbloch.com/
*/
@johnpbloch
johnpbloch / node.js
Created January 19, 2012 20:55 — forked from lazypower/node.js
// Define a JSON data-structure that will look and perform like the real deal
// What is common to every post? Lets examine the details:
var forumData = { // Defining the object structure
"Posts" : [ // array of Posts
// single post item in the array
{
// definition of properties
"id" : "1",
"user" : "Melvin",
"title" : "Yes, I beleive you have my stapler...",
@johnpbloch
johnpbloch / JPB_Options.php
Created May 12, 2012 01:49
An abstract options class. To use, extend this class. All public properties defined for the class will be used as the keys in the options array. Comes with helper functions for updating, etc.
<?php
abstract class JPB_Options {
/**
* The database option name value. Must be declared in extending classes.
* @var string
*/
protected $_option_name = null;
@johnpbloch
johnpbloch / .htaccess
Created June 20, 2012 14:26
.htaccess Extras for WordPress-Skeleton
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(wp-admin/.*)$ /wp/$1 [L]
RewriteRule ^(wp-[^/]+\.php)$ /wp/$1 [L]
RewriteRule ^xmlrpc\.php$ /wp/xmlrpc.php [L]
RewriteRule ^(wp-includes/.*)$ /wp/$1 [L]
</IfModule>
# BEGIN WordPress
@johnpbloch
johnpbloch / plugin.php
Created October 25, 2012 16:49
Automatically add featured image
<?php
function _jpb_featured_image_setup(){
define( 'JPB_THEME_REALLY_SUPPORTS_POST_THUMBNAILS', current_theme_supports('post-thumbnails') );
if(!JPB_THEME_REALLY_SUPPORTS_POST_THUMBNAILS){
add_theme_support( 'post-thumbnails' );
}
}
add_action('after_setup_theme', '_jpb_featured_image_setup', 101);
<?php
if (WP_STAGE == 'production') {
return;
}
if(!class_exists('WP_Stack_Plugin')){class WP_Stack_Plugin{function hook($h){$p=10;$m=$this->sanitize_method($h);$b=func_get_args();unset($b[0]);foreach((array)$b as $a){if(is_int($a))$p=$a;else $m=$a;}return add_action($h,array($this,$m),$p,999);}private function sanitize_method($m){return str_replace(array('.','-'),array('_DOT_','_DASH_'),$m);}}}
class AVM_Staging_Url_Rewrite extends WP_Stack_Plugin {
console.log('Here');