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');

Get post id and enqueue scripts

//Enqueue
function hypxml_enqueue_files(){
global $post;
$page_array = array(195);
if(in_array($post->ID,$page_array)){
add_action('wp_print_scripts', 'hypxml_enqueue_js');
add_action('wp_print_styles','hypxml_add_stylesheet');
}
}
add_action('wp','hypxml_enqueue_files',5,0);

function hypxml_enqueue_js(){
wp_enqueue_script('hypxml_js', HYPXML_PLUGIN . 'scripts.js',array('jquery'));
wp_enqueue_script('hypxml_sort_js', HYPXML_PLUGIN . 'jquery.tablesorter.min.js',array('jquery'));
}
function hypxml_add_stylesheet(){ wp_enqueue_style('hypxml_styles', HYPXML_PLUGIN . 'style.css'); }

Terms of Service custom field for Gravity Forms

<?php
/**
* Plugin Name: Gravity Forms Terms of Service Field
* Terms of Service Gravity Forms Custom Form Field
* Plugin URI: http://wpsmith.net/2011/plugins/how-to-create-a-custom-form-field-in-gravity-forms-with-a-terms-of-service-form-field-example/
* Donate link: http://wpsmith.net/donation
* Description: The first generation of this plugin will set a default image for post thumbnails for the Genesis framework.
* Version: 0.2 beta
* Author: Travis Smith
* Author URI: http://www.wpsmith.net/
* License: GPLv2
*
* Copyright 2012 Travis Smith (email : http://www.wpsmith.net/contact)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
*
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

// Add a custom field button to the advanced to the field editor
add_filter( 'gform_add_field_buttons', 'wps_add_tos_field' );
function wps_add_tos_field( $field_groups ) {
foreach( $field_groups as &$group ){
if( $group["name"] == "advanced_fields" ){ // to add to the Advanced Fields
//if( $group["name"] == "standard_fields" ){ // to add to the Standard Fields
//if( $group["name"] == "post_fields" ){ // to add to the Standard Fields
$group["fields"][] = array(
"class"=>"button",
"value" => __("Terms of Service", "gravityforms"),
"onclick" => "StartAddField('tos');"
);
break;
}
}
return $field_groups;
}

// Adds title to GF custom field
add_filter( 'gform_field_type_title' , 'wps_tos_title' );
function wps_tos_title( $type ) {
if ( $type == 'tos' )
return __( 'Terms of Service' , 'gravityforms' );
}

// Adds the input area to the external side
add_action( "gform_field_input" , "wps_tos_field_input", 10, 5 );
function wps_tos_field_input ( $input, $field, $value, $lead_id, $form_id ){

if ( $field["type"] == "tos" ) {
$max_chars = "";
if(!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"]))
$max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);

$input_name = $form_id .'_' . $field["id"];
$tabindex = GFCommon::get_tabindex();
$css = isset( $field['cssClass'] ) ? $field['cssClass'] : '';
return sprintf("<div class='ginput_container'><textarea readonly name='input_%s' id='%s' class='textarea gform_tos %s' $tabindex rows='10' cols='50'>%s</textarea></div>{$max_chars}", $field["id"], 'tos-'.$field['id'] , $field["type"] . ' ' . esc_attr($css) . ' ' . $field['size'] , esc_html($value));

}

return $input;
}

// Now we execute some javascript technicalitites for the field to load correctly
add_action( "gform_editor_js", "wps_gform_editor_js" );
function wps_gform_editor_js(){
?>

<script type='text/javascript'>

jQuery(document).ready(function($) {
//Add all textarea settings to the "TOS" field plus custom "tos_setting"
// fieldSettings["tos"] = fieldSettings["textarea"] + ", .tos_setting"; // this will show all fields that Paragraph Text field shows plus my custom setting

// from forms.js; can add custom "tos_setting" as well
fieldSettings["tos"] = ".label_setting, .description_setting, .admin_label_setting, .size_setting, .default_value_textarea_setting, .error_message_setting, .css_class_setting, .visibility_setting, .tos_setting"; //this will show all the fields of the Paragraph Text field minus a couple that I didn't want to appear.

//binding to the load field settings event to initialize the checkbox
jQuery(document).bind("gform_load_field_settings", function(event, field, form){
jQuery("#field_tos").attr("checked", field["field_tos"] == true);
jQuery("#field_tos_value").val(field["tos"]);
});
});

</script>
<?php
}

// Add a custom setting to the tos advanced field
add_action( "gform_field_advanced_settings" , "wps_tos_settings" , 10, 2 );
function wps_tos_settings( $position, $form_id ){

// Create settings on position 50 (right after Field Label)
if( $position == 50 ){
?>

<li class="tos_setting field_setting">

<input type="checkbox" id="field_tos" onClick="SetFieldProperty('field_tos', this.checked);" />
<label for="field_tos" class="inline">
<?php _e("Disable Submit Button", "gravityforms"); ?>
<?php gform_tooltip("form_field_tos"); ?>
</label>

</li>
<?php
}
}

//Filter to add a new tooltip
add_filter('gform_tooltips', 'wps_add_tos_tooltips');
function wps_add_tos_tooltips($tooltips){
$tooltips["form_field_tos"] = "<h6>Disable Submit Button</h6>Check the box if you would like to disable the submit button.";
$tooltips["form_field_default_value"] = "<h6>Default Value</h6>Enter the Terms of Service here.";
return $tooltips;
}

// Add a script to the display of the particular form only if tos field is being used
add_action( 'gform_enqueue_scripts' , 'wps_gform_enqueue_scripts' , 10 , 2 );
function wps_gform_enqueue_scripts( $form, $ajax ) {
// cycle through fields to see if tos is being used
foreach ( $form['fields'] as $field ) {
if ( ( $field['type'] == 'tos' ) && ( isset( $field['field_tos'] ) ) ) {
$url = plugins_url( 'gform_tos.js' , __FILE__ );
wp_enqueue_script( "gform_tos_script", $url , array("jquery"), '1.0' );
break;
}
}
}

// Add a custom class to the field li
add_action("gform_field_css_class", "custom_class", 10, 3);
function custom_class($classes, $field, $form){

if( $field["type"] == "tos" ){
$classes .= " gform_tos";
}

return $classes;
}
?>

Create WordPress Options Page

<?php
class MySettingsPage
{
/**
* Holds the values to be used in the fields callbacks
*/
private $options;

