Add meta box to attachment

<?php

$hypbi_attachment_meta = new HypbiAttachmentMeta();

class HypbiAttachmentMeta{
public function __construct(){
add_filter('attachment_fields_to_edit',array($this,'add_image_meta_field'),null,2);
add_filter('attachment_fields_to_save',array($this,'save_image_meta_field'),null,2);
}
public function add_image_meta_field($form_fields,$post){
$form_fields['hypbi_option_code'] = array(
'label' => __('Build It Option Code'),
'value' => get_post_meta($post->ID,'_hypbi_option_code', true),
'helps' => __('Comma separated option code. For multiple options separate with pipe |'),
);
return $form_fields;
}
public function save_image_meta_field($post,$attachment){
if(isset($attachment['hypbi_option_code'])) update_post_meta($post['ID'],'_hypbi_option_code',$attachment['hypbi_option_code']);
return $post;
}
}

?>

Shortcode AutoP Savior

function ter_shortcode_content_filter($content){
$block = join('|',array('one-third','grid'));
$rep = preg_replace("/(<p>)?[($block)(s[^]]+)?](</p>|<br />)?/","[$2$3]",$content);
$rep = preg_replace("/(<p>)?[/($block)](</p>|<br />)?/","[/$2]",$rep);
return $rep;
}
add_filter('the_content','ter_shortcode_content_filter');

Post Meta Filter

<?php
/*
Plugin Name: CFInterceptor
Plugin URI: http://hyperspatial.com
Description: CFInterceptor is used for wordpress filters that need to load early in execution
Version: 1.0
Author: Adam J Nowak
Author URI: http://hyperspatial.com
License: GPL2
*/

/*
* CFInterceptor is designed to work with the CFProjectFilters class
*
* Calling actions/filters here registers them before the plugins are loaded
* Write callbacks in the CFProjectFilters class here: /wp-content/plugins/cf-project/includes/project-filters.php
*/

//Project Type Meta Filter
add_filter( 'get_post_metadata', array( 'CFProjectFilters', 'project_type_meta_filter' ), 10, 4 );

?>

<?php
/*
* CFProjectFilters is a class to package action and filter callbacks
*
* WP add_action() or add_filter() can be called in /wp-content/mu-plugins/interceptor.php
* Calling in the mu-plugins forces the actions/filters to be registered before the plugins are loaded
*/

class CFProjectFilters{
/* ~~~~~~~~~~ Project Type Meta Filter ~~~~~~~~~~ */
public function project_type_meta_filter( $metadata, $object_id, $meta_key, $single ){
if( $meta_key != '_project_type' ) return;
$meta_cache = wp_cache_get( $object_id, 'post_meta' );
$project_type = $meta_cache['_project_type'][0];

if( $project_type == 3 ) $metadata = 'Project type 3 is now a string, yay';
return $metadata;
}
}
?>

Replace broken images

//Dev image replacement to fix broken images on dev site
cfReplaceDevImages('devdomain.us','http://livedomain.com');

function cfReplaceDevImages(devDomain,liveDomainUrl){
if(window.location.host.indexOf(devDomain) == -1) return false;
jQuery(window).bind('load', function(){
jQuery('img').each(function(){
if((typeof this.naturalWidth != "undefined" && this.naturalWidth == 0) || this.readyState == 'uninitialized'){
var oldUrl = jQuery(this).attr('src').replace(/^.*//[^/]+/, '');
var newUrl = liveDomainUrl + oldUrl;
jQuery(this).attr('src',newUrl);
}
});
})
}