Changeset 2542615
- Timestamp:
- 06/04/2021 01:52:18 PM (5 years ago)
- Location:
- gravity-forms-custom-post-types
- Files:
-
- 8 edited
- 1 copied
-
tags/3.1.20 (copied) (copied from gravity-forms-custom-post-types/trunk)
-
tags/3.1.20/gfcptaddon.php (modified) (2 diffs)
-
tags/3.1.20/gfcptaddon_1-5.php (modified) (1 diff)
-
tags/3.1.20/gfcptaddonbase.php (modified) (27 diffs)
-
tags/3.1.20/readme.txt (modified) (1 diff)
-
trunk/gfcptaddon.php (modified) (2 diffs)
-
trunk/gfcptaddon_1-5.php (modified) (1 diff)
-
trunk/gfcptaddonbase.php (modified) (27 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
gravity-forms-custom-post-types/tags/3.1.20/gfcptaddon.php
r2542253 r2542615 4 4 Plugin URI: https://gravitywiz.com/ 5 5 Description: Map your Gravity-Forms-generated posts to a custom post type and/or custom taxonomies. 6 Version: 3.1. 196 Version: 3.1.20 7 7 Author: Gravity Wiz 8 8 Author URI: https://gravitywiz.com/ … … 10 10 */ 11 11 12 add_action( 'init', array('GFCPTAddon', 'init'), 20);13 add_action( 'admin_notices', array('GFCPTAddon', 'admin_warnings'), 20);12 add_action( 'init', array( 'GFCPTAddon', 'init' ), 20 ); 13 add_action( 'admin_notices', array( 'GFCPTAddon', 'admin_warnings' ), 20 ); 14 14 15 15 class GFCPTAddon { 16 16 17 private static $name= 'Gravity Forms + Custom Post Types';18 private static $slug= 'GFCPTAddon';19 private static $version = '3.1.19';20 private static $min_gravityforms_version = '1.9.3';17 private static $name = 'Gravity Forms + Custom Post Types'; 18 private static $slug = 'GFCPTAddon'; 19 private static $version = '3.1.20'; 20 private static $min_gravityforms_version = '1.9.3'; 21 21 22 //Plugin starting point. Will load appropriate files23 public static function init(){22 //Plugin starting point. Will load appropriate files 23 public static function init() { 24 24 25 if(self::is_gravityforms_installed()){ 26 27 global $gf_cpt_addon; 25 if ( self::is_gravityforms_installed() ) { 28 26 29 //include the base class 30 require_once(self::get_base_path() . '/gfcptaddonbase.php'); 27 global $gf_cpt_addon; 31 28 32 //only supports 1.5 and over 33 require_once(self::get_base_path() . '/gfcptaddon_1-5.php'); 34 $gf_cpt_addon = new GFCPTAddon1_5(); 29 //include the base class 30 require_once( self::get_base_path() . '/gfcptaddonbase.php' ); 35 31 36 //start me up! 37 $gf_cpt_addon->init(__FILE__); 38 } 39 } 32 //only supports 1.5 and over 33 require_once( self::get_base_path() . '/gfcptaddon_1-5.php' ); 34 $gf_cpt_addon = new GFCPTAddon1_5(); 40 35 41 //display admin warnings if GF is not the correct version or GF is not installed 42 public static function admin_warnings() { 43 if ( !self::is_gravityforms_installed() ) { 44 $message = __('requires Gravity Forms to be installed.', self::$slug); 45 } else if ( !self::is_gravityforms_supported() ) { 46 $message = __('requires a minimum Gravity Forms version of ', self::$slug) . self::$min_gravityforms_version; 47 } 36 //start me up! 37 $gf_cpt_addon->init( __FILE__ ); 38 } 39 } 48 40 49 if (empty($message)) { 50 return; 51 } 52 ?> 53 <div class="error"> 54 <p> 55 <?php _e('The plugin ', self::$slug); ?><strong><?php echo self::$name; ?></strong> <?php echo $message; ?><br /> 56 <?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) ?> 57 </p> 58 </div> 59 <?php 60 } 41 //display admin warnings if GF is not the correct version or GF is not installed 42 public static function admin_warnings() { 43 if ( ! self::is_gravityforms_installed() ) { 44 $message = __( 'requires Gravity Forms to be installed.', self::$slug ); 45 } elseif ( ! self::is_gravityforms_supported() ) { 46 $message = __( 'requires a minimum Gravity Forms version of ', self::$slug ) . self::$min_gravityforms_version; 47 } 61 48 62 /* 63 * Check if GF is installed 64 */ 65 private static function is_gravityforms_installed(){ 66 return class_exists( 'RGForms' ); 67 } 49 if ( empty( $message ) ) { 50 return; 51 } 52 ?> 53 <div class="error"> 54 <p> 55 <?php _e( 'The plugin ', self::$slug ); ?> 56 <strong><?php echo self::$name; ?></strong> <?php echo $message; ?><br/> 57 <?php _e( 'Please ', self::$slug ); ?><a 58 href="http://bit.ly/getgravityforms"><?php _e( ' download the latest version ', self::$slug ); ?></a><?php _e( ' of Gravity Forms and try again.', self::$slug ); ?> 59 </p> 60 </div> 61 <?php 62 } 68 63 69 /*70 * Check if the installed version of GF is supported71 */72 private static function is_gravityforms_supported(){73 return self::check_gravityforms_version( self::$min_gravityforms_version,'>=' );74 }64 /* 65 * Check if GF is installed 66 */ 67 private static function is_gravityforms_installed() { 68 return class_exists( 'RGForms' ); 69 } 75 70 76 /* 77 * Do a GF version compare 78 */ 79 private static function check_gravityforms_version($version, $operator){ 80 if(class_exists('GFCommon')){ 81 return version_compare( GFCommon::$version, $version, $operator ); 82 } 83 return false; 84 } 71 /* 72 * Check if the installed version of GF is supported 73 */ 74 private static function is_gravityforms_supported() { 75 return self::check_gravityforms_version( self::$min_gravityforms_version, '>=' ); 76 } 85 77 86 /* 87 * Returns the url of the plugin's root folder 88 */ 89 protected function get_base_url(){ 90 return plugins_url(null, __FILE__); 91 } 78 /* 79 * Do a GF version compare 80 */ 81 private static function check_gravityforms_version( $version, $operator ) { 82 if ( class_exists( 'GFCommon' ) ) { 83 return version_compare( GFCommon::$version, $version, $operator ); 84 } 92 85 93 /* 94 * Returns the physical path of the plugin's root folder 95 */ 96 protected static function get_base_path(){ 97 return dirname( __FILE__ ); 98 } 86 return false; 87 } 99 88 100 /** 101 * starts_with 102 * Tests if a text starts with an given string. 103 * 104 * @param string 105 * @param string 106 * @return bool 107 */ 108 public static function starts_with($haystack, $needle){ 109 return strpos($haystack, $needle) === 0; 110 } 89 /* 90 * Returns the url of the plugin's root folder 91 */ 92 protected function get_base_url() { 93 return plugins_url( null, __FILE__ ); 94 } 111 95 112 /*113 * returns true if a needle can be found in a haystack 114 */115 public static function str_contains($haystack, $needle) {116 if (empty($haystack) || empty($needle)) 117 return false; 96 /* 97 * Returns the physical path of the plugin's root folder 98 */ 99 protected static function get_base_path() { 100 return dirname( __FILE__ ); 101 } 118 102 119 $pos = strpos(strtolower($haystack), strtolower($needle)); 103 /** 104 * starts_with 105 * Tests if a text starts with an given string. 106 * 107 * @param string 108 * @param string 109 * 110 * @return bool 111 */ 112 public static function starts_with( $haystack, $needle ) { 113 return strpos( $haystack, $needle ) === 0; 114 } 120 115 121 if ($pos === false) 122 return false; 123 else 124 return true; 125 } 116 /* 117 * returns true if a needle can be found in a haystack 118 */ 119 public static function str_contains( $haystack, $needle ) { 120 if ( empty( $haystack ) || empty( $needle ) ) { 121 return false; 122 } 123 124 $pos = strpos( strtolower( $haystack ), strtolower( $needle ) ); 125 126 if ( $pos === false ) { 127 return false; 128 } else { 129 return true; 130 } 131 } 126 132 } -
gravity-forms-custom-post-types/tags/3.1.20/gfcptaddon_1-5.php
r2542252 r2542615 1 1 <?php 2 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_standard_settings', array(&$this, 'render_field_standard_settings'), 10, 2); 20 add_action('gform_field_advanced_settings', array(&$this, 'render_field_advanced_settings'), 10, 2); 21 22 //include javascript for the form builder 23 add_action('gform_editor_js', array(&$this, 'render_editor_js')); 24 25 // filter to add a new tooltip 26 add_filter('gform_tooltips', array(&$this, 'add_gf_tooltips')); 27 } 28 29 /* 30 * Override. Gets the post type from our new field value 31 */ 32 function get_field_post_type( $field ) { 33 if ( isset( $field->populatePostType ) ) { 34 return $field->populatePostType; 35 } 36 37 return false; 38 } 39 40 /* 41 * Override. Gets the taxonomy from our new field value 42 */ 43 function get_field_taxonomy( $field ) { 44 if ( isset( $field->populateTaxonomy ) ) { 45 return $field->populateTaxonomy; 46 } elseif ( isset( $field->saveToTaxonomy ) ) { 47 return $field->saveToTaxonomy; 48 } 49 50 return false; 51 } 52 53 /* 54 * Override. Gets the custom post type from the post title field value 55 */ 56 function get_form_post_type( $form ) { 57 foreach ( $form['fields'] as $field ) { 58 if ( $field['type'] == 'post_title' && $field['saveAsCPT'] ) 59 return $field['saveAsCPT']; 60 } 61 return false; 62 } 63 64 function get_form_parent_post_id( $form ) { 65 foreach ( $form['fields'] as $field ) { 66 if ( $field['type'] == 'select' && $field['setParentPost'] ) { 67 $parent_id = RGForms::post('input_'.$field['id']); 68 return $parent_id; 69 } 70 } 71 return 0; 72 } 73 74 /* 75 * Add tooltips for the new field values 76 */ 77 function add_gf_tooltips($tooltips){ 78 $tooltips["form_field_populate_post_type"] = "<h6>Populate with a Post Type</h6>Check this box to populate this field from a specific post type."; 79 $tooltips["form_field_set_parent_post"] = "<h6>Try to set parent</h6>If this is checked, and the form creates a post type, then the parent for the newly created post type will be set from the value of this field. Please note that this only works for heirarcical post typs e.g. pages"; 80 $tooltips["form_field_custom_taxonomy"] = "<h6>Populate with a Taxonomy</h6>Check this box to populate this field from a custom taxonomy."; 81 $tooltips["form_field_custom_post_type"] = sprintf( '<h6>%s</h6> %s', __( 'Post Type', 'gravityforms' ), __( 'This form will create a WordPress post. Which post type should that post be assigned? Use this setting to specify the desired post type.' ) ); 82 $tooltips["form_field_save_to_taxonomy"] = "<h6>Save To Taxonomy</h6>Check this box to save this field to a specific custom taxonomy. Please note that the taxonomy must NOT be hierarchical."; 83 $tooltips["form_field_tax_enhanced"] = "<h6>Enable Enhanced UI</h6>By selecting this option, this field will be tranformed into a 'tag input' control which makes it more user-friendly for selecting existing and capturing new taxonomies."; 84 return $tooltips; 85 } 86 87 /* 88 * Add some advanced settings to the fields 89 */ 90 function render_field_standard_settings( $position, $form_id ) { 91 if( $position == 50 ) { 92 ?> 93 <li class="custom_post_type_field_setting field_setting"> 94 <label for="field_populate_custom_post_type"><?php _e( 'Post Type', 'gravityforms' ); ?> <?php gform_tooltip("form_field_custom_post_type") ?></label> 95 <select id="field_populate_custom_post_type" onchange="SetFieldProperty('saveAsCPT', jQuery(this).val());"> 96 <?php foreach( $this->get_post_types( $form_id ) as $post_type ): ?> 97 <option value="<?php echo $post_type->name; ?>" <?php selected( 'post', $post_type->name ); ?>><?php echo $post_type->label; ?></option> 98 <?php endforeach; ?> 99 </select> 100 </li> 101 <?php 102 } 103 104 } 105 106 /* 107 * Add some advanced settings to the fields 108 */ 109 function render_field_advanced_settings($position, $form_id){ 110 if($position == 50){ 111 ?> 112 <li class="populate_with_taxonomy_field_setting field_setting" style="display:list-item;"> 113 <input type="checkbox" id="field_enable_populate_with_taxonomy" /> 114 <label for="field_enable_populate_with_taxonomy" class="inline"> 115 <?php _e("Populate with a Taxonomy", "gravityforms"); ?> 116 </label> 117 <?php gform_tooltip("form_field_custom_taxonomy") ?><br /> 118 <select id="field_populate_taxonomy" onchange="SetFieldProperty('populateTaxonomy', jQuery(this).val());" style="margin-top:10px; display:none;"> 119 <option value="" style="color:#999;">Select a Taxonomy</option> 120 <?php foreach( $this->get_taxonomies( $form_id ) as $taxonomy ): ?> 121 <option value="<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></option> 122 <?php endforeach; ?> 123 </select> 124 </li> 125 <li class="populate_with_post_type_field_setting field_setting" style="display:list-item;"> 126 <input type="checkbox" class="toggle_setting" id="field_enable_populate_with_post_type" /> 127 <label for="field_enable_populate_with_post_type" class="inline"> 128 <?php _e("Populate with a Post Type", "gravityforms"); ?> 129 </label> 130 <?php gform_tooltip("form_field_populate_post_type") ?><br /> 131 <div style="margin-top:10px; display:none;"> 132 <select id="field_populate_post_type" onchange="SetFieldProperty('populatePostType', jQuery(this).val());"> 133 <option value="" style="color:#999;">Select a Post Type</option> 134 <?php 135 foreach( $this->get_post_types( $form_id ) as $post_type ): ?> 136 <option value="<?php echo $post_type->name; ?>"><?php echo $post_type->label; ?></option> 137 <?php endforeach; ?> 138 </select> 139 <input type="checkbox" class="check_parent" onclick="SetFieldProperty('setParentPost', this.checked);" id="field_set_parent_post" /> 140 <label for="field_set_parent_post" class="inline"> 141 <?php _e("Try to set parent", "gravityforms"); ?> 142 </label> 143 <?php gform_tooltip("form_field_set_parent_post") ?> 144 </div> 145 </li> 146 <li class="save_to_taxonomy_field_setting field_setting" style="display:list-item;"> 147 <input type="checkbox" class="toggle_setting" id="field_enable_save_to_taxonomy" /> 148 <label for="field_enable_save_to_taxonomy" class="inline"> 149 <?php _e("Save To Taxonomy", "gravityforms"); ?> 150 </label> 151 <?php gform_tooltip("form_field_save_to_taxonomy") ?> 152 <div style="margin-top:10px; display:none;"> 153 <select id="field_save_to_taxonomy" onchange="SetFieldProperty('saveToTaxonomy', jQuery(this).val());"> 154 <option value="" style="color:#999;">Select a Taxonomy</option> 155 <?php foreach( $this->get_taxonomies( $form_id ) as $taxonomy ): 156 if ( $taxonomy->hierarchical === false ): ?> 157 <option value="<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></option> 158 <?php endif; ?> 159 <?php endforeach; ?> 160 161 </select> 162 <input type="checkbox" class="check_tax_enhanced" onclick="SetFieldProperty('taxonomyEnhanced', this.checked);" id="field_tax_enhanced" /> 163 <label for="field_tax_enhanced" class="inline"> 164 <?php _e("Enable enhanced UI", "gravityforms"); ?> 165 </label> 166 <?php gform_tooltip("form_field_tax_enhanced") ?> 167 </div> 168 </li> 169 <?php 170 } 171 172 } 173 174 /* 175 * render some custom JS to get the settings to work 176 */ 177 function render_editor_js(){ 178 ?> 179 <script type='text/javascript'> 180 181 jQuery(document).bind("gform_load_field_settings", function(event, field, form){ 182 //only show taxonomy for selects and radios 183 var valid_types = new Array('select', 'radio', 'checkbox', 'multiselect'); 184 185 //alert(field['type']); 186 187 if(jQuery.inArray(field['type'], valid_types) != -1) { 188 189 var $taxonomy_setting_container = jQuery(".populate_with_taxonomy_field_setting"); 190 //show the setting container! 191 $taxonomy_setting_container.show(); 192 193 //get the saved taxonomy 194 var populateTaxonomy = (typeof field['populateTaxonomy'] != 'undefined' && field['populateTaxonomy'] != '') ? field['populateTaxonomy'] : false; 195 196 if (populateTaxonomy != false) { 197 //check the checkbox if previously checked 198 $taxonomy_setting_container.find("input:checkbox").attr("checked", "checked"); 199 //set the select and show 200 $taxonomy_setting_container.find("select").val(populateTaxonomy).show(); 201 } else { 202 $taxonomy_setting_container.find("input:checkbox").removeAttr("checked"); 203 $taxonomy_setting_container.find("select").val('').hide(); 204 } 205 206 if (field['type'] == 'select') { 207 var $populate_post_type_container = jQuery(".populate_with_post_type_field_setting"); 208 $populate_post_type_container.show(); 209 210 //get the saved post type 211 var populatePostType = (typeof field['populatePostType'] != 'undefined' && field['populatePostType'] != '') ? field['populatePostType'] : false; 212 213 if (populatePostType != false) { 214 //check the checkbox if previously checked 215 $populate_post_type_container.find("input.toggle_setting").attr("checked", "checked"); 216 //set the select 217 $populate_post_type_container.find("select").val(populatePostType); 218 //show the div 219 $populate_post_type_container.find("div").show(); 220 221 //get the saved check for setting the parent post 222 var setParent = (typeof field['setParentPost'] != 'undefined' && field['setParentPost'] != '') ? field['setParentPost'] : false; 223 if (setParent != false) { 224 $populate_post_type_container.find(".check_parent").attr("checked", "checked"); 225 } else { 226 $populate_post_type_container.find(".check_parent").removeAttr("checked"); 227 } 228 } else { 229 /*$taxonomy_setting_container.find("input.toggle_setting").removeAttr("checked"); 230 $taxonomy_setting_container.find("select").val('');*/ 231 $populate_post_type_container.find("input.toggle_setting").removeAttr("checked"); 232 $populate_post_type_container.find("select").val(''); 233 } 234 235 } 236 237 } else if (field['type'] == 'post_title') { 238 239 var $cpt_setting_container = jQuery(".custom_post_type_field_setting" ), 240 saveAsCPT = ( typeof field['saveAsCPT'] != 'undefined' && field['saveAsCPT'] != '') ? field['saveAsCPT'] : 'post'; 241 242 //set the select and show 243 $cpt_setting_container.show().find( 'select' ).val( saveAsCPT ); 244 245 } else if (field['type'] == 'text') { 246 var $tax_setting_container = jQuery('.save_to_taxonomy_field_setting'); 247 248 $tax_setting_container.show(); 249 250 var saveToTax = (typeof field['saveToTaxonomy'] != 'undefined' && field['saveToTaxonomy'] != '') ? field['saveToTaxonomy'] : false; 251 252 if (saveToTax != false) { 253 //check the checkbox if previously checked 254 $tax_setting_container.find("input.toggle_setting").attr("checked", "checked"); 255 //set the select 256 $tax_setting_container.find("select").val(saveToTax); 257 //show the div 258 $tax_setting_container.find("div").show(); 259 260 //get the saved check for using enhanced UI 261 var useEnhancedUI = (typeof field['taxonomyEnhanced'] != 'undefined' && field['taxonomyEnhanced'] != '') ? field['taxonomyEnhanced'] : false; 262 if (useEnhancedUI != false) { 263 $tax_setting_container.find(".check_tax_enhanced").attr("checked", "checked"); 264 } else { 265 $tax_setting_container.find(".check_tax_enhanced").removeAttr("checked"); 266 } 267 268 } else { 269 $tax_setting_container.find("input.toggle_setting").removeAttr("checked"); 270 $tax_setting_container.find("div").hide(); 271 $tax_setting_container.find(".check_tax_enhanced").removeAttr("checked"); 272 $tax_setting_container.find("select").val(''); 273 } 274 } 275 }); 276 277 jQuery(".populate_with_taxonomy_field_setting input:checkbox").click(function() { 278 var checked = jQuery(this).is(":checked"); 279 var $select = jQuery(this).parent(".populate_with_taxonomy_field_setting:first").find("select"); 280 if(checked){ 281 $select.slideDown(); 282 283 //uncheck post type 284 var $pt_container = jQuery(this).parents("ul:first").find(".populate_with_post_type_field_setting:first"); 285 var $pt_check = $pt_container.find("input.toggle_setting"); 286 var $pt_div = $pt_container.find("div"); 287 if ($pt_check.is(":checked")) { 288 289 SetFieldProperty('populatePostType',''); 290 $pt_div.slideUp(); 291 $pt_check.removeAttr('checked'); 292 293 } 294 295 } else { 296 SetFieldProperty('populateTaxonomy',''); 297 $select.slideUp(); 298 } 299 }); 300 301 jQuery(".populate_with_post_type_field_setting .toggle_setting").click(function() { 302 var checked = jQuery(this).is(":checked"); 303 var $div = jQuery(this).parent(".populate_with_post_type_field_setting:first").find("div"); 304 if(checked){ 305 $div.slideDown(); 306 //uncheck taxonomy 307 var $tax_container = jQuery(this).parents("ul:first").find(".populate_with_taxonomy_field_setting:first"); 308 var $tax_check = $tax_container.find("input:checkbox"); 309 var $tax_select = $tax_container.find("select"); 310 if ($tax_check.is(":checked")) { 311 312 SetFieldProperty('populateTaxonomy',''); 313 $tax_select.slideUp(); 314 $tax_check.removeAttr('checked'); 315 316 } 317 318 } else { 319 SetFieldProperty('populatePostType',''); 320 $div.slideUp(); 321 } 322 }); 323 324 jQuery(".save_to_taxonomy_field_setting .toggle_setting").click(function() { 325 var checked = jQuery(this).is(":checked"); 326 var $div = jQuery(this).parent(".save_to_taxonomy_field_setting:first").find("div"); 327 if(checked){ 328 $div.slideDown(); 329 } else { 330 SetFieldProperty('saveToTaxonomy',''); 331 $div.slideUp(); 332 } 333 }); 334 335 </script> 336 <?php 337 } 338 339 } 3 if ( ! class_exists( 'GFCPTAddon1_5' ) ) { 4 5 /* 6 * GFCPT Addon class targetting version 1.5 of Gravity Forms 7 */ 8 9 class GFCPTAddon1_5 extends GFCPTAddonBase { 10 11 /* 12 * Override. Include a couple more hooks 13 */ 14 public function init() { 15 //hook up the defaults 16 parent::init(); 17 18 //then add these for 1.5... 19 //add our advanced options to the form builder 20 add_action( 'gform_field_standard_settings', array( &$this, 'render_field_standard_settings' ), 10, 2 ); 21 add_action( 'gform_field_advanced_settings', array( &$this, 'render_field_advanced_settings' ), 10, 2 ); 22 23 //include javascript for the form builder 24 add_action( 'gform_editor_js', array( &$this, 'render_editor_js' ) ); 25 26 // filter to add a new tooltip 27 add_filter( 'gform_tooltips', array( &$this, 'add_gf_tooltips' ) ); 28 } 29 30 /* 31 * Override. Gets the post type from our new field value 32 */ 33 function get_field_post_type( $field ) { 34 if ( isset( $field->populatePostType ) ) { 35 return $field->populatePostType; 36 } 37 38 return false; 39 } 40 41 /* 42 * Override. Gets the taxonomy from our new field value 43 */ 44 function get_field_taxonomy( $field ) { 45 if ( isset( $field->populateTaxonomy ) ) { 46 return $field->populateTaxonomy; 47 } elseif ( isset( $field->saveToTaxonomy ) ) { 48 return $field->saveToTaxonomy; 49 } 50 51 return false; 52 } 53 54 /* 55 * Override. Gets the custom post type from the post title field value 56 */ 57 function get_form_post_type( $form ) { 58 foreach ( $form['fields'] as $field ) { 59 if ( $field['type'] == 'post_title' && $field['saveAsCPT'] ) { 60 return $field['saveAsCPT']; 61 } 62 } 63 64 return false; 65 } 66 67 function get_form_parent_post_id( $form ) { 68 foreach ( $form['fields'] as $field ) { 69 if ( $field['type'] == 'select' && $field['setParentPost'] ) { 70 $parent_id = RGForms::post( 'input_' . $field['id'] ); 71 72 return $parent_id; 73 } 74 } 75 76 return 0; 77 } 78 79 /* 80 * Add tooltips for the new field values 81 */ 82 function add_gf_tooltips( $tooltips ) { 83 $tooltips['form_field_populate_post_type'] = '<h6>Populate with a Post Type</h6>Check this box to populate this field from a specific post type.'; 84 $tooltips['form_field_set_parent_post'] = '<h6>Try to set parent</h6>If this is checked, and the form creates a post type, then the parent for the newly created post type will be set from the value of this field. Please note that this only works for heirarcical post typs e.g. pages'; 85 $tooltips['form_field_custom_taxonomy'] = '<h6>Populate with a Taxonomy</h6>Check this box to populate this field from a custom taxonomy.'; 86 $tooltips['form_field_custom_post_type'] = sprintf( '<h6>%s</h6> %s', __( 'Post Type', 'gravityforms' ), __( 'This form will create a WordPress post. Which post type should that post be assigned? Use this setting to specify the desired post type.' ) ); 87 $tooltips['form_field_save_to_taxonomy'] = '<h6>Save To Taxonomy</h6>Check this box to save this field to a specific custom taxonomy. Please note that the taxonomy must NOT be hierarchical.'; 88 $tooltips['form_field_tax_enhanced'] = "<h6>Enable Enhanced UI</h6>By selecting this option, this field will be tranformed into a 'tag input' control which makes it more user-friendly for selecting existing and capturing new taxonomies."; 89 90 return $tooltips; 91 } 92 93 /* 94 * Add some advanced settings to the fields 95 */ 96 function render_field_standard_settings( $position, $form_id ) { 97 if ( $position == 50 ) { 98 ?> 99 <li class="custom_post_type_field_setting field_setting"> 100 <label for="field_populate_custom_post_type"><?php _e( 'Post Type', 'gravityforms' ); ?><?php gform_tooltip( 'form_field_custom_post_type' ); ?></label> 101 <select id="field_populate_custom_post_type" 102 onchange="SetFieldProperty('saveAsCPT', jQuery(this).val());"> 103 <?php foreach ( $this->get_post_types( $form_id ) as $post_type ) : ?> 104 <option value="<?php echo $post_type->name; ?>" <?php selected( 'post', $post_type->name ); ?>><?php echo $post_type->label; ?></option> 105 <?php endforeach; ?> 106 </select> 107 </li> 108 <?php 109 } 110 111 } 112 113 /* 114 * Add some advanced settings to the fields 115 */ 116 function render_field_advanced_settings( $position, $form_id ) { 117 if ( $position == 50 ) { 118 ?> 119 <li class="populate_with_taxonomy_field_setting field_setting" style="display:list-item;"> 120 <input type="checkbox" id="field_enable_populate_with_taxonomy"/> 121 <label for="field_enable_populate_with_taxonomy" class="inline"> 122 <?php _e( 'Populate with a Taxonomy', 'gravityforms' ); ?> 123 </label> 124 <?php gform_tooltip( 'form_field_custom_taxonomy' ); ?><br/> 125 <select id="field_populate_taxonomy" 126 onchange="SetFieldProperty('populateTaxonomy', jQuery(this).val());" 127 style="margin-top:10px; display:none;"> 128 <option value="" style="color:#999;">Select a Taxonomy</option> 129 <?php foreach ( $this->get_taxonomies( $form_id ) as $taxonomy ) : ?> 130 <option value="<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></option> 131 <?php endforeach; ?> 132 </select> 133 </li> 134 <li class="populate_with_post_type_field_setting field_setting" style="display:list-item;"> 135 <input type="checkbox" class="toggle_setting" id="field_enable_populate_with_post_type"/> 136 <label for="field_enable_populate_with_post_type" class="inline"> 137 <?php _e( 'Populate with a Post Type', 'gravityforms' ); ?> 138 </label> 139 <?php gform_tooltip( 'form_field_populate_post_type' ); ?><br/> 140 <div style="margin-top:10px; display:none;"> 141 <select id="field_populate_post_type" 142 onchange="SetFieldProperty('populatePostType', jQuery(this).val());"> 143 <option value="" style="color:#999;">Select a Post Type</option> 144 <?php 145 foreach ( $this->get_post_types( $form_id ) as $post_type ) : 146 ?> 147 <option value="<?php echo $post_type->name; ?>"><?php echo $post_type->label; ?></option> 148 <?php endforeach; ?> 149 </select> 150 <input type="checkbox" class="check_parent" 151 onclick="SetFieldProperty('setParentPost', this.checked);" id="field_set_parent_post"/> 152 <label for="field_set_parent_post" class="inline"> 153 <?php _e( 'Try to set parent', 'gravityforms' ); ?> 154 </label> 155 <?php gform_tooltip( 'form_field_set_parent_post' ); ?> 156 </div> 157 </li> 158 <li class="save_to_taxonomy_field_setting field_setting" style="display:list-item;"> 159 <input type="checkbox" class="toggle_setting" id="field_enable_save_to_taxonomy"/> 160 <label for="field_enable_save_to_taxonomy" class="inline"> 161 <?php _e( 'Save To Taxonomy', 'gravityforms' ); ?> 162 </label> 163 <?php gform_tooltip( 'form_field_save_to_taxonomy' ); ?> 164 <div style="margin-top:10px; display:none;"> 165 <select id="field_save_to_taxonomy" 166 onchange="SetFieldProperty('saveToTaxonomy', jQuery(this).val());"> 167 <option value="" style="color:#999;">Select a Taxonomy</option> 168 <?php 169 foreach ( $this->get_taxonomies( $form_id ) as $taxonomy ) : 170 if ( $taxonomy->hierarchical === false ) : 171 ?> 172 <option value="<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></option> 173 <?php endif; ?> 174 <?php endforeach; ?> 175 176 </select> 177 <input type="checkbox" class="check_tax_enhanced" 178 onclick="SetFieldProperty('taxonomyEnhanced', this.checked);" id="field_tax_enhanced"/> 179 <label for="field_tax_enhanced" class="inline"> 180 <?php _e( 'Enable enhanced UI', 'gravityforms' ); ?> 181 </label> 182 <?php gform_tooltip( 'form_field_tax_enhanced' ); ?> 183 </div> 184 </li> 185 <?php 186 } 187 188 } 189 190 /* 191 * render some custom JS to get the settings to work 192 */ 193 function render_editor_js() { 194 ?> 195 <script type='text/javascript'> 196 197 jQuery(document).bind("gform_load_field_settings", function (event, field, form) { 198 //only show taxonomy for selects and radios 199 var valid_types = new Array('select', 'radio', 'checkbox', 'multiselect'); 200 201 //alert(field['type']); 202 203 if (jQuery.inArray(field['type'], valid_types) != -1) { 204 205 var $taxonomy_setting_container = jQuery(".populate_with_taxonomy_field_setting"); 206 //show the setting container! 207 $taxonomy_setting_container.show(); 208 209 //get the saved taxonomy 210 var populateTaxonomy = (typeof field['populateTaxonomy'] != 'undefined' && field['populateTaxonomy'] != '') ? field['populateTaxonomy'] : false; 211 212 if (populateTaxonomy != false) { 213 //check the checkbox if previously checked 214 $taxonomy_setting_container.find("input:checkbox").attr("checked", "checked"); 215 //set the select and show 216 $taxonomy_setting_container.find("select").val(populateTaxonomy).show(); 217 } else { 218 $taxonomy_setting_container.find("input:checkbox").removeAttr("checked"); 219 $taxonomy_setting_container.find("select").val('').hide(); 220 } 221 222 if (field['type'] == 'select') { 223 var $populate_post_type_container = jQuery(".populate_with_post_type_field_setting"); 224 $populate_post_type_container.show(); 225 226 //get the saved post type 227 var populatePostType = (typeof field['populatePostType'] != 'undefined' && field['populatePostType'] != '') ? field['populatePostType'] : false; 228 229 if (populatePostType != false) { 230 //check the checkbox if previously checked 231 $populate_post_type_container.find("input.toggle_setting").attr("checked", "checked"); 232 //set the select 233 $populate_post_type_container.find("select").val(populatePostType); 234 //show the div 235 $populate_post_type_container.find("div").show(); 236 237 //get the saved check for setting the parent post 238 var setParent = (typeof field['setParentPost'] != 'undefined' && field['setParentPost'] != '') ? field['setParentPost'] : false; 239 if (setParent != false) { 240 $populate_post_type_container.find(".check_parent").attr("checked", "checked"); 241 } else { 242 $populate_post_type_container.find(".check_parent").removeAttr("checked"); 243 } 244 } else { 245 /*$taxonomy_setting_container.find("input.toggle_setting").removeAttr("checked"); 246 $taxonomy_setting_container.find("select").val('');*/ 247 $populate_post_type_container.find("input.toggle_setting").removeAttr("checked"); 248 $populate_post_type_container.find("select").val(''); 249 } 250 251 } 252 253 } else if (field['type'] == 'post_title') { 254 255 var $cpt_setting_container = jQuery(".custom_post_type_field_setting"), 256 saveAsCPT = (typeof field['saveAsCPT'] != 'undefined' && field['saveAsCPT'] != '') ? field['saveAsCPT'] : 'post'; 257 258 //set the select and show 259 $cpt_setting_container.show().find('select').val(saveAsCPT); 260 261 } else if (field['type'] == 'text') { 262 var $tax_setting_container = jQuery('.save_to_taxonomy_field_setting'); 263 264 $tax_setting_container.show(); 265 266 var saveToTax = (typeof field['saveToTaxonomy'] != 'undefined' && field['saveToTaxonomy'] != '') ? field['saveToTaxonomy'] : false; 267 268 if (saveToTax != false) { 269 //check the checkbox if previously checked 270 $tax_setting_container.find("input.toggle_setting").attr("checked", "checked"); 271 //set the select 272 $tax_setting_container.find("select").val(saveToTax); 273 //show the div 274 $tax_setting_container.find("div").show(); 275 276 //get the saved check for using enhanced UI 277 var useEnhancedUI = (typeof field['taxonomyEnhanced'] != 'undefined' && field['taxonomyEnhanced'] != '') ? field['taxonomyEnhanced'] : false; 278 if (useEnhancedUI != false) { 279 $tax_setting_container.find(".check_tax_enhanced").attr("checked", "checked"); 280 } else { 281 $tax_setting_container.find(".check_tax_enhanced").removeAttr("checked"); 282 } 283 284 } else { 285 $tax_setting_container.find("input.toggle_setting").removeAttr("checked"); 286 $tax_setting_container.find("div").hide(); 287 $tax_setting_container.find(".check_tax_enhanced").removeAttr("checked"); 288 $tax_setting_container.find("select").val(''); 289 } 290 } 291 }); 292 293 jQuery(".populate_with_taxonomy_field_setting input:checkbox").click(function () { 294 var checked = jQuery(this).is(":checked"); 295 var $select = jQuery(this).parent(".populate_with_taxonomy_field_setting:first").find("select"); 296 if (checked) { 297 $select.slideDown(); 298 299 //uncheck post type 300 var $pt_container = jQuery(this).parents("ul:first").find(".populate_with_post_type_field_setting:first"); 301 var $pt_check = $pt_container.find("input.toggle_setting"); 302 var $pt_div = $pt_container.find("div"); 303 if ($pt_check.is(":checked")) { 304 305 SetFieldProperty('populatePostType', ''); 306 $pt_div.slideUp(); 307 $pt_check.removeAttr('checked'); 308 309 } 310 311 } else { 312 SetFieldProperty('populateTaxonomy', ''); 313 $select.slideUp(); 314 } 315 }); 316 317 jQuery(".populate_with_post_type_field_setting .toggle_setting").click(function () { 318 var checked = jQuery(this).is(":checked"); 319 var $div = jQuery(this).parent(".populate_with_post_type_field_setting:first").find("div"); 320 if (checked) { 321 $div.slideDown(); 322 //uncheck taxonomy 323 var $tax_container = jQuery(this).parents("ul:first").find(".populate_with_taxonomy_field_setting:first"); 324 var $tax_check = $tax_container.find("input:checkbox"); 325 var $tax_select = $tax_container.find("select"); 326 if ($tax_check.is(":checked")) { 327 328 SetFieldProperty('populateTaxonomy', ''); 329 $tax_select.slideUp(); 330 $tax_check.removeAttr('checked'); 331 332 } 333 334 } else { 335 SetFieldProperty('populatePostType', ''); 336 $div.slideUp(); 337 } 338 }); 339 340 jQuery(".save_to_taxonomy_field_setting .toggle_setting").click(function () { 341 var checked = jQuery(this).is(":checked"); 342 var $div = jQuery(this).parent(".save_to_taxonomy_field_setting:first").find("div"); 343 if (checked) { 344 $div.slideDown(); 345 } else { 346 SetFieldProperty('saveToTaxonomy', ''); 347 $div.slideUp(); 348 } 349 }); 350 351 </script> 352 <?php 353 } 354 355 } 340 356 341 357 } -
gravity-forms-custom-post-types/tags/3.1.20/gfcptaddonbase.php
r2063866 r2542615 1 1 <?php 2 2 3 if ( !class_exists('GFCPTAddonBase')) {3 if ( ! class_exists( 'GFCPTAddonBase' ) ) { 4 4 5 5 /* 6 6 * Base class for the GFCPT Addon. All common code is in here and differences per version are overrided 7 7 */ 8 8 9 class GFCPTAddonBase { 9 10 10 protected $_has_tag_inputs = false;11 protected $_included_js;12 protected $_tag_inputs = array();13 protected $_tag_map = array();14 protected $_tag_terms = array();11 protected $_has_tag_inputs = false; 12 protected $_included_js; 13 protected $_tag_inputs = array(); 14 protected $_tag_map = array(); 15 protected $_tag_terms = array(); 15 16 16 17 … … 20 21 public function init() { 21 22 //alter the way forms are rendered by inserting taxomony dropdowns,radios and checkboxes 22 add_filter( 'gform_pre_render' , array(&$this, 'setup_form') );23 add_filter( 'gform_pre_render', array( &$this, 'setup_form' ) ); 23 24 24 25 //alter the way forms are rendered by the admin too! 25 add_filter( 'gform_admin_pre_render' , array(&$this, 'setup_form') );26 add_filter( 'gform_admin_pre_render', array( &$this, 'setup_form' ) ); 26 27 27 28 //alter the form for submission - this is mainly for checkboxes 28 add_filter( 'gform_pre_submission_filter', array(&$this, 'setup_form') );29 add_filter( 'gform_pre_submission_filter', array( &$this, 'setup_form' ) ); 29 30 30 31 add_filter( 'gform_form_post_get_meta', array( $this, 'setup_form_on_export' ) ); 31 32 32 33 //set the post type when saving a post 33 add_filter("gform_post_data", array(&$this, 'set_post_values'), 10, 2); 34 35 if( class_exists( 'gform_update_post' ) ) { 36 remove_filter( 'gform_after_submission', array( 'gform_update_post', 'delete_custom_taxonomy_save' ), 1, 2 ); 34 add_filter( "gform_post_data", array( &$this, 'set_post_values' ), 10, 2 ); 35 36 if ( class_exists( 'gform_update_post' ) ) { 37 remove_filter( 'gform_after_submission', array( 38 'gform_update_post', 39 'delete_custom_taxonomy_save' 40 ), 1, 2 ); 37 41 } 38 42 39 43 //intercept the form save and save any taxonomy links if needed 40 add_action( 'gform_after_create_post', array( $this, 'save_taxonomies' ), 10, 3 );44 add_action( 'gform_after_create_post', array( $this, 'save_taxonomies' ), 10, 3 ); 41 45 42 46 //enqueue scripts to the page 43 add_action( 'gform_enqueue_scripts', array( $this, 'enqueue_form_scripts' ), 10, 2 );47 add_action( 'gform_enqueue_scripts', array( $this, 'enqueue_form_scripts' ), 10, 2 ); 44 48 add_action( 'gform_register_init_scripts', array( $this, 'register_init_scripts' ), 10, 2 ); 45 49 46 add_filter( "gform_preview_styles", array(&$this, 'preview_print_styles'), 10, 2);47 48 add_filter( 'gform_entry_field_value', array( $this, 'display_term_name_on_entry_detail' ), 10, 4 );50 add_filter( "gform_preview_styles", array( &$this, 'preview_print_styles' ), 10, 2 ); 51 52 add_filter( 'gform_entry_field_value', array( $this, 'display_term_name_on_entry_detail' ), 10, 4 ); 49 53 add_filter( 'gform_entries_field_value', array( $this, 'display_term_name_on_entry_list' ), 10, 4 ); 50 add_filter( 'gform_export_field_value', array( $this, 'display_term_name_on_export' ), 10, 4 );51 52 add_filter( 'gform_entry_field_value', array( $this, 'display_post_title_on_entry_detail' ), 10, 4 );54 add_filter( 'gform_export_field_value', array( $this, 'display_term_name_on_export' ), 10, 4 ); 55 56 add_filter( 'gform_entry_field_value', array( $this, 'display_post_title_on_entry_detail' ), 10, 4 ); 53 57 add_filter( 'gform_entries_field_value', array( $this, 'display_post_title_on_entry_list' ), 10, 4 ); 54 add_filter( 'gform_export_field_value', array( $this, 'display_post_title_on_export' ), 10, 4 );58 add_filter( 'gform_export_field_value', array( $this, 'display_post_title_on_export' ), 10, 4 ); 55 59 56 60 … … 62 66 function setup_form( $form ) { 63 67 64 //loop thru all fields 65 foreach($form['fields'] as &$field) { 66 67 //see if the field is using a taxonomy 68 $taxonomy = $this->get_field_taxonomy( $field ); 69 70 if($taxonomy) { 71 $this->setup_taxonomy_field( $field, $taxonomy ); 72 continue; 73 } 74 75 //if its a select then check if we have set a post type 76 if ($field['type'] == 'select') { 77 78 $post_type = $this->get_field_post_type( $field ); 79 80 if ($post_type) { 81 $this->setup_post_type_field( $field, $post_type ); 82 continue; 83 } 84 85 } 86 } 87 88 return $form; 68 if ( empty( $form['fields'] ) ) { 69 return $form; 70 } 71 72 //loop thru all fields 73 foreach ( $form['fields'] as &$field ) { 74 75 //see if the field is using a taxonomy 76 $taxonomy = $this->get_field_taxonomy( $field ); 77 78 if ( $taxonomy ) { 79 $this->setup_taxonomy_field( $field, $taxonomy ); 80 continue; 81 } 82 83 //if its a select then check if we have set a post type 84 if ( $field['type'] == 'select' ) { 85 86 $post_type = $this->get_field_post_type( $field ); 87 88 if ( $post_type ) { 89 $this->setup_post_type_field( $field, $post_type ); 90 continue; 91 } 92 93 } 94 } 95 96 return $form; 89 97 } 90 98 91 99 function setup_form_on_export( $form ) { 92 100 93 if ( in_array( rgpost( 'action' ), array( 'rg_select_export_form', 'gf_process_export' ) ) ) {101 if ( in_array( rgpost( 'action' ), array( 'rg_select_export_form', 'gf_process_export' ) ) ) { 94 102 $form = $this->setup_form( $form ); 95 103 } … … 100 108 function register_init_scripts( $form ) { 101 109 102 $inputs = array();110 $inputs = array(); 103 111 $taxonomies = array(); 104 112 105 foreach ( $form['fields'] as $field ) {106 107 if ( ! $this->has_tax_enhanced_ui( $field ) ) {113 foreach ( $form['fields'] as $field ) { 114 115 if ( ! $this->has_tax_enhanced_ui( $field ) ) { 108 116 continue; 109 117 } 110 118 111 $inputs[] = array( 'input' => sprintf( '#input_%d_%d', $form['id'], $field->id ), 'taxonomy' => $field->saveToTaxonomy ); 112 if( ! array_key_exists( $field->saveToTaxonomy, $taxonomies ) ) { 119 $inputs[] = array( 120 'input' => sprintf( '#input_%d_%d', $form['id'], $field->id ), 121 'taxonomy' => $field->saveToTaxonomy 122 ); 123 124 if ( ! array_key_exists( $field->saveToTaxonomy, $taxonomies ) ) { 113 125 $taxonomies[ $field->saveToTaxonomy ] = get_terms( $field->saveToTaxonomy, 'orderby=name&hide_empty=0&fields=names' ); 114 126 } … … 116 128 } 117 129 118 if ( empty( $inputs ) ) {130 if ( empty( $inputs ) ) { 119 131 return; 120 132 } … … 143 155 function enqueue_form_scripts( $form ) { 144 156 145 if ( ! $this->has_tax_enhanced_ui( $form ) ) {157 if ( ! $this->has_tax_enhanced_ui( $form ) ) { 146 158 return; 147 159 } 148 160 149 wp_register_style( 'gfcpt_jquery_ui_theme', plugins_url( 'css/custom/jquery-ui-1.8.16.custom.css' , __FILE__ ) );161 wp_register_style( 'gfcpt_jquery_ui_theme', plugins_url( 'css/custom/jquery-ui-1.8.16.custom.css', __FILE__ ) ); 150 162 wp_enqueue_style( 'gfcpt_jquery_ui_theme' ); 151 163 152 wp_register_style( 'gfcpt_tagit_css', plugins_url( 'css/jquery.tagit.css' , __FILE__ ) );164 wp_register_style( 'gfcpt_tagit_css', plugins_url( 'css/jquery.tagit.css', __FILE__ ) ); 153 165 wp_enqueue_style( 'gfcpt_tagit_css' ); 154 166 … … 157 169 wp_enqueue_script( 'jquery-ui-autocomplete' ); 158 170 159 wp_register_script( 'gfcpt_tagit_js', plugins_url( 'js/tag-it.js' , __FILE__ ), array( 'jquery-ui-widget' ) );171 wp_register_script( 'gfcpt_tagit_js', plugins_url( 'js/tag-it.js', __FILE__ ), array( 'jquery-ui-widget' ) ); 160 172 wp_enqueue_script( 'gfcpt_tagit_js' ); 161 173 162 wp_register_script( 'gfcpt_tagit_init_js', plugins_url( 'js/tag-it.init.js' , __FILE__ ), array('gfcpt_tagit_js' ), false, true );174 wp_register_script( 'gfcpt_tagit_init_js', plugins_url( 'js/tag-it.init.js', __FILE__ ), array( 'gfcpt_tagit_js' ), false, true ); 163 175 wp_enqueue_script( 'gfcpt_tagit_init_js' ); 164 176 … … 167 179 function has_tax_enhanced_ui( $form_or_field ) { 168 180 169 if ( is_a( $form_or_field, 'GF_Field' ) ) {170 if ( $form_or_field->get_input_type() == 'text' && $form_or_field->saveToTaxonomy && $form_or_field->taxonomyEnhanced ) {181 if ( is_a( $form_or_field, 'GF_Field' ) ) { 182 if ( $form_or_field->get_input_type() == 'text' && $form_or_field->saveToTaxonomy && $form_or_field->taxonomyEnhanced ) { 171 183 return true; 172 184 } 173 185 } else { 174 foreach ( $form_or_field['fields'] as $field ) {175 if ( $this->has_tax_enhanced_ui( $field ) ) {186 foreach ( $form_or_field['fields'] as $field ) { 187 if ( $this->has_tax_enhanced_ui( $field ) ) { 176 188 return true; 177 189 } … … 193 205 194 206 //check if the form saves a post 195 if ( $this->is_form_a_post_form( $form) ) {207 if ( $this->is_form_a_post_form( $form ) ) { 196 208 $target_post_type = $this->get_form_post_type( $form ); 197 209 198 if ( $target_post_type)210 if ( $target_post_type ) { 199 211 $post_data["post_type"] = $target_post_type; 212 } 200 213 201 214 //then check if we have set a parent 202 215 $parent_post_id = $this->get_form_parent_post_id( $form ); 203 216 204 if ($parent_post_id > 0) { 205 $post_data["post_parent"] = $parent_post_id; 206 } 207 } 217 if ( $parent_post_id > 0 ) { 218 $post_data["post_parent"] = $parent_post_id; 219 } 220 } 221 208 222 return $post_data; 209 223 … … 214 228 */ 215 229 function is_form_a_post_form( $form ) { 216 foreach ($form["fields"] as $field) { 217 if(in_array($field["type"], 218 array("post_category","post_title","post_content", 219 "post_excerpt","post_tags","post_custom_fields","post_image"))) 230 foreach ( $form["fields"] as $field ) { 231 if ( in_array( $field["type"], 232 array( 233 "post_category", 234 "post_title", 235 "post_content", 236 "post_excerpt", 237 "post_tags", 238 "post_custom_fields", 239 "post_image" 240 ) ) ) { 220 241 return true; 221 } 242 } 243 } 244 222 245 return false; 223 246 } … … 280 303 */ 281 304 function setup_post_type_field( &$field, $post_type ) { 282 $first_choice = $field['choices'][0]['text'];283 $field['choices'] = $this->load_post_type_choices( $post_type, $first_choice, $field );305 $first_choice = $field['choices'][0]['text']; 306 $field['choices'] = $this->load_post_type_choices( $post_type, $first_choice, $field ); 284 307 $field->enableChoiceValue = true; 285 308 } 286 309 287 function load_post_type_choices( $post_type, $first_choice = '', $field ) {310 function load_post_type_choices( $post_type, $first_choice = '', $field ) { 288 311 $posts = $this->load_posts_hierarchical( $post_type, $field->formId, $field->id ); 289 if ( $first_choice === '' || $first_choice === 'First Choice'){312 if ( $first_choice === '' || $first_choice === 'First Choice' ) { 290 313 // if no default option is specified, dynamically create based on post type name 291 $post_type_obj = get_post_type_object($post_type); 292 $choices[] = array('text' => "-- select a {$post_type_obj->labels->singular_name} --", 'value' => ''); 314 $post_type_obj = get_post_type_object( $post_type ); 315 $choices[] = array( 316 'text' => "-- select a {$post_type_obj->labels->singular_name} --", 317 'value' => '' 318 ); 293 319 } else { 294 $choices[] = array( 'text' => $first_choice, 'value' => '');295 } 296 297 foreach ($posts as $post) {298 $choices[] = array( 'value' => $post->ID, 'text' => $post->post_title);320 $choices[] = array( 'text' => $first_choice, 'value' => '' ); 321 } 322 323 foreach ( $posts as $post ) { 324 $choices[] = array( 'value' => $post->ID, 'text' => $post->post_title ); 299 325 } 300 326 … … 306 332 */ 307 333 function load_posts_hierarchical( $post_type, $form_id, $field_id ) { 308 $args = gf_apply_filters( 'gfcpt_get_posts_args', array( $form_id, $field_id ), array(334 $args = gf_apply_filters( 'gfcpt_get_posts_args', array( $form_id, $field_id ), array( 309 335 'post_type' => $post_type, 310 'numberposts' => - 1,336 'numberposts' => - 1, 311 337 'orderby' => $post_type == 'page' ? 'menu_order' : 'title', 312 338 'order' => $post_type == 'page' ? null : 'ASC', … … 314 340 ) ); 315 341 $posts = get_posts( $args ); 342 316 343 return $this->walk_posts( $posts ); 317 344 } … … 320 347 * Helper function to recursively 'walk' the posts 321 348 */ 322 function walk_posts( $input_array, $parent_id =0, &$out_array=array(), $level=0 ){349 function walk_posts( $input_array, $parent_id = 0, &$out_array = array(), $level = 0 ) { 323 350 foreach ( $input_array as $item ) { 324 351 if ( $item->post_parent == $parent_id ) { 325 $item->post_title = str_repeat('--', $level) . $item->post_title; 326 $out_array[] = $item; 327 $this->walk_posts( $input_array, $item->ID, $out_array, $level+1 ); 328 } 329 } 352 $item->post_title = str_repeat( '--', $level ) . $item->post_title; 353 $out_array[] = $item; 354 $this->walk_posts( $input_array, $item->ID, $out_array, $level + 1 ); 355 } 356 } 357 330 358 return $out_array; 331 359 } … … 336 364 function setup_taxonomy_field( &$field, $taxonomy ) { 337 365 338 $first_choice = rgars( $field, 'choices/0/text' );339 $field['choices'] = $this->load_taxonomy_choices( $taxonomy, $field['type'], $first_choice, $field );366 $first_choice = rgars( $field, 'choices/0/text' ); 367 $field['choices'] = $this->load_taxonomy_choices( $taxonomy, $field['type'], $first_choice, $field ); 340 368 $field->enableChoiceValue = true; 341 369 … … 347 375 $counter = 0; 348 376 //recreate the inputs so they are captured correctly on form submission 349 foreach ( $field['choices'] as $choice ) {377 foreach ( $field['choices'] as $choice ) { 350 378 351 379 //thanks to Peter Schuster for the help on this fix 352 $counter ++;380 $counter ++; 353 381 if ( $counter % 10 == 0 ) { 354 $counter ++;355 } 356 357 $id = $field['id'] . '.' . $counter;382 $counter ++; 383 } 384 385 $id = $field['id'] . '.' . $counter; 358 386 $inputs[] = array( 'label' => $choice['text'], 'id' => $id ); 359 387 } … … 367 395 * Load any taxonomy terms 368 396 */ 369 function load_taxonomy_choices( $taxonomy, $type, $first_choice = '', $field ) {397 function load_taxonomy_choices( $taxonomy, $type, $first_choice = '', $field ) { 370 398 $choices = array(); 371 399 372 if ( in_array( $field->get_input_type(), gf_apply_filters( array( 'gfcpt_hierarchical_display', $field->formId, $field->fieldId ), array( 'select', 'multiselect' ) ) ) ) { 400 if ( in_array( $field->get_input_type(), gf_apply_filters( array( 401 'gfcpt_hierarchical_display', 402 $field->formId, 403 $field->fieldId 404 ), array( 'select', 'multiselect' ) ) ) ) { 373 405 374 406 $terms = $this->load_taxonomy_hierarchical( $taxonomy, $field ); 375 407 376 if ( $field->get_input_type() == 'select' ) {408 if ( $field->get_input_type() == 'select' ) { 377 409 if ( $first_choice !== '' && $first_choice !== 'First Choice' && empty( $field->placeholder ) ) { 378 410 // if no default option is specified, dynamically create based on taxonomy name 379 $taxonomy = get_taxonomy($taxonomy); 380 $choices[] = array('text' => "-- select a {$taxonomy->labels->singular_name} --", 'value' => ''); 411 $taxonomy = get_taxonomy( $taxonomy ); 412 $choices[] = array( 413 'text' => "-- select a {$taxonomy->labels->singular_name} --", 414 'value' => '' 415 ); 381 416 } 382 417 } 383 418 384 419 } else { 385 $terms = get_terms( $taxonomy, 'orderby=name&hide_empty=0');386 } 387 388 if ( ! array_key_exists("errors",$terms) ) {389 foreach($terms as $term) {390 $choices[] = array('value' => $term->term_id, 'text' => $term->name);391 }420 $terms = get_terms( $taxonomy, 'orderby=name&hide_empty=0' ); 421 } 422 423 if ( ! array_key_exists( "errors", $terms ) ) { 424 foreach ( $terms as $term ) { 425 $choices[] = array( 'value' => $term->term_id, 'text' => $term->name ); 426 } 392 427 } 393 428 … … 401 436 402 437 $args = gf_apply_filters( 'gfcpt_taxonomy_args', array( $field->formId, $field->id ), array( 403 'taxonomy' => $taxonomy,404 'orderby' => 'name',405 'hierarchical' => 1,406 'hide_empty' => 0438 'taxonomy' => $taxonomy, 439 'orderby' => 'name', 440 'hierarchical' => 1, 441 'hide_empty' => 0 407 442 ), $field ); 408 443 409 $terms = get_categories( $args );410 411 if ( array_key_exists( "errors",$terms) ) {444 $terms = get_categories( $args ); 445 446 if ( array_key_exists( "errors", $terms ) ) { 412 447 return $terms; 413 448 } else { 414 449 $parent = isset( $args['parent'] ) ? $args['parent'] : 0; 450 415 451 return $this->walk_terms( $terms, $parent ); 416 452 } … … 421 457 * Helper function to recursively 'walk' the taxonomy terms 422 458 */ 423 function walk_terms( $input_array, $parent_id =0, &$out_array=array(), $level=0 ){459 function walk_terms( $input_array, $parent_id = 0, &$out_array = array(), $level = 0 ) { 424 460 foreach ( $input_array as $item ) { 425 461 if ( $item->parent == $parent_id ) { 426 $item->name = str_repeat('--', $level) . $item->name; 427 $out_array[] = $item; 428 $this->walk_terms( $input_array, $item->term_id, $out_array, $level+1 ); 429 } 430 } 462 $item->name = str_repeat( '--', $level ) . $item->name; 463 $out_array[] = $item; 464 $this->walk_terms( $input_array, $item->term_id, $out_array, $level + 1 ); 465 } 466 } 467 431 468 return $out_array; 432 469 } … … 442 479 $this->delete_custom_taxonomies( $entry, $form ); 443 480 444 foreach ( $form['fields'] as &$field ) {481 foreach ( $form['fields'] as &$field ) { 445 482 446 483 $taxonomy = $this->get_field_taxonomy( $field ); 447 484 448 if ( !$taxonomy ) continue; 485 if ( ! $taxonomy ) { 486 continue; 487 } 449 488 450 489 $this->save_taxonomy_field( $field, $entry, $taxonomy ); … … 456 495 * Remove Custom Taxonomies 457 496 * 497 * @return void 458 498 * @author ekaj 459 * @return void460 499 */ 461 500 public function delete_custom_taxonomies( $entry, $form ) { 462 501 // Check if the submission contains a WordPress post 463 if (! empty($entry['post_id']) ) 464 { 465 foreach( $form['fields'] as &$field ) 466 { 467 $taxonomy = false; 468 if ( array_key_exists('populateTaxonomy', $field) ) { 469 $taxonomy = $field['populateTaxonomy']; 470 } 502 if ( ! empty( $entry['post_id'] ) ) { 503 foreach ( $form['fields'] as &$field ) { 504 $taxonomy = rgar( $field, 'populateTaxonomy' ); 471 505 472 506 if ( $taxonomy ) { 473 wp_set_object_terms( $entry['post_id'], NULL, $taxonomy );507 wp_set_object_terms( $entry['post_id'], null, $taxonomy ); 474 508 } 475 509 } … … 484 518 $terms = array(); 485 519 486 switch ( $field->get_input_type() ) {520 switch ( $field->get_input_type() ) { 487 521 case 'multiselect': 488 522 … … 490 524 $terms = json_decode( $value ); 491 525 492 if ( ! is_array( $terms ) ) {526 if ( ! is_array( $terms ) ) { 493 527 $terms = explode( ',', $value ); 494 528 } … … 528 562 $return = $term_id; 529 563 530 if ( $field->populateTaxonomy && ! empty( $term_id ) ) {564 if ( $field->populateTaxonomy && ! empty( $term_id ) ) { 531 565 $term = get_term( (int) $term_id, $field->populateTaxonomy ); 532 if ( ! is_wp_error( $term ) ) {566 if ( ! is_wp_error( $term ) ) { 533 567 $return = $term->name; 534 568 } … … 544 578 function display_term_name_on_entry_list( $value, $form_id, $field_id ) { 545 579 546 if ( is_numeric( $field_id ) ) {580 if ( is_numeric( $field_id ) ) { 547 581 $field = GFFormsModel::get_field( GFAPI::get_form( $form_id ), $field_id ); 548 582 $value = $this->get_term_name( $value, $field ); … … 558 592 function get_post_title( $post_id, $field ) { 559 593 560 if ( $field->populatePostType && ! empty( $post_id ) ) {594 if ( $field->populatePostType && ! empty( $post_id ) ) { 561 595 $post = get_post( $post_id ); 596 562 597 return $post ? $post->post_title : $post_id; 563 598 } … … 572 607 function display_post_title_on_entry_list( $value, $form_id, $field_id ) { 573 608 574 if ( is_numeric( $field_id ) ) {609 if ( is_numeric( $field_id ) ) { 575 610 $field = GFFormsModel::get_field( GFAPI::get_form( $form_id ), $field_id ); 576 611 $value = $this->get_post_title( $value, $field ); -
gravity-forms-custom-post-types/tags/3.1.20/readme.txt
r2542253 r2542615 81 81 82 82 == Changelog == 83 84 = 3.1.20 = 85 86 * Fixed PHP notice on Gravity Forms Coupons Add-On page. 87 * Fixed PHP warning when populating taxonomies. 88 * Updated formatting of PHP files in plugin to better conform to the WordPress Coding Standards. 83 89 84 90 = 3.1.19 = -
gravity-forms-custom-post-types/trunk/gfcptaddon.php
r2542253 r2542615 4 4 Plugin URI: https://gravitywiz.com/ 5 5 Description: Map your Gravity-Forms-generated posts to a custom post type and/or custom taxonomies. 6 Version: 3.1. 196 Version: 3.1.20 7 7 Author: Gravity Wiz 8 8 Author URI: https://gravitywiz.com/ … … 10 10 */ 11 11 12 add_action( 'init', array('GFCPTAddon', 'init'), 20);13 add_action( 'admin_notices', array('GFCPTAddon', 'admin_warnings'), 20);12 add_action( 'init', array( 'GFCPTAddon', 'init' ), 20 ); 13 add_action( 'admin_notices', array( 'GFCPTAddon', 'admin_warnings' ), 20 ); 14 14 15 15 class GFCPTAddon { 16 16 17 private static $name= 'Gravity Forms + Custom Post Types';18 private static $slug= 'GFCPTAddon';19 private static $version = '3.1.19';20 private static $min_gravityforms_version = '1.9.3';17 private static $name = 'Gravity Forms + Custom Post Types'; 18 private static $slug = 'GFCPTAddon'; 19 private static $version = '3.1.20'; 20 private static $min_gravityforms_version = '1.9.3'; 21 21 22 //Plugin starting point. Will load appropriate files23 public static function init(){22 //Plugin starting point. Will load appropriate files 23 public static function init() { 24 24 25 if(self::is_gravityforms_installed()){ 26 27 global $gf_cpt_addon; 25 if ( self::is_gravityforms_installed() ) { 28 26 29 //include the base class 30 require_once(self::get_base_path() . '/gfcptaddonbase.php'); 27 global $gf_cpt_addon; 31 28 32 //only supports 1.5 and over 33 require_once(self::get_base_path() . '/gfcptaddon_1-5.php'); 34 $gf_cpt_addon = new GFCPTAddon1_5(); 29 //include the base class 30 require_once( self::get_base_path() . '/gfcptaddonbase.php' ); 35 31 36 //start me up! 37 $gf_cpt_addon->init(__FILE__); 38 } 39 } 32 //only supports 1.5 and over 33 require_once( self::get_base_path() . '/gfcptaddon_1-5.php' ); 34 $gf_cpt_addon = new GFCPTAddon1_5(); 40 35 41 //display admin warnings if GF is not the correct version or GF is not installed 42 public static function admin_warnings() { 43 if ( !self::is_gravityforms_installed() ) { 44 $message = __('requires Gravity Forms to be installed.', self::$slug); 45 } else if ( !self::is_gravityforms_supported() ) { 46 $message = __('requires a minimum Gravity Forms version of ', self::$slug) . self::$min_gravityforms_version; 47 } 36 //start me up! 37 $gf_cpt_addon->init( __FILE__ ); 38 } 39 } 48 40 49 if (empty($message)) { 50 return; 51 } 52 ?> 53 <div class="error"> 54 <p> 55 <?php _e('The plugin ', self::$slug); ?><strong><?php echo self::$name; ?></strong> <?php echo $message; ?><br /> 56 <?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) ?> 57 </p> 58 </div> 59 <?php 60 } 41 //display admin warnings if GF is not the correct version or GF is not installed 42 public static function admin_warnings() { 43 if ( ! self::is_gravityforms_installed() ) { 44 $message = __( 'requires Gravity Forms to be installed.', self::$slug ); 45 } elseif ( ! self::is_gravityforms_supported() ) { 46 $message = __( 'requires a minimum Gravity Forms version of ', self::$slug ) . self::$min_gravityforms_version; 47 } 61 48 62 /* 63 * Check if GF is installed 64 */ 65 private static function is_gravityforms_installed(){ 66 return class_exists( 'RGForms' ); 67 } 49 if ( empty( $message ) ) { 50 return; 51 } 52 ?> 53 <div class="error"> 54 <p> 55 <?php _e( 'The plugin ', self::$slug ); ?> 56 <strong><?php echo self::$name; ?></strong> <?php echo $message; ?><br/> 57 <?php _e( 'Please ', self::$slug ); ?><a 58 href="http://bit.ly/getgravityforms"><?php _e( ' download the latest version ', self::$slug ); ?></a><?php _e( ' of Gravity Forms and try again.', self::$slug ); ?> 59 </p> 60 </div> 61 <?php 62 } 68 63 69 /*70 * Check if the installed version of GF is supported71 */72 private static function is_gravityforms_supported(){73 return self::check_gravityforms_version( self::$min_gravityforms_version,'>=' );74 }64 /* 65 * Check if GF is installed 66 */ 67 private static function is_gravityforms_installed() { 68 return class_exists( 'RGForms' ); 69 } 75 70 76 /* 77 * Do a GF version compare 78 */ 79 private static function check_gravityforms_version($version, $operator){ 80 if(class_exists('GFCommon')){ 81 return version_compare( GFCommon::$version, $version, $operator ); 82 } 83 return false; 84 } 71 /* 72 * Check if the installed version of GF is supported 73 */ 74 private static function is_gravityforms_supported() { 75 return self::check_gravityforms_version( self::$min_gravityforms_version, '>=' ); 76 } 85 77 86 /* 87 * Returns the url of the plugin's root folder 88 */ 89 protected function get_base_url(){ 90 return plugins_url(null, __FILE__); 91 } 78 /* 79 * Do a GF version compare 80 */ 81 private static function check_gravityforms_version( $version, $operator ) { 82 if ( class_exists( 'GFCommon' ) ) { 83 return version_compare( GFCommon::$version, $version, $operator ); 84 } 92 85 93 /* 94 * Returns the physical path of the plugin's root folder 95 */ 96 protected static function get_base_path(){ 97 return dirname( __FILE__ ); 98 } 86 return false; 87 } 99 88 100 /** 101 * starts_with 102 * Tests if a text starts with an given string. 103 * 104 * @param string 105 * @param string 106 * @return bool 107 */ 108 public static function starts_with($haystack, $needle){ 109 return strpos($haystack, $needle) === 0; 110 } 89 /* 90 * Returns the url of the plugin's root folder 91 */ 92 protected function get_base_url() { 93 return plugins_url( null, __FILE__ ); 94 } 111 95 112 /*113 * returns true if a needle can be found in a haystack 114 */115 public static function str_contains($haystack, $needle) {116 if (empty($haystack) || empty($needle)) 117 return false; 96 /* 97 * Returns the physical path of the plugin's root folder 98 */ 99 protected static function get_base_path() { 100 return dirname( __FILE__ ); 101 } 118 102 119 $pos = strpos(strtolower($haystack), strtolower($needle)); 103 /** 104 * starts_with 105 * Tests if a text starts with an given string. 106 * 107 * @param string 108 * @param string 109 * 110 * @return bool 111 */ 112 public static function starts_with( $haystack, $needle ) { 113 return strpos( $haystack, $needle ) === 0; 114 } 120 115 121 if ($pos === false) 122 return false; 123 else 124 return true; 125 } 116 /* 117 * returns true if a needle can be found in a haystack 118 */ 119 public static function str_contains( $haystack, $needle ) { 120 if ( empty( $haystack ) || empty( $needle ) ) { 121 return false; 122 } 123 124 $pos = strpos( strtolower( $haystack ), strtolower( $needle ) ); 125 126 if ( $pos === false ) { 127 return false; 128 } else { 129 return true; 130 } 131 } 126 132 } -
gravity-forms-custom-post-types/trunk/gfcptaddon_1-5.php
r2542252 r2542615 1 1 <?php 2 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_standard_settings', array(&$this, 'render_field_standard_settings'), 10, 2); 20 add_action('gform_field_advanced_settings', array(&$this, 'render_field_advanced_settings'), 10, 2); 21 22 //include javascript for the form builder 23 add_action('gform_editor_js', array(&$this, 'render_editor_js')); 24 25 // filter to add a new tooltip 26 add_filter('gform_tooltips', array(&$this, 'add_gf_tooltips')); 27 } 28 29 /* 30 * Override. Gets the post type from our new field value 31 */ 32 function get_field_post_type( $field ) { 33 if ( isset( $field->populatePostType ) ) { 34 return $field->populatePostType; 35 } 36 37 return false; 38 } 39 40 /* 41 * Override. Gets the taxonomy from our new field value 42 */ 43 function get_field_taxonomy( $field ) { 44 if ( isset( $field->populateTaxonomy ) ) { 45 return $field->populateTaxonomy; 46 } elseif ( isset( $field->saveToTaxonomy ) ) { 47 return $field->saveToTaxonomy; 48 } 49 50 return false; 51 } 52 53 /* 54 * Override. Gets the custom post type from the post title field value 55 */ 56 function get_form_post_type( $form ) { 57 foreach ( $form['fields'] as $field ) { 58 if ( $field['type'] == 'post_title' && $field['saveAsCPT'] ) 59 return $field['saveAsCPT']; 60 } 61 return false; 62 } 63 64 function get_form_parent_post_id( $form ) { 65 foreach ( $form['fields'] as $field ) { 66 if ( $field['type'] == 'select' && $field['setParentPost'] ) { 67 $parent_id = RGForms::post('input_'.$field['id']); 68 return $parent_id; 69 } 70 } 71 return 0; 72 } 73 74 /* 75 * Add tooltips for the new field values 76 */ 77 function add_gf_tooltips($tooltips){ 78 $tooltips["form_field_populate_post_type"] = "<h6>Populate with a Post Type</h6>Check this box to populate this field from a specific post type."; 79 $tooltips["form_field_set_parent_post"] = "<h6>Try to set parent</h6>If this is checked, and the form creates a post type, then the parent for the newly created post type will be set from the value of this field. Please note that this only works for heirarcical post typs e.g. pages"; 80 $tooltips["form_field_custom_taxonomy"] = "<h6>Populate with a Taxonomy</h6>Check this box to populate this field from a custom taxonomy."; 81 $tooltips["form_field_custom_post_type"] = sprintf( '<h6>%s</h6> %s', __( 'Post Type', 'gravityforms' ), __( 'This form will create a WordPress post. Which post type should that post be assigned? Use this setting to specify the desired post type.' ) ); 82 $tooltips["form_field_save_to_taxonomy"] = "<h6>Save To Taxonomy</h6>Check this box to save this field to a specific custom taxonomy. Please note that the taxonomy must NOT be hierarchical."; 83 $tooltips["form_field_tax_enhanced"] = "<h6>Enable Enhanced UI</h6>By selecting this option, this field will be tranformed into a 'tag input' control which makes it more user-friendly for selecting existing and capturing new taxonomies."; 84 return $tooltips; 85 } 86 87 /* 88 * Add some advanced settings to the fields 89 */ 90 function render_field_standard_settings( $position, $form_id ) { 91 if( $position == 50 ) { 92 ?> 93 <li class="custom_post_type_field_setting field_setting"> 94 <label for="field_populate_custom_post_type"><?php _e( 'Post Type', 'gravityforms' ); ?> <?php gform_tooltip("form_field_custom_post_type") ?></label> 95 <select id="field_populate_custom_post_type" onchange="SetFieldProperty('saveAsCPT', jQuery(this).val());"> 96 <?php foreach( $this->get_post_types( $form_id ) as $post_type ): ?> 97 <option value="<?php echo $post_type->name; ?>" <?php selected( 'post', $post_type->name ); ?>><?php echo $post_type->label; ?></option> 98 <?php endforeach; ?> 99 </select> 100 </li> 101 <?php 102 } 103 104 } 105 106 /* 107 * Add some advanced settings to the fields 108 */ 109 function render_field_advanced_settings($position, $form_id){ 110 if($position == 50){ 111 ?> 112 <li class="populate_with_taxonomy_field_setting field_setting" style="display:list-item;"> 113 <input type="checkbox" id="field_enable_populate_with_taxonomy" /> 114 <label for="field_enable_populate_with_taxonomy" class="inline"> 115 <?php _e("Populate with a Taxonomy", "gravityforms"); ?> 116 </label> 117 <?php gform_tooltip("form_field_custom_taxonomy") ?><br /> 118 <select id="field_populate_taxonomy" onchange="SetFieldProperty('populateTaxonomy', jQuery(this).val());" style="margin-top:10px; display:none;"> 119 <option value="" style="color:#999;">Select a Taxonomy</option> 120 <?php foreach( $this->get_taxonomies( $form_id ) as $taxonomy ): ?> 121 <option value="<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></option> 122 <?php endforeach; ?> 123 </select> 124 </li> 125 <li class="populate_with_post_type_field_setting field_setting" style="display:list-item;"> 126 <input type="checkbox" class="toggle_setting" id="field_enable_populate_with_post_type" /> 127 <label for="field_enable_populate_with_post_type" class="inline"> 128 <?php _e("Populate with a Post Type", "gravityforms"); ?> 129 </label> 130 <?php gform_tooltip("form_field_populate_post_type") ?><br /> 131 <div style="margin-top:10px; display:none;"> 132 <select id="field_populate_post_type" onchange="SetFieldProperty('populatePostType', jQuery(this).val());"> 133 <option value="" style="color:#999;">Select a Post Type</option> 134 <?php 135 foreach( $this->get_post_types( $form_id ) as $post_type ): ?> 136 <option value="<?php echo $post_type->name; ?>"><?php echo $post_type->label; ?></option> 137 <?php endforeach; ?> 138 </select> 139 <input type="checkbox" class="check_parent" onclick="SetFieldProperty('setParentPost', this.checked);" id="field_set_parent_post" /> 140 <label for="field_set_parent_post" class="inline"> 141 <?php _e("Try to set parent", "gravityforms"); ?> 142 </label> 143 <?php gform_tooltip("form_field_set_parent_post") ?> 144 </div> 145 </li> 146 <li class="save_to_taxonomy_field_setting field_setting" style="display:list-item;"> 147 <input type="checkbox" class="toggle_setting" id="field_enable_save_to_taxonomy" /> 148 <label for="field_enable_save_to_taxonomy" class="inline"> 149 <?php _e("Save To Taxonomy", "gravityforms"); ?> 150 </label> 151 <?php gform_tooltip("form_field_save_to_taxonomy") ?> 152 <div style="margin-top:10px; display:none;"> 153 <select id="field_save_to_taxonomy" onchange="SetFieldProperty('saveToTaxonomy', jQuery(this).val());"> 154 <option value="" style="color:#999;">Select a Taxonomy</option> 155 <?php foreach( $this->get_taxonomies( $form_id ) as $taxonomy ): 156 if ( $taxonomy->hierarchical === false ): ?> 157 <option value="<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></option> 158 <?php endif; ?> 159 <?php endforeach; ?> 160 161 </select> 162 <input type="checkbox" class="check_tax_enhanced" onclick="SetFieldProperty('taxonomyEnhanced', this.checked);" id="field_tax_enhanced" /> 163 <label for="field_tax_enhanced" class="inline"> 164 <?php _e("Enable enhanced UI", "gravityforms"); ?> 165 </label> 166 <?php gform_tooltip("form_field_tax_enhanced") ?> 167 </div> 168 </li> 169 <?php 170 } 171 172 } 173 174 /* 175 * render some custom JS to get the settings to work 176 */ 177 function render_editor_js(){ 178 ?> 179 <script type='text/javascript'> 180 181 jQuery(document).bind("gform_load_field_settings", function(event, field, form){ 182 //only show taxonomy for selects and radios 183 var valid_types = new Array('select', 'radio', 'checkbox', 'multiselect'); 184 185 //alert(field['type']); 186 187 if(jQuery.inArray(field['type'], valid_types) != -1) { 188 189 var $taxonomy_setting_container = jQuery(".populate_with_taxonomy_field_setting"); 190 //show the setting container! 191 $taxonomy_setting_container.show(); 192 193 //get the saved taxonomy 194 var populateTaxonomy = (typeof field['populateTaxonomy'] != 'undefined' && field['populateTaxonomy'] != '') ? field['populateTaxonomy'] : false; 195 196 if (populateTaxonomy != false) { 197 //check the checkbox if previously checked 198 $taxonomy_setting_container.find("input:checkbox").attr("checked", "checked"); 199 //set the select and show 200 $taxonomy_setting_container.find("select").val(populateTaxonomy).show(); 201 } else { 202 $taxonomy_setting_container.find("input:checkbox").removeAttr("checked"); 203 $taxonomy_setting_container.find("select").val('').hide(); 204 } 205 206 if (field['type'] == 'select') { 207 var $populate_post_type_container = jQuery(".populate_with_post_type_field_setting"); 208 $populate_post_type_container.show(); 209 210 //get the saved post type 211 var populatePostType = (typeof field['populatePostType'] != 'undefined' && field['populatePostType'] != '') ? field['populatePostType'] : false; 212 213 if (populatePostType != false) { 214 //check the checkbox if previously checked 215 $populate_post_type_container.find("input.toggle_setting").attr("checked", "checked"); 216 //set the select 217 $populate_post_type_container.find("select").val(populatePostType); 218 //show the div 219 $populate_post_type_container.find("div").show(); 220 221 //get the saved check for setting the parent post 222 var setParent = (typeof field['setParentPost'] != 'undefined' && field['setParentPost'] != '') ? field['setParentPost'] : false; 223 if (setParent != false) { 224 $populate_post_type_container.find(".check_parent").attr("checked", "checked"); 225 } else { 226 $populate_post_type_container.find(".check_parent").removeAttr("checked"); 227 } 228 } else { 229 /*$taxonomy_setting_container.find("input.toggle_setting").removeAttr("checked"); 230 $taxonomy_setting_container.find("select").val('');*/ 231 $populate_post_type_container.find("input.toggle_setting").removeAttr("checked"); 232 $populate_post_type_container.find("select").val(''); 233 } 234 235 } 236 237 } else if (field['type'] == 'post_title') { 238 239 var $cpt_setting_container = jQuery(".custom_post_type_field_setting" ), 240 saveAsCPT = ( typeof field['saveAsCPT'] != 'undefined' && field['saveAsCPT'] != '') ? field['saveAsCPT'] : 'post'; 241 242 //set the select and show 243 $cpt_setting_container.show().find( 'select' ).val( saveAsCPT ); 244 245 } else if (field['type'] == 'text') { 246 var $tax_setting_container = jQuery('.save_to_taxonomy_field_setting'); 247 248 $tax_setting_container.show(); 249 250 var saveToTax = (typeof field['saveToTaxonomy'] != 'undefined' && field['saveToTaxonomy'] != '') ? field['saveToTaxonomy'] : false; 251 252 if (saveToTax != false) { 253 //check the checkbox if previously checked 254 $tax_setting_container.find("input.toggle_setting").attr("checked", "checked"); 255 //set the select 256 $tax_setting_container.find("select").val(saveToTax); 257 //show the div 258 $tax_setting_container.find("div").show(); 259 260 //get the saved check for using enhanced UI 261 var useEnhancedUI = (typeof field['taxonomyEnhanced'] != 'undefined' && field['taxonomyEnhanced'] != '') ? field['taxonomyEnhanced'] : false; 262 if (useEnhancedUI != false) { 263 $tax_setting_container.find(".check_tax_enhanced").attr("checked", "checked"); 264 } else { 265 $tax_setting_container.find(".check_tax_enhanced").removeAttr("checked"); 266 } 267 268 } else { 269 $tax_setting_container.find("input.toggle_setting").removeAttr("checked"); 270 $tax_setting_container.find("div").hide(); 271 $tax_setting_container.find(".check_tax_enhanced").removeAttr("checked"); 272 $tax_setting_container.find("select").val(''); 273 } 274 } 275 }); 276 277 jQuery(".populate_with_taxonomy_field_setting input:checkbox").click(function() { 278 var checked = jQuery(this).is(":checked"); 279 var $select = jQuery(this).parent(".populate_with_taxonomy_field_setting:first").find("select"); 280 if(checked){ 281 $select.slideDown(); 282 283 //uncheck post type 284 var $pt_container = jQuery(this).parents("ul:first").find(".populate_with_post_type_field_setting:first"); 285 var $pt_check = $pt_container.find("input.toggle_setting"); 286 var $pt_div = $pt_container.find("div"); 287 if ($pt_check.is(":checked")) { 288 289 SetFieldProperty('populatePostType',''); 290 $pt_div.slideUp(); 291 $pt_check.removeAttr('checked'); 292 293 } 294 295 } else { 296 SetFieldProperty('populateTaxonomy',''); 297 $select.slideUp(); 298 } 299 }); 300 301 jQuery(".populate_with_post_type_field_setting .toggle_setting").click(function() { 302 var checked = jQuery(this).is(":checked"); 303 var $div = jQuery(this).parent(".populate_with_post_type_field_setting:first").find("div"); 304 if(checked){ 305 $div.slideDown(); 306 //uncheck taxonomy 307 var $tax_container = jQuery(this).parents("ul:first").find(".populate_with_taxonomy_field_setting:first"); 308 var $tax_check = $tax_container.find("input:checkbox"); 309 var $tax_select = $tax_container.find("select"); 310 if ($tax_check.is(":checked")) { 311 312 SetFieldProperty('populateTaxonomy',''); 313 $tax_select.slideUp(); 314 $tax_check.removeAttr('checked'); 315 316 } 317 318 } else { 319 SetFieldProperty('populatePostType',''); 320 $div.slideUp(); 321 } 322 }); 323 324 jQuery(".save_to_taxonomy_field_setting .toggle_setting").click(function() { 325 var checked = jQuery(this).is(":checked"); 326 var $div = jQuery(this).parent(".save_to_taxonomy_field_setting:first").find("div"); 327 if(checked){ 328 $div.slideDown(); 329 } else { 330 SetFieldProperty('saveToTaxonomy',''); 331 $div.slideUp(); 332 } 333 }); 334 335 </script> 336 <?php 337 } 338 339 } 3 if ( ! class_exists( 'GFCPTAddon1_5' ) ) { 4 5 /* 6 * GFCPT Addon class targetting version 1.5 of Gravity Forms 7 */ 8 9 class GFCPTAddon1_5 extends GFCPTAddonBase { 10 11 /* 12 * Override. Include a couple more hooks 13 */ 14 public function init() { 15 //hook up the defaults 16 parent::init(); 17 18 //then add these for 1.5... 19 //add our advanced options to the form builder 20 add_action( 'gform_field_standard_settings', array( &$this, 'render_field_standard_settings' ), 10, 2 ); 21 add_action( 'gform_field_advanced_settings', array( &$this, 'render_field_advanced_settings' ), 10, 2 ); 22 23 //include javascript for the form builder 24 add_action( 'gform_editor_js', array( &$this, 'render_editor_js' ) ); 25 26 // filter to add a new tooltip 27 add_filter( 'gform_tooltips', array( &$this, 'add_gf_tooltips' ) ); 28 } 29 30 /* 31 * Override. Gets the post type from our new field value 32 */ 33 function get_field_post_type( $field ) { 34 if ( isset( $field->populatePostType ) ) { 35 return $field->populatePostType; 36 } 37 38 return false; 39 } 40 41 /* 42 * Override. Gets the taxonomy from our new field value 43 */ 44 function get_field_taxonomy( $field ) { 45 if ( isset( $field->populateTaxonomy ) ) { 46 return $field->populateTaxonomy; 47 } elseif ( isset( $field->saveToTaxonomy ) ) { 48 return $field->saveToTaxonomy; 49 } 50 51 return false; 52 } 53 54 /* 55 * Override. Gets the custom post type from the post title field value 56 */ 57 function get_form_post_type( $form ) { 58 foreach ( $form['fields'] as $field ) { 59 if ( $field['type'] == 'post_title' && $field['saveAsCPT'] ) { 60 return $field['saveAsCPT']; 61 } 62 } 63 64 return false; 65 } 66 67 function get_form_parent_post_id( $form ) { 68 foreach ( $form['fields'] as $field ) { 69 if ( $field['type'] == 'select' && $field['setParentPost'] ) { 70 $parent_id = RGForms::post( 'input_' . $field['id'] ); 71 72 return $parent_id; 73 } 74 } 75 76 return 0; 77 } 78 79 /* 80 * Add tooltips for the new field values 81 */ 82 function add_gf_tooltips( $tooltips ) { 83 $tooltips['form_field_populate_post_type'] = '<h6>Populate with a Post Type</h6>Check this box to populate this field from a specific post type.'; 84 $tooltips['form_field_set_parent_post'] = '<h6>Try to set parent</h6>If this is checked, and the form creates a post type, then the parent for the newly created post type will be set from the value of this field. Please note that this only works for heirarcical post typs e.g. pages'; 85 $tooltips['form_field_custom_taxonomy'] = '<h6>Populate with a Taxonomy</h6>Check this box to populate this field from a custom taxonomy.'; 86 $tooltips['form_field_custom_post_type'] = sprintf( '<h6>%s</h6> %s', __( 'Post Type', 'gravityforms' ), __( 'This form will create a WordPress post. Which post type should that post be assigned? Use this setting to specify the desired post type.' ) ); 87 $tooltips['form_field_save_to_taxonomy'] = '<h6>Save To Taxonomy</h6>Check this box to save this field to a specific custom taxonomy. Please note that the taxonomy must NOT be hierarchical.'; 88 $tooltips['form_field_tax_enhanced'] = "<h6>Enable Enhanced UI</h6>By selecting this option, this field will be tranformed into a 'tag input' control which makes it more user-friendly for selecting existing and capturing new taxonomies."; 89 90 return $tooltips; 91 } 92 93 /* 94 * Add some advanced settings to the fields 95 */ 96 function render_field_standard_settings( $position, $form_id ) { 97 if ( $position == 50 ) { 98 ?> 99 <li class="custom_post_type_field_setting field_setting"> 100 <label for="field_populate_custom_post_type"><?php _e( 'Post Type', 'gravityforms' ); ?><?php gform_tooltip( 'form_field_custom_post_type' ); ?></label> 101 <select id="field_populate_custom_post_type" 102 onchange="SetFieldProperty('saveAsCPT', jQuery(this).val());"> 103 <?php foreach ( $this->get_post_types( $form_id ) as $post_type ) : ?> 104 <option value="<?php echo $post_type->name; ?>" <?php selected( 'post', $post_type->name ); ?>><?php echo $post_type->label; ?></option> 105 <?php endforeach; ?> 106 </select> 107 </li> 108 <?php 109 } 110 111 } 112 113 /* 114 * Add some advanced settings to the fields 115 */ 116 function render_field_advanced_settings( $position, $form_id ) { 117 if ( $position == 50 ) { 118 ?> 119 <li class="populate_with_taxonomy_field_setting field_setting" style="display:list-item;"> 120 <input type="checkbox" id="field_enable_populate_with_taxonomy"/> 121 <label for="field_enable_populate_with_taxonomy" class="inline"> 122 <?php _e( 'Populate with a Taxonomy', 'gravityforms' ); ?> 123 </label> 124 <?php gform_tooltip( 'form_field_custom_taxonomy' ); ?><br/> 125 <select id="field_populate_taxonomy" 126 onchange="SetFieldProperty('populateTaxonomy', jQuery(this).val());" 127 style="margin-top:10px; display:none;"> 128 <option value="" style="color:#999;">Select a Taxonomy</option> 129 <?php foreach ( $this->get_taxonomies( $form_id ) as $taxonomy ) : ?> 130 <option value="<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></option> 131 <?php endforeach; ?> 132 </select> 133 </li> 134 <li class="populate_with_post_type_field_setting field_setting" style="display:list-item;"> 135 <input type="checkbox" class="toggle_setting" id="field_enable_populate_with_post_type"/> 136 <label for="field_enable_populate_with_post_type" class="inline"> 137 <?php _e( 'Populate with a Post Type', 'gravityforms' ); ?> 138 </label> 139 <?php gform_tooltip( 'form_field_populate_post_type' ); ?><br/> 140 <div style="margin-top:10px; display:none;"> 141 <select id="field_populate_post_type" 142 onchange="SetFieldProperty('populatePostType', jQuery(this).val());"> 143 <option value="" style="color:#999;">Select a Post Type</option> 144 <?php 145 foreach ( $this->get_post_types( $form_id ) as $post_type ) : 146 ?> 147 <option value="<?php echo $post_type->name; ?>"><?php echo $post_type->label; ?></option> 148 <?php endforeach; ?> 149 </select> 150 <input type="checkbox" class="check_parent" 151 onclick="SetFieldProperty('setParentPost', this.checked);" id="field_set_parent_post"/> 152 <label for="field_set_parent_post" class="inline"> 153 <?php _e( 'Try to set parent', 'gravityforms' ); ?> 154 </label> 155 <?php gform_tooltip( 'form_field_set_parent_post' ); ?> 156 </div> 157 </li> 158 <li class="save_to_taxonomy_field_setting field_setting" style="display:list-item;"> 159 <input type="checkbox" class="toggle_setting" id="field_enable_save_to_taxonomy"/> 160 <label for="field_enable_save_to_taxonomy" class="inline"> 161 <?php _e( 'Save To Taxonomy', 'gravityforms' ); ?> 162 </label> 163 <?php gform_tooltip( 'form_field_save_to_taxonomy' ); ?> 164 <div style="margin-top:10px; display:none;"> 165 <select id="field_save_to_taxonomy" 166 onchange="SetFieldProperty('saveToTaxonomy', jQuery(this).val());"> 167 <option value="" style="color:#999;">Select a Taxonomy</option> 168 <?php 169 foreach ( $this->get_taxonomies( $form_id ) as $taxonomy ) : 170 if ( $taxonomy->hierarchical === false ) : 171 ?> 172 <option value="<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->label; ?></option> 173 <?php endif; ?> 174 <?php endforeach; ?> 175 176 </select> 177 <input type="checkbox" class="check_tax_enhanced" 178 onclick="SetFieldProperty('taxonomyEnhanced', this.checked);" id="field_tax_enhanced"/> 179 <label for="field_tax_enhanced" class="inline"> 180 <?php _e( 'Enable enhanced UI', 'gravityforms' ); ?> 181 </label> 182 <?php gform_tooltip( 'form_field_tax_enhanced' ); ?> 183 </div> 184 </li> 185 <?php 186 } 187 188 } 189 190 /* 191 * render some custom JS to get the settings to work 192 */ 193 function render_editor_js() { 194 ?> 195 <script type='text/javascript'> 196 197 jQuery(document).bind("gform_load_field_settings", function (event, field, form) { 198 //only show taxonomy for selects and radios 199 var valid_types = new Array('select', 'radio', 'checkbox', 'multiselect'); 200 201 //alert(field['type']); 202 203 if (jQuery.inArray(field['type'], valid_types) != -1) { 204 205 var $taxonomy_setting_container = jQuery(".populate_with_taxonomy_field_setting"); 206 //show the setting container! 207 $taxonomy_setting_container.show(); 208 209 //get the saved taxonomy 210 var populateTaxonomy = (typeof field['populateTaxonomy'] != 'undefined' && field['populateTaxonomy'] != '') ? field['populateTaxonomy'] : false; 211 212 if (populateTaxonomy != false) { 213 //check the checkbox if previously checked 214 $taxonomy_setting_container.find("input:checkbox").attr("checked", "checked"); 215 //set the select and show 216 $taxonomy_setting_container.find("select").val(populateTaxonomy).show(); 217 } else { 218 $taxonomy_setting_container.find("input:checkbox").removeAttr("checked"); 219 $taxonomy_setting_container.find("select").val('').hide(); 220 } 221 222 if (field['type'] == 'select') { 223 var $populate_post_type_container = jQuery(".populate_with_post_type_field_setting"); 224 $populate_post_type_container.show(); 225 226 //get the saved post type 227 var populatePostType = (typeof field['populatePostType'] != 'undefined' && field['populatePostType'] != '') ? field['populatePostType'] : false; 228 229 if (populatePostType != false) { 230 //check the checkbox if previously checked 231 $populate_post_type_container.find("input.toggle_setting").attr("checked", "checked"); 232 //set the select 233 $populate_post_type_container.find("select").val(populatePostType); 234 //show the div 235 $populate_post_type_container.find("div").show(); 236 237 //get the saved check for setting the parent post 238 var setParent = (typeof field['setParentPost'] != 'undefined' && field['setParentPost'] != '') ? field['setParentPost'] : false; 239 if (setParent != false) { 240 $populate_post_type_container.find(".check_parent").attr("checked", "checked"); 241 } else { 242 $populate_post_type_container.find(".check_parent").removeAttr("checked"); 243 } 244 } else { 245 /*$taxonomy_setting_container.find("input.toggle_setting").removeAttr("checked"); 246 $taxonomy_setting_container.find("select").val('');*/ 247 $populate_post_type_container.find("input.toggle_setting").removeAttr("checked"); 248 $populate_post_type_container.find("select").val(''); 249 } 250 251 } 252 253 } else if (field['type'] == 'post_title') { 254 255 var $cpt_setting_container = jQuery(".custom_post_type_field_setting"), 256 saveAsCPT = (typeof field['saveAsCPT'] != 'undefined' && field['saveAsCPT'] != '') ? field['saveAsCPT'] : 'post'; 257 258 //set the select and show 259 $cpt_setting_container.show().find('select').val(saveAsCPT); 260 261 } else if (field['type'] == 'text') { 262 var $tax_setting_container = jQuery('.save_to_taxonomy_field_setting'); 263 264 $tax_setting_container.show(); 265 266 var saveToTax = (typeof field['saveToTaxonomy'] != 'undefined' && field['saveToTaxonomy'] != '') ? field['saveToTaxonomy'] : false; 267 268 if (saveToTax != false) { 269 //check the checkbox if previously checked 270 $tax_setting_container.find("input.toggle_setting").attr("checked", "checked"); 271 //set the select 272 $tax_setting_container.find("select").val(saveToTax); 273 //show the div 274 $tax_setting_container.find("div").show(); 275 276 //get the saved check for using enhanced UI 277 var useEnhancedUI = (typeof field['taxonomyEnhanced'] != 'undefined' && field['taxonomyEnhanced'] != '') ? field['taxonomyEnhanced'] : false; 278 if (useEnhancedUI != false) { 279 $tax_setting_container.find(".check_tax_enhanced").attr("checked", "checked"); 280 } else { 281 $tax_setting_container.find(".check_tax_enhanced").removeAttr("checked"); 282 } 283 284 } else { 285 $tax_setting_container.find("input.toggle_setting").removeAttr("checked"); 286 $tax_setting_container.find("div").hide(); 287 $tax_setting_container.find(".check_tax_enhanced").removeAttr("checked"); 288 $tax_setting_container.find("select").val(''); 289 } 290 } 291 }); 292 293 jQuery(".populate_with_taxonomy_field_setting input:checkbox").click(function () { 294 var checked = jQuery(this).is(":checked"); 295 var $select = jQuery(this).parent(".populate_with_taxonomy_field_setting:first").find("select"); 296 if (checked) { 297 $select.slideDown(); 298 299 //uncheck post type 300 var $pt_container = jQuery(this).parents("ul:first").find(".populate_with_post_type_field_setting:first"); 301 var $pt_check = $pt_container.find("input.toggle_setting"); 302 var $pt_div = $pt_container.find("div"); 303 if ($pt_check.is(":checked")) { 304 305 SetFieldProperty('populatePostType', ''); 306 $pt_div.slideUp(); 307 $pt_check.removeAttr('checked'); 308 309 } 310 311 } else { 312 SetFieldProperty('populateTaxonomy', ''); 313 $select.slideUp(); 314 } 315 }); 316 317 jQuery(".populate_with_post_type_field_setting .toggle_setting").click(function () { 318 var checked = jQuery(this).is(":checked"); 319 var $div = jQuery(this).parent(".populate_with_post_type_field_setting:first").find("div"); 320 if (checked) { 321 $div.slideDown(); 322 //uncheck taxonomy 323 var $tax_container = jQuery(this).parents("ul:first").find(".populate_with_taxonomy_field_setting:first"); 324 var $tax_check = $tax_container.find("input:checkbox"); 325 var $tax_select = $tax_container.find("select"); 326 if ($tax_check.is(":checked")) { 327 328 SetFieldProperty('populateTaxonomy', ''); 329 $tax_select.slideUp(); 330 $tax_check.removeAttr('checked'); 331 332 } 333 334 } else { 335 SetFieldProperty('populatePostType', ''); 336 $div.slideUp(); 337 } 338 }); 339 340 jQuery(".save_to_taxonomy_field_setting .toggle_setting").click(function () { 341 var checked = jQuery(this).is(":checked"); 342 var $div = jQuery(this).parent(".save_to_taxonomy_field_setting:first").find("div"); 343 if (checked) { 344 $div.slideDown(); 345 } else { 346 SetFieldProperty('saveToTaxonomy', ''); 347 $div.slideUp(); 348 } 349 }); 350 351 </script> 352 <?php 353 } 354 355 } 340 356 341 357 } -
gravity-forms-custom-post-types/trunk/gfcptaddonbase.php
r2063866 r2542615 1 1 <?php 2 2 3 if ( !class_exists('GFCPTAddonBase')) {3 if ( ! class_exists( 'GFCPTAddonBase' ) ) { 4 4 5 5 /* 6 6 * Base class for the GFCPT Addon. All common code is in here and differences per version are overrided 7 7 */ 8 8 9 class GFCPTAddonBase { 9 10 10 protected $_has_tag_inputs = false;11 protected $_included_js;12 protected $_tag_inputs = array();13 protected $_tag_map = array();14 protected $_tag_terms = array();11 protected $_has_tag_inputs = false; 12 protected $_included_js; 13 protected $_tag_inputs = array(); 14 protected $_tag_map = array(); 15 protected $_tag_terms = array(); 15 16 16 17 … … 20 21 public function init() { 21 22 //alter the way forms are rendered by inserting taxomony dropdowns,radios and checkboxes 22 add_filter( 'gform_pre_render' , array(&$this, 'setup_form') );23 add_filter( 'gform_pre_render', array( &$this, 'setup_form' ) ); 23 24 24 25 //alter the way forms are rendered by the admin too! 25 add_filter( 'gform_admin_pre_render' , array(&$this, 'setup_form') );26 add_filter( 'gform_admin_pre_render', array( &$this, 'setup_form' ) ); 26 27 27 28 //alter the form for submission - this is mainly for checkboxes 28 add_filter( 'gform_pre_submission_filter', array(&$this, 'setup_form') );29 add_filter( 'gform_pre_submission_filter', array( &$this, 'setup_form' ) ); 29 30 30 31 add_filter( 'gform_form_post_get_meta', array( $this, 'setup_form_on_export' ) ); 31 32 32 33 //set the post type when saving a post 33 add_filter("gform_post_data", array(&$this, 'set_post_values'), 10, 2); 34 35 if( class_exists( 'gform_update_post' ) ) { 36 remove_filter( 'gform_after_submission', array( 'gform_update_post', 'delete_custom_taxonomy_save' ), 1, 2 ); 34 add_filter( "gform_post_data", array( &$this, 'set_post_values' ), 10, 2 ); 35 36 if ( class_exists( 'gform_update_post' ) ) { 37 remove_filter( 'gform_after_submission', array( 38 'gform_update_post', 39 'delete_custom_taxonomy_save' 40 ), 1, 2 ); 37 41 } 38 42 39 43 //intercept the form save and save any taxonomy links if needed 40 add_action( 'gform_after_create_post', array( $this, 'save_taxonomies' ), 10, 3 );44 add_action( 'gform_after_create_post', array( $this, 'save_taxonomies' ), 10, 3 ); 41 45 42 46 //enqueue scripts to the page 43 add_action( 'gform_enqueue_scripts', array( $this, 'enqueue_form_scripts' ), 10, 2 );47 add_action( 'gform_enqueue_scripts', array( $this, 'enqueue_form_scripts' ), 10, 2 ); 44 48 add_action( 'gform_register_init_scripts', array( $this, 'register_init_scripts' ), 10, 2 ); 45 49 46 add_filter( "gform_preview_styles", array(&$this, 'preview_print_styles'), 10, 2);47 48 add_filter( 'gform_entry_field_value', array( $this, 'display_term_name_on_entry_detail' ), 10, 4 );50 add_filter( "gform_preview_styles", array( &$this, 'preview_print_styles' ), 10, 2 ); 51 52 add_filter( 'gform_entry_field_value', array( $this, 'display_term_name_on_entry_detail' ), 10, 4 ); 49 53 add_filter( 'gform_entries_field_value', array( $this, 'display_term_name_on_entry_list' ), 10, 4 ); 50 add_filter( 'gform_export_field_value', array( $this, 'display_term_name_on_export' ), 10, 4 );51 52 add_filter( 'gform_entry_field_value', array( $this, 'display_post_title_on_entry_detail' ), 10, 4 );54 add_filter( 'gform_export_field_value', array( $this, 'display_term_name_on_export' ), 10, 4 ); 55 56 add_filter( 'gform_entry_field_value', array( $this, 'display_post_title_on_entry_detail' ), 10, 4 ); 53 57 add_filter( 'gform_entries_field_value', array( $this, 'display_post_title_on_entry_list' ), 10, 4 ); 54 add_filter( 'gform_export_field_value', array( $this, 'display_post_title_on_export' ), 10, 4 );58 add_filter( 'gform_export_field_value', array( $this, 'display_post_title_on_export' ), 10, 4 ); 55 59 56 60 … … 62 66 function setup_form( $form ) { 63 67 64 //loop thru all fields 65 foreach($form['fields'] as &$field) { 66 67 //see if the field is using a taxonomy 68 $taxonomy = $this->get_field_taxonomy( $field ); 69 70 if($taxonomy) { 71 $this->setup_taxonomy_field( $field, $taxonomy ); 72 continue; 73 } 74 75 //if its a select then check if we have set a post type 76 if ($field['type'] == 'select') { 77 78 $post_type = $this->get_field_post_type( $field ); 79 80 if ($post_type) { 81 $this->setup_post_type_field( $field, $post_type ); 82 continue; 83 } 84 85 } 86 } 87 88 return $form; 68 if ( empty( $form['fields'] ) ) { 69 return $form; 70 } 71 72 //loop thru all fields 73 foreach ( $form['fields'] as &$field ) { 74 75 //see if the field is using a taxonomy 76 $taxonomy = $this->get_field_taxonomy( $field ); 77 78 if ( $taxonomy ) { 79 $this->setup_taxonomy_field( $field, $taxonomy ); 80 continue; 81 } 82 83 //if its a select then check if we have set a post type 84 if ( $field['type'] == 'select' ) { 85 86 $post_type = $this->get_field_post_type( $field ); 87 88 if ( $post_type ) { 89 $this->setup_post_type_field( $field, $post_type ); 90 continue; 91 } 92 93 } 94 } 95 96 return $form; 89 97 } 90 98 91 99 function setup_form_on_export( $form ) { 92 100 93 if ( in_array( rgpost( 'action' ), array( 'rg_select_export_form', 'gf_process_export' ) ) ) {101 if ( in_array( rgpost( 'action' ), array( 'rg_select_export_form', 'gf_process_export' ) ) ) { 94 102 $form = $this->setup_form( $form ); 95 103 } … … 100 108 function register_init_scripts( $form ) { 101 109 102 $inputs = array();110 $inputs = array(); 103 111 $taxonomies = array(); 104 112 105 foreach ( $form['fields'] as $field ) {106 107 if ( ! $this->has_tax_enhanced_ui( $field ) ) {113 foreach ( $form['fields'] as $field ) { 114 115 if ( ! $this->has_tax_enhanced_ui( $field ) ) { 108 116 continue; 109 117 } 110 118 111 $inputs[] = array( 'input' => sprintf( '#input_%d_%d', $form['id'], $field->id ), 'taxonomy' => $field->saveToTaxonomy ); 112 if( ! array_key_exists( $field->saveToTaxonomy, $taxonomies ) ) { 119 $inputs[] = array( 120 'input' => sprintf( '#input_%d_%d', $form['id'], $field->id ), 121 'taxonomy' => $field->saveToTaxonomy 122 ); 123 124 if ( ! array_key_exists( $field->saveToTaxonomy, $taxonomies ) ) { 113 125 $taxonomies[ $field->saveToTaxonomy ] = get_terms( $field->saveToTaxonomy, 'orderby=name&hide_empty=0&fields=names' ); 114 126 } … … 116 128 } 117 129 118 if ( empty( $inputs ) ) {130 if ( empty( $inputs ) ) { 119 131 return; 120 132 } … … 143 155 function enqueue_form_scripts( $form ) { 144 156 145 if ( ! $this->has_tax_enhanced_ui( $form ) ) {157 if ( ! $this->has_tax_enhanced_ui( $form ) ) { 146 158 return; 147 159 } 148 160 149 wp_register_style( 'gfcpt_jquery_ui_theme', plugins_url( 'css/custom/jquery-ui-1.8.16.custom.css' , __FILE__ ) );161 wp_register_style( 'gfcpt_jquery_ui_theme', plugins_url( 'css/custom/jquery-ui-1.8.16.custom.css', __FILE__ ) ); 150 162 wp_enqueue_style( 'gfcpt_jquery_ui_theme' ); 151 163 152 wp_register_style( 'gfcpt_tagit_css', plugins_url( 'css/jquery.tagit.css' , __FILE__ ) );164 wp_register_style( 'gfcpt_tagit_css', plugins_url( 'css/jquery.tagit.css', __FILE__ ) ); 153 165 wp_enqueue_style( 'gfcpt_tagit_css' ); 154 166 … … 157 169 wp_enqueue_script( 'jquery-ui-autocomplete' ); 158 170 159 wp_register_script( 'gfcpt_tagit_js', plugins_url( 'js/tag-it.js' , __FILE__ ), array( 'jquery-ui-widget' ) );171 wp_register_script( 'gfcpt_tagit_js', plugins_url( 'js/tag-it.js', __FILE__ ), array( 'jquery-ui-widget' ) ); 160 172 wp_enqueue_script( 'gfcpt_tagit_js' ); 161 173 162 wp_register_script( 'gfcpt_tagit_init_js', plugins_url( 'js/tag-it.init.js' , __FILE__ ), array('gfcpt_tagit_js' ), false, true );174 wp_register_script( 'gfcpt_tagit_init_js', plugins_url( 'js/tag-it.init.js', __FILE__ ), array( 'gfcpt_tagit_js' ), false, true ); 163 175 wp_enqueue_script( 'gfcpt_tagit_init_js' ); 164 176 … … 167 179 function has_tax_enhanced_ui( $form_or_field ) { 168 180 169 if ( is_a( $form_or_field, 'GF_Field' ) ) {170 if ( $form_or_field->get_input_type() == 'text' && $form_or_field->saveToTaxonomy && $form_or_field->taxonomyEnhanced ) {181 if ( is_a( $form_or_field, 'GF_Field' ) ) { 182 if ( $form_or_field->get_input_type() == 'text' && $form_or_field->saveToTaxonomy && $form_or_field->taxonomyEnhanced ) { 171 183 return true; 172 184 } 173 185 } else { 174 foreach ( $form_or_field['fields'] as $field ) {175 if ( $this->has_tax_enhanced_ui( $field ) ) {186 foreach ( $form_or_field['fields'] as $field ) { 187 if ( $this->has_tax_enhanced_ui( $field ) ) { 176 188 return true; 177 189 } … … 193 205 194 206 //check if the form saves a post 195 if ( $this->is_form_a_post_form( $form) ) {207 if ( $this->is_form_a_post_form( $form ) ) { 196 208 $target_post_type = $this->get_form_post_type( $form ); 197 209 198 if ( $target_post_type)210 if ( $target_post_type ) { 199 211 $post_data["post_type"] = $target_post_type; 212 } 200 213 201 214 //then check if we have set a parent 202 215 $parent_post_id = $this->get_form_parent_post_id( $form ); 203 216 204 if ($parent_post_id > 0) { 205 $post_data["post_parent"] = $parent_post_id; 206 } 207 } 217 if ( $parent_post_id > 0 ) { 218 $post_data["post_parent"] = $parent_post_id; 219 } 220 } 221 208 222 return $post_data; 209 223 … … 214 228 */ 215 229 function is_form_a_post_form( $form ) { 216 foreach ($form["fields"] as $field) { 217 if(in_array($field["type"], 218 array("post_category","post_title","post_content", 219 "post_excerpt","post_tags","post_custom_fields","post_image"))) 230 foreach ( $form["fields"] as $field ) { 231 if ( in_array( $field["type"], 232 array( 233 "post_category", 234 "post_title", 235 "post_content", 236 "post_excerpt", 237 "post_tags", 238 "post_custom_fields", 239 "post_image" 240 ) ) ) { 220 241 return true; 221 } 242 } 243 } 244 222 245 return false; 223 246 } … … 280 303 */ 281 304 function setup_post_type_field( &$field, $post_type ) { 282 $first_choice = $field['choices'][0]['text'];283 $field['choices'] = $this->load_post_type_choices( $post_type, $first_choice, $field );305 $first_choice = $field['choices'][0]['text']; 306 $field['choices'] = $this->load_post_type_choices( $post_type, $first_choice, $field ); 284 307 $field->enableChoiceValue = true; 285 308 } 286 309 287 function load_post_type_choices( $post_type, $first_choice = '', $field ) {310 function load_post_type_choices( $post_type, $first_choice = '', $field ) { 288 311 $posts = $this->load_posts_hierarchical( $post_type, $field->formId, $field->id ); 289 if ( $first_choice === '' || $first_choice === 'First Choice'){312 if ( $first_choice === '' || $first_choice === 'First Choice' ) { 290 313 // if no default option is specified, dynamically create based on post type name 291 $post_type_obj = get_post_type_object($post_type); 292 $choices[] = array('text' => "-- select a {$post_type_obj->labels->singular_name} --", 'value' => ''); 314 $post_type_obj = get_post_type_object( $post_type ); 315 $choices[] = array( 316 'text' => "-- select a {$post_type_obj->labels->singular_name} --", 317 'value' => '' 318 ); 293 319 } else { 294 $choices[] = array( 'text' => $first_choice, 'value' => '');295 } 296 297 foreach ($posts as $post) {298 $choices[] = array( 'value' => $post->ID, 'text' => $post->post_title);320 $choices[] = array( 'text' => $first_choice, 'value' => '' ); 321 } 322 323 foreach ( $posts as $post ) { 324 $choices[] = array( 'value' => $post->ID, 'text' => $post->post_title ); 299 325 } 300 326 … … 306 332 */ 307 333 function load_posts_hierarchical( $post_type, $form_id, $field_id ) { 308 $args = gf_apply_filters( 'gfcpt_get_posts_args', array( $form_id, $field_id ), array(334 $args = gf_apply_filters( 'gfcpt_get_posts_args', array( $form_id, $field_id ), array( 309 335 'post_type' => $post_type, 310 'numberposts' => - 1,336 'numberposts' => - 1, 311 337 'orderby' => $post_type == 'page' ? 'menu_order' : 'title', 312 338 'order' => $post_type == 'page' ? null : 'ASC', … … 314 340 ) ); 315 341 $posts = get_posts( $args ); 342 316 343 return $this->walk_posts( $posts ); 317 344 } … … 320 347 * Helper function to recursively 'walk' the posts 321 348 */ 322 function walk_posts( $input_array, $parent_id =0, &$out_array=array(), $level=0 ){349 function walk_posts( $input_array, $parent_id = 0, &$out_array = array(), $level = 0 ) { 323 350 foreach ( $input_array as $item ) { 324 351 if ( $item->post_parent == $parent_id ) { 325 $item->post_title = str_repeat('--', $level) . $item->post_title; 326 $out_array[] = $item; 327 $this->walk_posts( $input_array, $item->ID, $out_array, $level+1 ); 328 } 329 } 352 $item->post_title = str_repeat( '--', $level ) . $item->post_title; 353 $out_array[] = $item; 354 $this->walk_posts( $input_array, $item->ID, $out_array, $level + 1 ); 355 } 356 } 357 330 358 return $out_array; 331 359 } … … 336 364 function setup_taxonomy_field( &$field, $taxonomy ) { 337 365 338 $first_choice = rgars( $field, 'choices/0/text' );339 $field['choices'] = $this->load_taxonomy_choices( $taxonomy, $field['type'], $first_choice, $field );366 $first_choice = rgars( $field, 'choices/0/text' ); 367 $field['choices'] = $this->load_taxonomy_choices( $taxonomy, $field['type'], $first_choice, $field ); 340 368 $field->enableChoiceValue = true; 341 369 … … 347 375 $counter = 0; 348 376 //recreate the inputs so they are captured correctly on form submission 349 foreach ( $field['choices'] as $choice ) {377 foreach ( $field['choices'] as $choice ) { 350 378 351 379 //thanks to Peter Schuster for the help on this fix 352 $counter ++;380 $counter ++; 353 381 if ( $counter % 10 == 0 ) { 354 $counter ++;355 } 356 357 $id = $field['id'] . '.' . $counter;382 $counter ++; 383 } 384 385 $id = $field['id'] . '.' . $counter; 358 386 $inputs[] = array( 'label' => $choice['text'], 'id' => $id ); 359 387 } … … 367 395 * Load any taxonomy terms 368 396 */ 369 function load_taxonomy_choices( $taxonomy, $type, $first_choice = '', $field ) {397 function load_taxonomy_choices( $taxonomy, $type, $first_choice = '', $field ) { 370 398 $choices = array(); 371 399 372 if ( in_array( $field->get_input_type(), gf_apply_filters( array( 'gfcpt_hierarchical_display', $field->formId, $field->fieldId ), array( 'select', 'multiselect' ) ) ) ) { 400 if ( in_array( $field->get_input_type(), gf_apply_filters( array( 401 'gfcpt_hierarchical_display', 402 $field->formId, 403 $field->fieldId 404 ), array( 'select', 'multiselect' ) ) ) ) { 373 405 374 406 $terms = $this->load_taxonomy_hierarchical( $taxonomy, $field ); 375 407 376 if ( $field->get_input_type() == 'select' ) {408 if ( $field->get_input_type() == 'select' ) { 377 409 if ( $first_choice !== '' && $first_choice !== 'First Choice' && empty( $field->placeholder ) ) { 378 410 // if no default option is specified, dynamically create based on taxonomy name 379 $taxonomy = get_taxonomy($taxonomy); 380 $choices[] = array('text' => "-- select a {$taxonomy->labels->singular_name} --", 'value' => ''); 411 $taxonomy = get_taxonomy( $taxonomy ); 412 $choices[] = array( 413 'text' => "-- select a {$taxonomy->labels->singular_name} --", 414 'value' => '' 415 ); 381 416 } 382 417 } 383 418 384 419 } else { 385 $terms = get_terms( $taxonomy, 'orderby=name&hide_empty=0');386 } 387 388 if ( ! array_key_exists("errors",$terms) ) {389 foreach($terms as $term) {390 $choices[] = array('value' => $term->term_id, 'text' => $term->name);391 }420 $terms = get_terms( $taxonomy, 'orderby=name&hide_empty=0' ); 421 } 422 423 if ( ! array_key_exists( "errors", $terms ) ) { 424 foreach ( $terms as $term ) { 425 $choices[] = array( 'value' => $term->term_id, 'text' => $term->name ); 426 } 392 427 } 393 428 … … 401 436 402 437 $args = gf_apply_filters( 'gfcpt_taxonomy_args', array( $field->formId, $field->id ), array( 403 'taxonomy' => $taxonomy,404 'orderby' => 'name',405 'hierarchical' => 1,406 'hide_empty' => 0438 'taxonomy' => $taxonomy, 439 'orderby' => 'name', 440 'hierarchical' => 1, 441 'hide_empty' => 0 407 442 ), $field ); 408 443 409 $terms = get_categories( $args );410 411 if ( array_key_exists( "errors",$terms) ) {444 $terms = get_categories( $args ); 445 446 if ( array_key_exists( "errors", $terms ) ) { 412 447 return $terms; 413 448 } else { 414 449 $parent = isset( $args['parent'] ) ? $args['parent'] : 0; 450 415 451 return $this->walk_terms( $terms, $parent ); 416 452 } … … 421 457 * Helper function to recursively 'walk' the taxonomy terms 422 458 */ 423 function walk_terms( $input_array, $parent_id =0, &$out_array=array(), $level=0 ){459 function walk_terms( $input_array, $parent_id = 0, &$out_array = array(), $level = 0 ) { 424 460 foreach ( $input_array as $item ) { 425 461 if ( $item->parent == $parent_id ) { 426 $item->name = str_repeat('--', $level) . $item->name; 427 $out_array[] = $item; 428 $this->walk_terms( $input_array, $item->term_id, $out_array, $level+1 ); 429 } 430 } 462 $item->name = str_repeat( '--', $level ) . $item->name; 463 $out_array[] = $item; 464 $this->walk_terms( $input_array, $item->term_id, $out_array, $level + 1 ); 465 } 466 } 467 431 468 return $out_array; 432 469 } … … 442 479 $this->delete_custom_taxonomies( $entry, $form ); 443 480 444 foreach ( $form['fields'] as &$field ) {481 foreach ( $form['fields'] as &$field ) { 445 482 446 483 $taxonomy = $this->get_field_taxonomy( $field ); 447 484 448 if ( !$taxonomy ) continue; 485 if ( ! $taxonomy ) { 486 continue; 487 } 449 488 450 489 $this->save_taxonomy_field( $field, $entry, $taxonomy ); … … 456 495 * Remove Custom Taxonomies 457 496 * 497 * @return void 458 498 * @author ekaj 459 * @return void460 499 */ 461 500 public function delete_custom_taxonomies( $entry, $form ) { 462 501 // Check if the submission contains a WordPress post 463 if (! empty($entry['post_id']) ) 464 { 465 foreach( $form['fields'] as &$field ) 466 { 467 $taxonomy = false; 468 if ( array_key_exists('populateTaxonomy', $field) ) { 469 $taxonomy = $field['populateTaxonomy']; 470 } 502 if ( ! empty( $entry['post_id'] ) ) { 503 foreach ( $form['fields'] as &$field ) { 504 $taxonomy = rgar( $field, 'populateTaxonomy' ); 471 505 472 506 if ( $taxonomy ) { 473 wp_set_object_terms( $entry['post_id'], NULL, $taxonomy );507 wp_set_object_terms( $entry['post_id'], null, $taxonomy ); 474 508 } 475 509 } … … 484 518 $terms = array(); 485 519 486 switch ( $field->get_input_type() ) {520 switch ( $field->get_input_type() ) { 487 521 case 'multiselect': 488 522 … … 490 524 $terms = json_decode( $value ); 491 525 492 if ( ! is_array( $terms ) ) {526 if ( ! is_array( $terms ) ) { 493 527 $terms = explode( ',', $value ); 494 528 } … … 528 562 $return = $term_id; 529 563 530 if ( $field->populateTaxonomy && ! empty( $term_id ) ) {564 if ( $field->populateTaxonomy && ! empty( $term_id ) ) { 531 565 $term = get_term( (int) $term_id, $field->populateTaxonomy ); 532 if ( ! is_wp_error( $term ) ) {566 if ( ! is_wp_error( $term ) ) { 533 567 $return = $term->name; 534 568 } … … 544 578 function display_term_name_on_entry_list( $value, $form_id, $field_id ) { 545 579 546 if ( is_numeric( $field_id ) ) {580 if ( is_numeric( $field_id ) ) { 547 581 $field = GFFormsModel::get_field( GFAPI::get_form( $form_id ), $field_id ); 548 582 $value = $this->get_term_name( $value, $field ); … … 558 592 function get_post_title( $post_id, $field ) { 559 593 560 if ( $field->populatePostType && ! empty( $post_id ) ) {594 if ( $field->populatePostType && ! empty( $post_id ) ) { 561 595 $post = get_post( $post_id ); 596 562 597 return $post ? $post->post_title : $post_id; 563 598 } … … 572 607 function display_post_title_on_entry_list( $value, $form_id, $field_id ) { 573 608 574 if ( is_numeric( $field_id ) ) {609 if ( is_numeric( $field_id ) ) { 575 610 $field = GFFormsModel::get_field( GFAPI::get_form( $form_id ), $field_id ); 576 611 $value = $this->get_post_title( $value, $field ); -
gravity-forms-custom-post-types/trunk/readme.txt
r2542253 r2542615 81 81 82 82 == Changelog == 83 84 = 3.1.20 = 85 86 * Fixed PHP notice on Gravity Forms Coupons Add-On page. 87 * Fixed PHP warning when populating taxonomies. 88 * Updated formatting of PHP files in plugin to better conform to the WordPress Coding Standards. 83 89 84 90 = 3.1.19 =
Note: See TracChangeset
for help on using the changeset viewer.