/**
* Start up
*/
public function __construct()
{
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'page_init' ) );
}

/**
* Add options page
*/
public function add_plugin_page()
{
// This page will be under "Settings"
add_options_page(
'Settings Admin',
'My Settings',
'manage_options',
'my-setting-admin',
array( $this, 'create_admin_page' )
);
}

/**
* Options page callback
*/
public function create_admin_page()
{
// Set class property
$this->options = get_option( 'my_option_name' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>My Settings</h2>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'my_option_group' );
do_settings_sections( 'my-setting-admin' );
submit_button();
?>
</form>
</div>
<?php
}

/**
* Register and add settings
*/
public function page_init()
{
register_setting(
'my_option_group', // Option group
'my_option_name', // Option name
array( $this, 'sanitize' ) // Sanitize
);

add_settings_section(
'setting_section_id', // ID
'My Custom Settings', // Title
array( $this, 'print_section_info' ), // Callback
'my-setting-admin' // Page
);

add_settings_field(
'id_number', // ID
'ID Number', // Title
array( $this, 'id_number_callback' ), // Callback
'my-setting-admin', // Page
'setting_section_id' // Section
);

add_settings_field(
'title',
'Title',
array( $this, 'title_callback' ),
'my-setting-admin',
'setting_section_id'
);
}

/**
* Sanitize each setting field as needed
*
* @param array $input Contains all settings fields as array keys
*/
public function sanitize( $input )
{
$new_input = array();
if( isset( $input['id_number'] ) )
$new_input['id_number'] = absint( $input['id_number'] );

if( isset( $input['title'] ) )
$new_input['title'] = sanitize_text_field( $input['title'] );

return $new_input;
}

/**
* Print the Section text
*/
public function print_section_info()
{
print 'Enter your settings below:';
}

/**
* Get the settings option array and print one of its values
*/
public function id_number_callback()
{
printf(
'<input type="text" id="id_number" name="my_option_name[id_number]" value="%s" />',
isset( $this->options['id_number'] ) ? esc_attr( $this->options['id_number']) : ''
);
}

/**
* Get the settings option array and print one of its values
*/
public function title_callback()
{
printf(
'<input type="text" id="title" name="my_option_name[title]" value="%s" />',
isset( $this->options['title'] ) ? esc_attr( $this->options['title']) : ''
);
}
}

if( is_admin() )
$my_settings_page = new MySettingsPage();

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;
}
}
?>

Custom Post Type Template

<?php
/*
Plugin Name: Hyp Coaches
Plugin URI: http://hyperspatial.com
Description: Custom post type for coaches
Author: Adam J Nowak
Version: 1.0
Author URI: http://hyperspatial.com
*/

//File Paths
define('HYPC_PLUGIN',WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)) . '/');
define('HYPC_PLUGIN_SERVERPATH',dirname(__FILE__) . '/');

$hyp_coaches = new HypCoaches();

