Version Description
- Added support for both Gravity Forms v1.5 beta and v.1.4.5
- Now supports linking taxonomies to Drop Downs, Multiple Choice or Checkboxes
- Integrated with GF v1.5 hooks for easier configuration (thanks to Alex and Carl from RocketGenius)
- Support linking more than 1 taxonomy to a form
- To keep in line with the GF standards, mapping a form to a CPT in GF v1.4.5 can now be done via the 'post title' field
Download this release
Release Info
Developer | bradvin |
Plugin | Gravity Forms + Custom Post Types |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 2.0
- gfcptaddon.php +158 -0
- gfcptaddon_1-4.php +48 -0
- gfcptaddon_1-5.php +181 -0
- gfcptaddonbase.php +207 -0
- gravity-forms-custom-post-type-mappings.php +0 -168
- readme.txt +40 -17
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- screenshot-6.png +0 -0
gfcptaddon.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Gravity Forms + Custom Post Types
|
4 |
+
Plugin URI: http://themergency.com/plugins/gravity-forms-custom-post-types/
|
5 |
+
Description: Allows a simple way to map a Gravity Form post entry to a custom post type. Also include custom taxonomies.
|
6 |
+
Version: 2.0
|
7 |
+
Author: Brad Vincent
|
8 |
+
Author URI: http://themergency.com/
|
9 |
+
License: GPL2
|
10 |
+
|
11 |
+
------------------------------------------------------------------------
|
12 |
+
Copyright 2011 Themergency
|
13 |
+
|
14 |
+
This program is free software; you can redistribute it and/or modify
|
15 |
+
it under the terms of the GNU General Public License as published by
|
16 |
+
the Free Software Foundation; either version 2 of the License, or
|
17 |
+
(at your option) any later version.
|
18 |
+
|
19 |
+
This program is distributed in the hope that it will be useful,
|
20 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
+
GNU General Public License for more details.
|
23 |
+
|
24 |
+
You should have received a copy of the GNU General Public License
|
25 |
+
along with this program; if not, write to the Free Software
|
26 |
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
27 |
+
*/
|
28 |
+
|
29 |
+
// Include Gravity Forms
|
30 |
+
if (!class_exists('RGForms'))
|
31 |
+
@include_once(WP_PLUGIN_DIR . '/gravityforms/gravityforms.php');
|
32 |
+
if (!class_exists('RGFormsModel'))
|
33 |
+
@include_once(WP_PLUGIN_DIR . '/gravityforms/forms_model.php');
|
34 |
+
if (!class_exists('GFCommon'))
|
35 |
+
@include_once(WP_PLUGIN_DIR . '/gravityforms/common.php');
|
36 |
+
|
37 |
+
add_action('init', array('GFCPTAddon', 'init'));
|
38 |
+
add_action('admin_notices', array('GFCPTAddon', 'admin_warnings'));
|
39 |
+
|
40 |
+
class GFCPTAddon {
|
41 |
+
|
42 |
+
private static $name = 'Gravity Forms + Custom Post Types';
|
43 |
+
private static $slug = 'GFCPTAddon';
|
44 |
+
private static $version = '2.0';
|
45 |
+
private static $min_gravityforms_version = '1.4.5';
|
46 |
+
|
47 |
+
//Plugin starting point. Will load appropriate files
|
48 |
+
public static function init(){
|
49 |
+
|
50 |
+
if(self::is_gravityforms_installed()){
|
51 |
+
|
52 |
+
global $gf_cpt_addon;
|
53 |
+
|
54 |
+
//include the base class
|
55 |
+
require_once(self::get_base_path() . '/gfcptaddonbase.php');
|
56 |
+
|
57 |
+
//then include the version specific class
|
58 |
+
if ( self::check_gravityforms_version( self::$min_gravityforms_version, '>' ) ) {
|
59 |
+
require_once(self::get_base_path() . '/gfcptaddon_1-5.php');
|
60 |
+
$gf_cpt_addon = new GFCPTAddon1_5();
|
61 |
+
} else {
|
62 |
+
require_once(self::get_base_path() . '/gfcptaddon_1-4.php');
|
63 |
+
$gf_cpt_addon = new GFCPTAddon1_4();
|
64 |
+
}
|
65 |
+
|
66 |
+
//start me up!
|
67 |
+
$gf_cpt_addon->init();
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
//display admin warnings if GF is not the correct version or GF is not installed
|
72 |
+
public static function admin_warnings() {
|
73 |
+
if ( !self::is_gravityforms_installed() ) {
|
74 |
+
$message = __('requires Gravity Forms to be installed.', self::$slug);
|
75 |
+
} else if ( !self::is_gravityforms_supported() ) {
|
76 |
+
$message = __('requires a minimum Gravity Forms version of ', self::$slug) . self::$min_gravityforms_version;
|
77 |
+
}
|
78 |
+
|
79 |
+
if (empty($message)) {
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
?>
|
83 |
+
<div class="error">
|
84 |
+
<p>
|
85 |
+
<?php _e('The plugin ', self::$slug); ?><strong><?php echo self::$name; ?></strong> <?php echo $message; ?><br />
|
86 |
+
<?php _e('Please ',self::$slug); ?><a href="http://bit.ly/getgravityforms"><?php _e(' download the latest version ',self::$slug); ?></a><?php _e(' of Gravity Forms and try again.',self::$slug) ?>
|
87 |
+
</p>
|
88 |
+
</div>
|
89 |
+
<?php
|
90 |
+
}
|
91 |
+
|
92 |
+
/*
|
93 |
+
* Check if GF is installed
|
94 |
+
*/
|
95 |
+
private static function is_gravityforms_installed(){
|
96 |
+
return class_exists( 'RGForms' );
|
97 |
+
}
|
98 |
+
|
99 |
+
/*
|
100 |
+
* Check if the installed version of GF is supported
|
101 |
+
*/
|
102 |
+
private static function is_gravityforms_supported(){
|
103 |
+
return self::check_gravityforms_version( self::$min_gravityforms_version,'>=' );
|
104 |
+
}
|
105 |
+
|
106 |
+
/*
|
107 |
+
* Do a GF version compare
|
108 |
+
*/
|
109 |
+
private static function check_gravityforms_version($version, $operator){
|
110 |
+
if(class_exists('GFCommon')){
|
111 |
+
return version_compare( GFCommon::$version, $version, $operator );
|
112 |
+
}
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
|
116 |
+
/*
|
117 |
+
* Returns the url of the plugin's root folder
|
118 |
+
*/
|
119 |
+
protected function get_base_url(){
|
120 |
+
return plugins_url(null, __FILE__);
|
121 |
+
}
|
122 |
+
|
123 |
+
/*
|
124 |
+
* Returns the physical path of the plugin's root folder
|
125 |
+
*/
|
126 |
+
protected function get_base_path(){
|
127 |
+
$folder = basename(dirname(__FILE__));
|
128 |
+
return WP_PLUGIN_DIR . '/' . $folder;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* starts_with
|
133 |
+
* Tests if a text starts with an given string.
|
134 |
+
*
|
135 |
+
* @param string
|
136 |
+
* @param string
|
137 |
+
* @return bool
|
138 |
+
*/
|
139 |
+
public static function starts_with($haystack, $needle){
|
140 |
+
return strpos($haystack, $needle) === 0;
|
141 |
+
}
|
142 |
+
|
143 |
+
/*
|
144 |
+
* returns true if a needle can be found in a haystack
|
145 |
+
*/
|
146 |
+
public static function str_contains($haystack, $needle) {
|
147 |
+
if (empty($haystack) || empty($needle))
|
148 |
+
return false;
|
149 |
+
|
150 |
+
$pos = strpos(strtolower($haystack), strtolower($needle));
|
151 |
+
|
152 |
+
if ($pos === false)
|
153 |
+
return false;
|
154 |
+
else
|
155 |
+
return true;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
?>
|
gfcptaddon_1-4.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('GFCPTAddon1_4')) {
|
4 |
+
|
5 |
+
class GFCPTAddon1_4 extends GFCPTAddonBase {
|
6 |
+
|
7 |
+
/*
|
8 |
+
* Override. Extract taxonomy from CSS class name
|
9 |
+
*/
|
10 |
+
function get_field_taxonomy( $field ) {
|
11 |
+
return self::extract_value( $field['cssClass'], 'taxonomy-' );
|
12 |
+
}
|
13 |
+
|
14 |
+
/*
|
15 |
+
* Override. Extract post type from CSS class name
|
16 |
+
*/
|
17 |
+
function get_form_post_type( $form ) {
|
18 |
+
$cpt = self::extract_value( $form['cssClass'], 'posttype-' );
|
19 |
+
if ( !$cpt ) {
|
20 |
+
//try to extract it from the post title field
|
21 |
+
foreach ( $form['fields'] as $field ) {
|
22 |
+
if ( $field['type'] == 'post_title' )
|
23 |
+
return self::extract_value( $field['cssClass'], 'posttype-' );
|
24 |
+
|
25 |
+
}
|
26 |
+
}
|
27 |
+
return $cpt;
|
28 |
+
}
|
29 |
+
|
30 |
+
/*
|
31 |
+
* extract the css class name by prefix
|
32 |
+
*/
|
33 |
+
private static function extract_value( $class_names, $prefix ) {
|
34 |
+
$classes = explode(' ', $class_names);
|
35 |
+
|
36 |
+
foreach($classes as $class) {
|
37 |
+
//check if the class starts with $prefix
|
38 |
+
if(GFCPTAddon::starts_with($class, $prefix)) {
|
39 |
+
return str_replace($prefix, '', $class);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
?>
|
gfcptaddon_1-5.php
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('GFCPTAddon1_5')) {
|
4 |
+
|
5 |
+
/*
|
6 |
+
* GFCPT Addon class targetting version 1.5 of Gravity Forms
|
7 |
+
*/
|
8 |
+
class GFCPTAddon1_5 extends GFCPTAddonBase {
|
9 |
+
|
10 |
+
/*
|
11 |
+
* Override. Include a couple more hooks
|
12 |
+
*/
|
13 |
+
public function init() {
|
14 |
+
//hook up the defaults
|
15 |
+
parent::init();
|
16 |
+
|
17 |
+
//then add these for 1.5...
|
18 |
+
//add our advanced options to the form builder
|
19 |
+
add_action('gform_field_advanced_settings', array(&$this, 'render_field_advanced_settings'), 10, 2);
|
20 |
+
|
21 |
+
//include javascript for the form builder
|
22 |
+
add_action('gform_editor_js', array(&$this, 'render_editor_js'));
|
23 |
+
|
24 |
+
// filter to add a new tooltip
|
25 |
+
add_filter('gform_tooltips', array(&$this, 'add_gf_tooltips'));
|
26 |
+
}
|
27 |
+
|
28 |
+
/*
|
29 |
+
* Override. Gets the taxonomy from our new field value
|
30 |
+
*/
|
31 |
+
function get_field_taxonomy( $field ) {
|
32 |
+
return $field['populateTaxonomy'];
|
33 |
+
}
|
34 |
+
|
35 |
+
/*
|
36 |
+
* Override. Gets the custom post type from the post title field value
|
37 |
+
*/
|
38 |
+
function get_form_post_type( $form ) {
|
39 |
+
foreach ( $form['fields'] as $field ) {
|
40 |
+
if ( $field['type'] == 'post_title' && $field['saveAsCPT'] )
|
41 |
+
return $field['saveAsCPT'];
|
42 |
+
}
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
|
46 |
+
/*
|
47 |
+
* Add tooltips for the new field values
|
48 |
+
*/
|
49 |
+
function add_gf_tooltips($tooltips){
|
50 |
+
$tooltips["form_field_custom_taxonomy"] = "<h6>Populate with a Taxonomy</h6>Check this box to populate this field from a custom taxonomy.";
|
51 |
+
$tooltips["form_field_custom_post_type"] = "<h6>Save As Custom Post Type</h6>Check this box to save this form to a custom post type.";
|
52 |
+
return $tooltips;
|
53 |
+
}
|
54 |
+
|
55 |
+
/*
|
56 |
+
* Add some advanced settings to the fields
|
57 |
+
*/
|
58 |
+
function render_field_advanced_settings($position, $form_id){
|
59 |
+
|
60 |
+
if($position == 50){
|
61 |
+
?>
|
62 |
+
<li class="populate_with_taxonomy_field_setting field_setting" style="display:list-item;">
|
63 |
+
<input type="checkbox" id="field_enable_populate_with_taxonomy" />
|
64 |
+
<label for="field_enable_populate_with_taxonomy" class="inline">
|
65 |
+
<?php _e("Populate with a Taxonomy", "gravityforms"); ?>
|
66 |
+
</label>
|
67 |
+
<?php gform_tooltip("form_field_custom_taxonomy") ?><br />
|
68 |
+
<select id="field_populate_taxonomy" onchange="SetFieldProperty('populateTaxonomy', jQuery(this).val());" style="margin-top:10px; display:none;">
|
69 |
+
<option value="" style="color:#999;">Select a Taxonomy</option>
|
70 |
+
<?php
|
71 |
+
$args=array(
|
72 |
+
'public' => true,
|
73 |
+
'_builtin' => false
|
74 |
+
);
|
75 |
+
$taxonomies = get_taxonomies($args, 'objects');
|
76 |
+
foreach($taxonomies as $taxonomy): ?>
|
77 |
+
<option value="<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></option>
|
78 |
+
<?php endforeach; ?>
|
79 |
+
</select>
|
80 |
+
|
81 |
+
</li>
|
82 |
+
<li class="custom_post_type_field_setting field_setting" style="display:list-item;">
|
83 |
+
<input type="checkbox" id="field_enable_custom_post_type" />
|
84 |
+
<label for="field_enable_custom_post_type" class="inline">
|
85 |
+
<?php _e("Save As Custom Post Type", "gravityforms"); ?>
|
86 |
+
</label>
|
87 |
+
<?php gform_tooltip("form_field_custom_post_type") ?><br />
|
88 |
+
<select id="field_populate_custom_post_type" onchange="SetFieldProperty('saveAsCPT', jQuery(this).val());" style="margin-top:10px; display:none;">
|
89 |
+
<option value="" style="color:#999;">Select a Custom Post Type</option>
|
90 |
+
<?php
|
91 |
+
$args=array(
|
92 |
+
'public' => true
|
93 |
+
);
|
94 |
+
$post_types = get_post_types($args, 'objects');
|
95 |
+
foreach($post_types as $post_type): ?>
|
96 |
+
<option value="<?php echo $post_type->name; ?>"><?php echo $post_type->label; ?></option>
|
97 |
+
<?php endforeach; ?>
|
98 |
+
</select>
|
99 |
+
|
100 |
+
</li>
|
101 |
+
<?php
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
/*
|
107 |
+
* render some custom JS to get the settings to work
|
108 |
+
*/
|
109 |
+
function render_editor_js(){
|
110 |
+
?>
|
111 |
+
<script type='text/javascript'>
|
112 |
+
|
113 |
+
jQuery(document).bind("gform_load_field_settings", function(event, field, form){
|
114 |
+
//only show taxonomy for selects and radios
|
115 |
+
var valid_types = new Array('select', 'radio', 'checkbox');
|
116 |
+
if(jQuery.inArray(field['type'], valid_types) != -1) {
|
117 |
+
var $taxonomy_setting_container = jQuery(".populate_with_taxonomy_field_setting");
|
118 |
+
//show the setting container!
|
119 |
+
$taxonomy_setting_container.show();
|
120 |
+
|
121 |
+
//get the saved taxonomy
|
122 |
+
var populateTaxonomy = (typeof field['populateTaxonomy'] != 'undefined' && field['populateTaxonomy'] != '') ? field['populateTaxonomy'] : false;
|
123 |
+
|
124 |
+
if (populateTaxonomy != false) {
|
125 |
+
//check the checkbox if previously checked
|
126 |
+
$taxonomy_setting_container.find("input:checkbox").attr("checked", "checked");
|
127 |
+
//set the select and show
|
128 |
+
$taxonomy_setting_container.find("select").val(populateTaxonomy).show();
|
129 |
+
} else {
|
130 |
+
$taxonomy_setting_container.find("input:checkbox").removeAttr("checked");
|
131 |
+
$taxonomy_setting_container.find("select").val('').hide();
|
132 |
+
}
|
133 |
+
} else if (field['type'] == 'post_title') {
|
134 |
+
var $cpt_setting_container = jQuery(".custom_post_type_field_setting");
|
135 |
+
|
136 |
+
$cpt_setting_container.show();
|
137 |
+
|
138 |
+
var saveAsCPT = (typeof field['saveAsCPT'] != 'undefined' && field['saveAsCPT'] != '') ? field['saveAsCPT'] : false;
|
139 |
+
|
140 |
+
if (saveAsCPT != false) {
|
141 |
+
//check the checkbox if previously checked
|
142 |
+
$cpt_setting_container.find("input:checkbox").attr("checked", "checked");
|
143 |
+
//set the select and show
|
144 |
+
$cpt_setting_container.find("select").val(saveAsCPT).show();
|
145 |
+
} else {
|
146 |
+
$cpt_setting_container.find("input:checkbox").removeAttr("checked");
|
147 |
+
$cpt_setting_container.find("select").val('').hide();
|
148 |
+
}
|
149 |
+
}
|
150 |
+
});
|
151 |
+
|
152 |
+
jQuery(".populate_with_taxonomy_field_setting input:checkbox").click(function() {
|
153 |
+
var checked = jQuery(this).is(":checked");
|
154 |
+
var $select = jQuery(this).parent(".populate_with_taxonomy_field_setting:first").find("select");
|
155 |
+
if(checked){
|
156 |
+
$select.slideDown();
|
157 |
+
} else {
|
158 |
+
SetFieldProperty('populateTaxonomy','');
|
159 |
+
$select.slideUp();
|
160 |
+
}
|
161 |
+
});
|
162 |
+
|
163 |
+
jQuery(".custom_post_type_field_setting input:checkbox").click(function() {
|
164 |
+
var checked = jQuery(this).is(":checked");
|
165 |
+
var $select = jQuery(this).parent(".custom_post_type_field_setting:first").find("select");
|
166 |
+
if(checked){
|
167 |
+
$select.slideDown();
|
168 |
+
} else {
|
169 |
+
SetFieldProperty('saveAsCPT','');
|
170 |
+
$select.slideUp();
|
171 |
+
}
|
172 |
+
});
|
173 |
+
|
174 |
+
</script>
|
175 |
+
<?php
|
176 |
+
}
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
}
|
181 |
+
?>
|
gfcptaddonbase.php
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('GFCPTAddonBase')) {
|
4 |
+
|
5 |
+
/*
|
6 |
+
* Base class for the GFCPT Addon. All common code is in here and differences per version are overrided
|
7 |
+
*/
|
8 |
+
class GFCPTAddonBase {
|
9 |
+
|
10 |
+
/*
|
11 |
+
* Main initilize method for wiring up all the hooks
|
12 |
+
*/
|
13 |
+
public function init() {
|
14 |
+
//alter the way forms are rendered by inserting taxomony dropdowns,radios and checkboxes
|
15 |
+
add_filter('gform_pre_render' , array(&$this, 'setup_form') );
|
16 |
+
|
17 |
+
//alter the form for submission - this is mainly for checkboxes
|
18 |
+
add_filter('gform_pre_submission_filter', array(&$this, 'setup_form') );
|
19 |
+
|
20 |
+
//set the post type when saving a post
|
21 |
+
add_filter("gform_post_data", array(&$this, 'set_post_type'), 10, 2);
|
22 |
+
|
23 |
+
//intercept the form save and save any taxonomy links if needed
|
24 |
+
add_action('gform_post_submission', array(&$this, 'save_taxonomies'), 10, 2);
|
25 |
+
}
|
26 |
+
|
27 |
+
/*
|
28 |
+
* Setup the form with any taxonomies
|
29 |
+
*/
|
30 |
+
function setup_form( $form ) {
|
31 |
+
//loop thru all fields
|
32 |
+
foreach($form['fields'] as &$field) {
|
33 |
+
|
34 |
+
//see if the field is using a taxonomy
|
35 |
+
$taxonomy = $this->get_field_taxonomy( $field );
|
36 |
+
|
37 |
+
if(!$taxonomy)
|
38 |
+
continue;
|
39 |
+
|
40 |
+
$this->setup_taxonomy_field( $field, $taxonomy );
|
41 |
+
}
|
42 |
+
|
43 |
+
return $form;
|
44 |
+
}
|
45 |
+
|
46 |
+
/*
|
47 |
+
* Set the post type (if set)
|
48 |
+
*/
|
49 |
+
function set_post_type( $post_data, $form ) {
|
50 |
+
|
51 |
+
//check if the form saves a post
|
52 |
+
if ( $this->is_form_a_post_form($form) ) {
|
53 |
+
$target_post_type = $this->get_form_post_type( $form );
|
54 |
+
|
55 |
+
if ($target_post_type)
|
56 |
+
$post_data["post_type"] = $target_post_type;
|
57 |
+
}
|
58 |
+
return $post_data;
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
/*
|
63 |
+
* Checks if a form includes a 'post field'
|
64 |
+
*/
|
65 |
+
function is_form_a_post_form( $form ) {
|
66 |
+
foreach ($form["fields"] as $field) {
|
67 |
+
if(in_array($field["type"],
|
68 |
+
array("post_category","post_title","post_content",
|
69 |
+
"post_excerpt","post_tags","post_custom_fields","post_image")))
|
70 |
+
return true;
|
71 |
+
}
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
/*
|
76 |
+
* override this to get the post type for a form
|
77 |
+
*/
|
78 |
+
function get_form_post_type( $form ) {
|
79 |
+
return null;
|
80 |
+
}
|
81 |
+
|
82 |
+
/*
|
83 |
+
* override this to get the taxonomy for a field
|
84 |
+
*/
|
85 |
+
function get_field_taxonomy( $field ) {
|
86 |
+
return null;
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
/*
|
91 |
+
* setup a field if it is linked to a taxonomy
|
92 |
+
*/
|
93 |
+
function setup_taxonomy_field( &$field, $taxonomy ) {
|
94 |
+
$first_choice = $field['choices'][0]['text'];
|
95 |
+
$field['choices'] = $this->load_taxonomy_choices( $taxonomy, $field['type'], $first_choice );
|
96 |
+
|
97 |
+
//now check if we are dealing with a checkbox list and do some extra magic
|
98 |
+
if ( $field['type'] == 'checkbox' ) {
|
99 |
+
//clear the inputs first
|
100 |
+
$field['inputs'] = array();
|
101 |
+
|
102 |
+
$counter = 0;
|
103 |
+
//recreate the inputs so they are captured correctly on form submission
|
104 |
+
foreach( $field['choices'] as $choice ) {
|
105 |
+
$counter++;
|
106 |
+
$id = floatval( $field['id'] . '.' . $counter );
|
107 |
+
$field['inputs'][] = array('label' => $choice->label, 'id' => $id);
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/*
|
113 |
+
* Load any taxonomy terms
|
114 |
+
*/
|
115 |
+
function load_taxonomy_choices($taxonomy, $type, $first_choice = '') {
|
116 |
+
$choices = array();
|
117 |
+
|
118 |
+
if ($type === 'select') {
|
119 |
+
$terms = $this->load_taxonomy_hierarchical( $taxonomy );
|
120 |
+
if ($first_choice === ''){
|
121 |
+
// if no default option is specified, dynamically create based on taxonomy name
|
122 |
+
$taxonomy = get_taxonomy($taxonomy);
|
123 |
+
$choices[] = array('text' => "-- select a {$taxonomy->labels->singular_name} --", 'value' => '');
|
124 |
+
} else {
|
125 |
+
$choices[] = array('text' => $first_choice, 'value' => '');
|
126 |
+
}
|
127 |
+
} else {
|
128 |
+
$terms = get_terms($taxonomy, 'orderby=name&hide_empty=0');
|
129 |
+
}
|
130 |
+
|
131 |
+
foreach($terms as $term) {
|
132 |
+
$choices[] = array('value' => $term->term_id, 'text' => $term->name);
|
133 |
+
}
|
134 |
+
|
135 |
+
return $choices;
|
136 |
+
}
|
137 |
+
|
138 |
+
/*
|
139 |
+
* Get a hierarchical list of taxonomies
|
140 |
+
*/
|
141 |
+
function load_taxonomy_hierarchical( $taxonomy ) {
|
142 |
+
$args = array(
|
143 |
+
'taxonomy' => $taxonomy,
|
144 |
+
'orderby' => 'name',
|
145 |
+
'hierarchical' => 1,
|
146 |
+
'hide_empty' => 0
|
147 |
+
);
|
148 |
+
$terms = get_categories( $args );
|
149 |
+
return $this->walk_terms( $terms );
|
150 |
+
}
|
151 |
+
|
152 |
+
/*
|
153 |
+
* Helper function to recursively 'walk' the taxonomy terms
|
154 |
+
*/
|
155 |
+
function walk_terms( $input_array, $parent_id=0, &$out_array=array(), $level=0 ){
|
156 |
+
foreach ( $input_array as $item ) {
|
157 |
+
if ( $item->parent == $parent_id ) {
|
158 |
+
$item->name = str_repeat('--', $level) . $item->name;
|
159 |
+
$out_array[] = $item;
|
160 |
+
$this->walk_terms( $input_array, $item->term_id, $out_array, $level+1 );
|
161 |
+
}
|
162 |
+
}
|
163 |
+
return $out_array;
|
164 |
+
}
|
165 |
+
|
166 |
+
/*
|
167 |
+
* Loop through all fields and save any linked taxonomies
|
168 |
+
*/
|
169 |
+
function save_taxonomies( $entry, $form ) {
|
170 |
+
// Check if the submission contains a WordPress post
|
171 |
+
if ( isset ( $entry['post_id'] ) ) {
|
172 |
+
|
173 |
+
foreach( $form['fields'] as &$field ) {
|
174 |
+
|
175 |
+
$taxonomy = $this->get_field_taxonomy( $field );
|
176 |
+
|
177 |
+
if ( !$taxonomy ) continue;
|
178 |
+
|
179 |
+
$this->save_taxonomy_field( $field, $entry, $taxonomy );
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
/*
|
185 |
+
* Save linked taxonomies for a sinle field
|
186 |
+
*/
|
187 |
+
function save_taxonomy_field( &$field, $entry, $taxonomy ) {
|
188 |
+
if ( $field['type'] == 'checkbox' ) {
|
189 |
+
$term_ids = array();
|
190 |
+
foreach ( $field['inputs'] as $input ) {
|
191 |
+
$term_id = (int) $entry[ (string) $input['id'] ];
|
192 |
+
if ( $term_id > 0 )
|
193 |
+
$term_ids[] = $term_id;
|
194 |
+
}
|
195 |
+
if ( !empty ( $term_ids ))
|
196 |
+
wp_set_object_terms( $entry['post_id'], $term_ids, $taxonomy );
|
197 |
+
|
198 |
+
} else {
|
199 |
+
$term_id = (int) $entry[$field['id']];
|
200 |
+
if ( $term_id > 0 )
|
201 |
+
wp_set_object_terms( $entry['post_id'], $term_id, $taxonomy );
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
?>
|
gravity-forms-custom-post-type-mappings.php
DELETED
@@ -1,168 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Gravity Forms Custom Post Type Mappings
|
4 |
-
Plugin URI: http://themergency.com/
|
5 |
-
Description: Allow simple way to map a Gravity Form post entry to a custom post type
|
6 |
-
Version: 1.0
|
7 |
-
Author: Brad Vincent
|
8 |
-
Author URI: http://themergency.com/
|
9 |
-
License: GPL2
|
10 |
-
*/
|
11 |
-
|
12 |
-
// Get Gravity Forms over here!
|
13 |
-
@include_once(WP_PLUGIN_DIR . "/gravityforms/gravityforms.php");
|
14 |
-
@include_once(WP_PLUGIN_DIR . "/gravityforms/forms_model.php");
|
15 |
-
|
16 |
-
// check if Gravity Forms is installed and exists
|
17 |
-
if(class_exists('RGForms') && class_exists('RGFormsModel')) {
|
18 |
-
|
19 |
-
if (!class_exists('GF_CustomPostTypeMappings')) {
|
20 |
-
|
21 |
-
class GF_CustomPostTypeMappings {
|
22 |
-
|
23 |
-
private $_plugin_name; //the name of the plugin
|
24 |
-
|
25 |
-
//PHP 4 constructor
|
26 |
-
function GF_CustomPostTypeMappings() {
|
27 |
-
$this->__construct();
|
28 |
-
}
|
29 |
-
|
30 |
-
function __construct() {
|
31 |
-
$this->init();
|
32 |
-
}
|
33 |
-
|
34 |
-
function gf_populate_taxonomy_dropdowns($form) {
|
35 |
-
foreach($form['fields'] as &$field) {
|
36 |
-
$classes = explode(' ', $field['cssClass']);
|
37 |
-
|
38 |
-
foreach($classes as $class) {
|
39 |
-
//check if the class starts with 'taxomony-'
|
40 |
-
if($this->starts_with($class, 'taxonomy-')) {
|
41 |
-
$field['type'] = 'select';
|
42 |
-
$taxonomy = str_replace('taxonomy-', '', $class);
|
43 |
-
$field['choices'] = $this->gf_get_taxonomy_dropdown_choices($taxonomy);
|
44 |
-
}
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
return $form;
|
49 |
-
}
|
50 |
-
|
51 |
-
function gf_get_taxonomy_dropdown_choices($taxonomy, $withEmpty = true) {
|
52 |
-
$terms = get_terms($taxonomy, 'hide_empty=0');
|
53 |
-
|
54 |
-
$items = array();
|
55 |
-
|
56 |
-
if($withEmpty) {
|
57 |
-
$items[] = array('text' => '--select--', 'value' => '');
|
58 |
-
}
|
59 |
-
|
60 |
-
foreach($terms as $term) {
|
61 |
-
$items[] = array('value' => $term->term_id, 'text' => $term->name);
|
62 |
-
}
|
63 |
-
|
64 |
-
return $items;
|
65 |
-
}
|
66 |
-
|
67 |
-
function gf_set_post_type($post_data, $form){
|
68 |
-
//check if the form we are dealing with saves a post
|
69 |
-
if($this->gf_is_form_a_post_form($form)){
|
70 |
-
$classes = explode(' ', $form['cssClass']);
|
71 |
-
|
72 |
-
//loop through the classes and see if we have set the posttype class
|
73 |
-
foreach($classes as $class) {
|
74 |
-
//check if the class starts with 'posttype-'
|
75 |
-
if($this->starts_with($class, 'posttype-')) {
|
76 |
-
$target_post_type = str_replace('posttype-', '', $class);
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
if (!isset($target_post_type)) {
|
81 |
-
//lastly check if we have saved the mapping in an option
|
82 |
-
$options = get_option( $this->_plugin_name );
|
83 |
-
|
84 |
-
$target_post_type = $options["gf_".$form["id"]];
|
85 |
-
}
|
86 |
-
|
87 |
-
if (isset($target_post_type))
|
88 |
-
$post_data["post_type"] = $target_post_type;
|
89 |
-
}
|
90 |
-
return $post_data;
|
91 |
-
}
|
92 |
-
|
93 |
-
function gf_is_form_a_post_form($form) {
|
94 |
-
foreach ($form["fields"] as $field) {
|
95 |
-
if(in_array($field["type"],
|
96 |
-
array("post_category","post_title","post_content",
|
97 |
-
"post_excerpt","post_tags","post_custom_fields","post_image")))
|
98 |
-
return true;
|
99 |
-
}
|
100 |
-
return false;
|
101 |
-
}
|
102 |
-
|
103 |
-
function gf_save_taxonomy($lead, $form) {
|
104 |
-
// Check if the submission contains a WordPress post
|
105 |
-
if(isset($lead['post_id'])) {
|
106 |
-
|
107 |
-
foreach($form['fields'] as &$field) {
|
108 |
-
$classes = explode(' ', $field['cssClass']);
|
109 |
-
|
110 |
-
foreach($classes as $class) {
|
111 |
-
//check if the class starts with 'taxomony-'
|
112 |
-
if($this->starts_with($class, 'taxonomy-')) {
|
113 |
-
$taxonomy = str_replace('taxonomy-', '', $class);
|
114 |
-
$term_id = (int) $lead[$field['id']];
|
115 |
-
wp_set_object_terms($lead['post_id'], $term_id, $taxonomy);
|
116 |
-
}
|
117 |
-
}
|
118 |
-
}
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* starts_with
|
124 |
-
* Tests if a text starts with an given string.
|
125 |
-
*
|
126 |
-
* @param string
|
127 |
-
* @param string
|
128 |
-
* @return bool
|
129 |
-
*/
|
130 |
-
function starts_with($haystack, $needle){
|
131 |
-
return strpos($haystack, $needle) === 0;
|
132 |
-
}
|
133 |
-
|
134 |
-
/*
|
135 |
-
* returns true if a needle can be found in a haystack
|
136 |
-
*/
|
137 |
-
function str_contains($haystack, $needle) {
|
138 |
-
if (empty($haystack) || empty($needle))
|
139 |
-
return false;
|
140 |
-
|
141 |
-
$pos = strpos(strtolower($haystack), strtolower($needle));
|
142 |
-
|
143 |
-
if ($pos === false)
|
144 |
-
return false;
|
145 |
-
else
|
146 |
-
return true;
|
147 |
-
}
|
148 |
-
|
149 |
-
function init() {
|
150 |
-
$this->_plugin_name = 'gravity-forms-custom-post-type-mapping';
|
151 |
-
|
152 |
-
//alter the way forms are rendered by inserting taxomony dropdowns if needed
|
153 |
-
add_filter ('gform_pre_render' , array(&$this, 'gf_populate_taxonomy_dropdowns') );
|
154 |
-
|
155 |
-
//set the post types for a form
|
156 |
-
add_filter("gform_post_data", array(&$this, 'gf_set_post_type'), 10, 2);
|
157 |
-
|
158 |
-
//intercept the form save and save any taxonomy links if needed
|
159 |
-
add_action('gform_post_submission', array(&$this, 'gf_save_taxonomy'), 10, 2);
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
add_action("init",
|
164 |
-
create_function('', "global \$gfcpt; \$gfcpt = new GF_CustomPostTypeMappings();"));
|
165 |
-
}
|
166 |
-
}
|
167 |
-
|
168 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -3,52 +3,75 @@ Contributors: bradvin
|
|
3 |
Donate link: http://themergency.com/donate/
|
4 |
Tags: form,forms,gravity,gravity form,gravity forms,CPT,custom post types,custom post type,taxonomy,taxonomies
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 3.1
|
7 |
-
Stable tag:
|
8 |
|
9 |
-
Easily map your forms that create
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
> This plugin is an add-on for the [Gravity Forms Plugin](http://bit.ly/getgravityforms "visit the Gravity Forms website").
|
14 |
> If you don't yet own a license of the best forms plugin for WordPress, go and [buy one now!](http://bit.ly/getgravityforms "purchase Gravity Forms!")
|
15 |
|
16 |
-
Gravity forms allows you to create posts from a form using post fields.
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
Eg. adding a CSS class name of "posttype-movies" will save the post to the custom post type of "movies".
|
19 |
|
20 |
-
|
21 |
|
22 |
-
|
23 |
|
24 |
-
|
|
|
25 |
|
26 |
-
|
27 |
-
* Map a form dropdown field to a custom taxonomy
|
28 |
|
29 |
== Installation ==
|
30 |
|
31 |
1. Upload the plugin folder 'gravity-forms-custom-post-types' to your `/wp-content/plugins/` folder
|
32 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
33 |
-
3.
|
34 |
|
35 |
== Screenshots ==
|
36 |
|
37 |
-
1.
|
38 |
-
2.
|
|
|
|
|
|
|
|
|
39 |
|
40 |
== Changelog ==
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
= 1.0 =
|
43 |
* Initial Relase. First version.
|
44 |
|
45 |
== Frequently Asked Questions ==
|
46 |
|
47 |
= Does this plugin rely on anything? =
|
48 |
-
Yes, you need to install the Gravity Forms
|
49 |
|
50 |
-
|
51 |
-
You need to set the CSS Class Name for a form to be "posttype-YOURPOSTTYPEHERE". (see screenshots)
|
52 |
|
53 |
-
|
54 |
-
You need to set the CSS Class Name of a dropdown field to be "taxonomy-YOURTAXONOMYHERE" (see screenshots)
|
3 |
Donate link: http://themergency.com/donate/
|
4 |
Tags: form,forms,gravity,gravity form,gravity forms,CPT,custom post types,custom post type,taxonomy,taxonomies
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.1
|
7 |
+
Stable tag: 2.0
|
8 |
|
9 |
+
Easily map your forms that create posts to a custom post type. Also map dropdown select, radio buttons list and checkboxes lists to a custom taxonomy.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
> This plugin is an add-on for the [Gravity Forms Plugin](http://bit.ly/getgravityforms "visit the Gravity Forms website").
|
14 |
> If you don't yet own a license of the best forms plugin for WordPress, go and [buy one now!](http://bit.ly/getgravityforms "purchase Gravity Forms!")
|
15 |
|
16 |
+
Gravity forms allows you to create posts from a form using 'post fields'. By default the submitted form will create a draft post, but I wanted a way to save a custom post type instead. It can be done quite easily with some php code, but I wanted it to be easier without any code at all. Now it is easy. Maybe too easy :)
|
17 |
|
18 |
+
You can also link a custom taxomony to the field types : Drop Downs, Multiple Choice (radio buttons) or Checkboxes. So when the form is displayed a list of terms for the custom taxonomy are listed. And then when the post (or custom post type) is created, it automatically links the post to the selected taxonomy term(s).
|
19 |
+
|
20 |
+
**features**
|
21 |
+
|
22 |
+
* Map a form to a custom post type
|
23 |
+
* Map fields (Drop Downs, Multiple Choice or Checkboxes) to a custom taxonomy
|
24 |
+
* Supports both Gravity Forms v1.5 beta and v.1.4.5
|
25 |
+
* Much easier to map in Gravity Forms v1.5 - just select from a dropdown list
|
26 |
+
* Ability to have more than 1 taxonomy linked in a form (see screenshots)
|
27 |
+
* Hierarchical dropdowns for hierarchical taxonomies (see screenshots)
|
28 |
+
|
29 |
+
**How to map a form to a custom post type**
|
30 |
+
|
31 |
+
With Gravity Forms **v1.4.5**, all you need to do is add a CSS Class Name of *"posttype-YOUR_POST_TYPE"* to the form or your 'post title' field and your work is done.
|
32 |
Eg. adding a CSS class name of "posttype-movies" will save the post to the custom post type of "movies".
|
33 |
|
34 |
+
With **v1.5** of Gravity Forms, things get ALOT easier. You no longer need to set values for CSS class names. Rather just select the custom post types and taxonomies from a dropdown. Add a post title field to your form and under the advanced tab, tick the "Save As Custom Post Type" checkbox. A dropdown will appear with the available custom post types. Select the one you want.
|
35 |
|
36 |
+
**How to link a field to a custom taxonomy**
|
37 |
|
38 |
+
Custom taxonomies can be linked to Drop Downs, Multiple Choice (radio buttons) or Checkboxes. With Gravity Forms **v1.4.5**, simply, add a CSS class name of *"taxonomy-YOUR_TAXONOMY"* to the field.
|
39 |
+
Eg. adding a CSS class name of "taxonomy-actors" will link the dropdown to the "actors" custom taxonomy.
|
40 |
|
41 |
+
With **v1.5** of Gravity Forms, again things are alot easier. Under the advanced tab for your field, tick the "Populate with a Taxonomy" checkbox. A dropdown will appear and you can select your custom taxonomy from the list.
|
|
|
42 |
|
43 |
== Installation ==
|
44 |
|
45 |
1. Upload the plugin folder 'gravity-forms-custom-post-types' to your `/wp-content/plugins/` folder
|
46 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
47 |
+
3. Make sure you also have Gravity Forms activated.
|
48 |
|
49 |
== Screenshots ==
|
50 |
|
51 |
+
1. An example of what the end result can look like
|
52 |
+
2. Support for hierarchical taxonomies
|
53 |
+
3. How to map a form to a custom post type in GF v.1.5
|
54 |
+
4. How to map a field to a custom taxonomy in GF v.1.5
|
55 |
+
5. How to map a form to a custom post type in GF v.1.4.5
|
56 |
+
6. How to map a field to a custom taxonomy in GF v.1.4.5
|
57 |
|
58 |
== Changelog ==
|
59 |
|
60 |
+
= 2.0 =
|
61 |
+
* Added support for both Gravity Forms v1.5 beta and v.1.4.5
|
62 |
+
* Now supports linking taxonomies to Drop Downs, Multiple Choice or Checkboxes
|
63 |
+
* Integrated with GF v1.5 hooks for easier configuration (thanks to Alex and Carl from RocketGenius)
|
64 |
+
* Support linking more than 1 taxonomy to a form
|
65 |
+
* To keep in line with the GF standards, mapping a form to a CPT in GF v1.4.5 can now be done via the 'post title' field
|
66 |
+
|
67 |
= 1.0 =
|
68 |
* Initial Relase. First version.
|
69 |
|
70 |
== Frequently Asked Questions ==
|
71 |
|
72 |
= Does this plugin rely on anything? =
|
73 |
+
Yes, you need to install the [Gravity Forms Plugin](http://bit.ly/getgravityforms "visit the Gravity Forms website") for this plugin to work.
|
74 |
|
75 |
+
== Upgrade Notice ==
|
|
|
76 |
|
77 |
+
Please upgrade to the latest version
|
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
ADDED
Binary file
|
screenshot-4.png
ADDED
Binary file
|
screenshot-5.png
ADDED
Binary file
|
screenshot-6.png
ADDED
Binary file
|