class HypCoaches{
public function __construct(){
add_action('init',array(&$this,'init'));
add_filter('post_updated_messages',array(&$this,'updated_messages'));
//add_action('add_meta_boxes',array(&$this,'add_meta_boxes'));
//add_action('save_post',array(&$this,'save_post'));
}
public function init(){
$labels = array(
'name' => _x('Coaches','post type general name','terra'),
'singular_name' => _x('Coach','post type singular name','terra'),
'add_new' => _x('Add New','coach','terra'),
'add_new_item' => __('Add New Coach','terra'),
'edit_item' => __('Edit Coach','terra'),
'new_item' => __('New Coach','terra'),
'all_items' => __('All Coaches','terra'),
'view_item' => __('View Coach','terra'),
'search_items' => __('Search Coaches','terra'),
'not_found' => __('No coaches found','terra'),
'not_found_in_trash' => __('No coaches found in Trash','terra'),
'parent_item_colon' => '',
'menu_name' => __('Coaches','terra')
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => null,
'menu_icon' => HYPC_PLUGIN . 'icon-coach.png',
'supports' => array('title','editor','author','thumbnail','excerpt','comments','custom-fields','revisions')
);
register_post_type('coach',$args);

//Taxonomy
$labels = array(
'name' => _x( 'Subjects', 'taxonomy general name' ),
'singular_name' => _x( 'Subject', 'taxonomy singular name' ),
'search_items' => __( 'Search Subjects' ),
'all_items' => __( 'All Subjects' ),
'parent_item' => __( 'Parent Subject' ),
'parent_item_colon' => __( 'Parent Subject:' ),
'edit_item' => __( 'Edit Subject' ),
'update_item' => __( 'Update Subject' ),
'add_new_item' => __( 'Add New Subject' ),
'new_item_name' => __( 'New Subject Name' ),
'menu_name' => __( 'Subject' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
//'rewrite' => array( 'slug' => 'slugname' ),
);
register_taxonomy('subjects','coach',$args);
}

/* Updated Messages */
public function updated_messages($messages){
global $post, $post_ID;
$messages['coach'] = array(
0 => '',
1 => sprintf( __('Coach updated. <a href="%s">View coach</a>'), esc_url( get_permalink($post_ID) ) ),
2 => __('Custom field updated.'),
3 => __('Custom field deleted.'),
4 => __('Coach updated.'),
5 => isset($_GET['revision']) ? sprintf( __('Coach restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __('Coach published. <a href="%s">View coach</a>'), esc_url( get_permalink($post_ID) ) ),
7 => __('Coach saved.'),
8 => sprintf( __('Coach submitted. <a target="_blank" href="%s">Preview coach</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __('Coach scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview coach</a>'),
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __('Coach draft updated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);
return $messages;
}

/* Add meta box */
public function add_meta_boxes(){
add_meta_box(
'slug_name',
'Title Text',
array(&$this,'meta_box_1'),
'coach',
'advanced',
'high'
);
}

/* Meta box content */
public function meta_box_1($post){
wp_nonce_field(plugin_basename(__FILE__),'hyp_noncename');
$this->print_mce($post->ID,'metaname');
}

/* MCE */
private function print_mce($post_id,$metaname){
$content = get_post_meta($post_id,$metaname,1);
$wp_editor_args = array(
'teeny' => 1,
'textarea_rows' => 4,
'media_buttons' => true,
'dfw' => false,
'tinymce' => array(
'theme_advanced_buttons1' => 'formatselect,fontsizeselect,forecolor,backcolor|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,undo,redo,|,spellchecker',
'theme_advanced_buttons2' => 'cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|,fullscreen',
'theme_advanced_buttons3' => '',
'theme_advanced_buttons4' => ''
),
'quicktags' => true
);
wp_editor($content,$metaname . '_html',$wp_editor_args);
}

/* Save Postdata */
public function save_postdata($post_id){
if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if($_POST['post_type'] != 'coach') return $post_id;
if(!wp_verify_nonce($_POST['hyp_noncename'],plugin_basename(__FILE__))) return $post_id;
if(!current_user_can('edit_post',$post_id)) return $post_id;
update_post_meta($post_id,'slug_name',$_POST['metaname_html']);
}
}//END HypCoach
?>

Post to third party after submit

<?php

//Post Form
function post_form($entry,$form){
$post_url = 'http://mydomain.com/mypage';
$body = array(
'firstName' => $entry[1],
'lastName' => $entry[2],
'email' => $entry[3]
);
send_form($post_url,$body);
}

//Send Form
function send_form($post_url,$body){
$request = new WP_Http();
$response = $request->post($post_url, array('body' => $body));
}

//Form Actions
add_action('gform_after_submission', 'post_form', 10, 2);

?>