Changeset 489080
- Timestamp:
- 01/12/2012 11:17:24 PM (14 years ago)
- Location:
- custom-field-suite/trunk
- Files:
-
- 1 added
- 7 edited
-
cfs.php (modified) (4 diffs)
-
core/actions/admin_head.php (modified) (1 diff)
-
core/actions/save_fields.php (modified) (1 diff)
-
core/admin/meta_box_extras.php (added)
-
core/api.php (modified) (6 diffs)
-
core/upgrade.php (modified) (2 diffs)
-
css/fields.css (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
custom-field-suite/trunk/cfs.php
r485124 r489080 4 4 Plugin URI: http://uproot.us/custom-field-suite/ 5 5 Description: Visually create custom field groups. 6 Version: 1. 2.66 Version: 1.3.0 7 7 Author: Matt Gibbs 8 8 Author URI: http://uproot.us/ … … 12 12 13 13 $cfs = new Cfs(); 14 $cfs->version = '1. 2.6';14 $cfs->version = '1.3.0'; 15 15 16 16 class Cfs … … 49 49 add_action('save_post', array($this, 'save_post')); 50 50 add_action('delete_post', array($this, 'delete_post')); 51 52 // 3rd party hooks 53 add_action('gform_post_submission', array($this, 'gform_handler'), 10, 2); 51 54 52 55 // add translations … … 390 393 include($this->dir . '/core/admin/field_html.php'); 391 394 } 395 396 397 /*-------------------------------------------------------------------------------------- 398 * 399 * gform_handler (gravity forms) 400 * 401 * @author Matt Gibbs 402 * @since 1.3.0 403 * 404 *-------------------------------------------------------------------------------------*/ 405 406 function gform_handler($entry, $form) 407 { 408 global $wpdb; 409 410 // get the form id 411 $form_id = $entry['form_id']; 412 $form_data = array(); 413 414 // get submitted fields 415 foreach ($form['fields'] as $field) 416 { 417 $field_id = $field['id']; 418 419 // handle fields with children 420 if (null !== $field['inputs']) 421 { 422 $values = array(); 423 424 foreach ($field['inputs'] as $sub_field) 425 { 426 $sub_field_value = $entry[$sub_field['id']]; 427 428 if (!empty($sub_field_value)) 429 { 430 $values[] = $sub_field_value; 431 } 432 } 433 $value = implode("\n", $values); 434 } 435 else 436 { 437 $value = $entry[$field_id]; 438 } 439 440 $form_data[$field['label']] = $value; 441 } 442 443 // see if any field groups use this form id 444 $field_groups = array(); 445 $results = $wpdb->get_results("SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = 'cfs_extras'"); 446 foreach ($results as $result) 447 { 448 $meta_value = unserialize($result->meta_value); 449 $meta_value = $meta_value['gforms']; 450 451 if ($form_id == $meta_value['form_id']) 452 { 453 $fields = array(); 454 $all_fields = $wpdb->get_results("SELECT name, label FROM {$wpdb->prefix}cfs_fields WHERE post_id = '{$result->post_id}'"); 455 foreach ($all_fields as $field) 456 { 457 $fields[$field->label] = $field->name; 458 } 459 460 $field_groups[$result->post_id] = array( 461 'post_type' => $meta_value['post_type'], 462 'fields' => $fields, 463 ); 464 } 465 } 466 467 foreach ($field_groups as $post_id => $data) 468 { 469 $field_data = array(); 470 $intersect = array_intersect_key($form_data, $data['fields']); 471 foreach ($intersect as $key => $field_value) 472 { 473 $field_name = $data['fields'][$key]; 474 $field_data[$field_name] = $field_value; 475 } 476 477 $post_data = array( 478 'post_type' => $meta_value['post_type'], 479 ); 480 if (isset($entry['post_id'])) 481 { 482 $post_data['ID'] = $entry['post_id']; 483 } 484 485 // save data 486 $this->save($field_data, $post_data); 487 } 488 } 392 489 } -
custom-field-suite/trunk/core/actions/admin_head.php
r481990 r489080 36 36 add_meta_box('cfs_fields', 'Fields', array($this, 'meta_box'), 'cfs', 'normal', 'high', array('box' => 'fields')); 37 37 add_meta_box('cfs_rules', 'Placement Rules', array($this, 'meta_box'), 'cfs', 'normal', 'high', array('box' => 'rules')); 38 add_meta_box('cfs_extras', 'Extras', array($this, 'meta_box'), 'cfs', 'normal', 'high', array('box' => 'extras')); 38 39 } 39 40 -
custom-field-suite/trunk/core/actions/save_fields.php
r474942 r489080 83 83 84 84 update_post_meta($post_id, 'cfs_rules', $data); 85 86 /*--------------------------------------------------------------------------------------------- 87 Save extras 88 ---------------------------------------------------------------------------------------------*/ 89 90 $cfs_extras = $_POST['cfs']['extras']; 91 update_post_meta($post_id, 'cfs_extras', $cfs_extras); -
custom-field-suite/trunk/core/api.php
r475093 r489080 102 102 { 103 103 $sql = " 104 SELECT v.value, v.weight104 SELECT m.meta_value AS value, v.weight 105 105 FROM {$wpdb->prefix}cfs_values v 106 WHERE v.post_id = '$post_id' AND v.field_id = '$field->id' 106 INNER JOIN {$wpdb->postmeta} m ON m.meta_id = v.meta_id 107 WHERE m.post_id = '$post_id' AND v.field_id = '$field->id' 107 108 ORDER BY v.weight, v.sub_weight"; 108 109 … … 270 271 $options = (object) array_merge($defaults, $options); 271 272 272 // Create the post if $post_data['ID'] is missing 273 $post_id = empty($post_data['ID']) ? wp_insert_post($post_data) : $post_data['ID']; 273 // create post if the ID is missing 274 if (empty($post_data['ID'])) 275 { 276 $post_defaults = array( 277 'post_title' => 'Untitled', 278 'post_content' => '', 279 'post_content_filtered' => '', 280 'post_excerpt' => '', 281 'to_ping' => '', 282 'pinged' => '', 283 ); 284 $post_data = array_merge($post_defaults, $post_data); 285 $post_id = wp_insert_post($post_data); 286 } 287 else 288 { 289 $post_id = $post_data['ID']; 290 291 if (1 < count($post_data)) 292 { 293 $wpdb->update($wpdb->posts, $post_data, array('ID' => $post_id)); 294 } 295 } 274 296 275 297 // If NOT "raw_input", then flatten the data! … … 336 358 337 359 // If saving raw input, delete existing postdata 338 $sql = "DELETE v, m 360 $sql = " 361 DELETE v, m 339 362 FROM {$wpdb->prefix}cfs_values v 340 363 LEFT JOIN {$wpdb->postmeta} m ON m.meta_id = v.meta_id … … 347 370 348 371 // Delete from cfs_values and postmeta 349 $sql = "DELETE v, m 372 $sql = " 373 DELETE v, m 350 374 FROM {$wpdb->prefix}cfs_values v 351 375 LEFT JOIN {$wpdb->postmeta} m ON m.meta_id = v.meta_id … … 387 411 'meta_id' => $meta_id, 388 412 'post_id' => $post_id, 389 'value' => $v,390 413 'weight' => $weight, 391 414 'sub_weight' => $sub_weight, … … 419 442 'meta_id' => $meta_id, 420 443 'post_id' => $post_id, 421 'value' => $v,422 444 'weight' => $weight, 423 445 'sub_weight' => $sub_weight, -
custom-field-suite/trunk/core/upgrade.php
r474942 r489080 10 10 if (version_compare($last_version, '1.0.0', '<')) 11 11 { 12 $sql = "CREATE TABLE {$wpdb->prefix}cfs_fields ( 13 id INT unsigned not null auto_increment primary key, 12 $sql = " 13 CREATE TABLE {$wpdb->prefix}cfs_fields ( 14 id INT unsigned not null auto_increment, 14 15 name TEXT, 15 16 label TEXT, … … 19 20 parent_id INT unsigned default 0, 20 21 weight INT unsigned, 21 options TEXT 22 options TEXT, 23 PRIMARY KEY (id), 24 INDEX post_id_idx (post_id) 22 25 ) DEFAULT CHARSET=utf8"; 23 26 dbDelta($sql); 24 27 25 $sql = "CREATE TABLE {$wpdb->prefix}cfs_values ( 26 id INT unsigned not null auto_increment primary key, 28 $sql = " 29 CREATE TABLE {$wpdb->prefix}cfs_values ( 30 id INT unsigned not null auto_increment, 27 31 field_id INT unsigned, 28 32 meta_id INT unsigned, 29 33 post_id INT unsigned, 30 value TEXT,31 34 weight INT unsigned, 32 sub_weight INT unsigned 35 sub_weight INT unsigned, 36 PRIMARY KEY (id), 37 INDEX field_id_idx (field_id), 38 INDEX post_id_idx (post_id) 33 39 ) DEFAULT CHARSET=utf8"; 34 40 dbDelta($sql); -
custom-field-suite/trunk/css/fields.css
r474942 r489080 152 152 ---------------------------------------------------------------------------------------------*/ 153 153 154 #cfs_rules .inside { 154 #cfs_rules .inside, 155 #cfs_extras .inside { 155 156 margin: 0; 156 157 padding: 0; 157 158 } 158 159 159 #cfs_rules table td { 160 #cfs_rules table td, 161 #cfs_extras table td { 160 162 padding: 10px; 161 163 } 162 164 163 #cfs_rules table td.label { 165 #cfs_rules table td.label, 166 #cfs_extras table td.label { 164 167 width: 24%; 165 168 vertical-align: top; 166 169 } 167 170 168 #cfs_rules table td.label label { 171 #cfs_rules table td.label label, 172 #cfs_extras table td.label label { 169 173 font-weight: bold; 170 174 color: #333; 171 175 } 172 176 173 #cfs_rules table td.label p.description { 177 #cfs_rules table td.label p.description, 178 #cfs_extras table td.label p.description { 174 179 color: #666; 175 180 font-style: normal; … … 178 183 179 184 #cfs_rules table select, 185 #cfs_extras table select, 180 186 #cfs_rules table textarea, 181 #cfs_rules table input[type="text"] { 187 #cfs_extras table textarea, 188 #cfs_rules table input[type="text"], 189 #cfs_extras table input[type="text"] { 182 190 width: 99.95%; 183 191 height: auto; … … 186 194 } 187 195 188 #wpcontent #cfs_rules table select.multiple { 196 #wpcontent #cfs_rules table select.multiple, 197 #wpcontent #cfs_extras table select.multiple { 189 198 height: 100px; 190 199 } -
custom-field-suite/trunk/readme.txt
r485124 r489080 2 2 Contributors: logikal16 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JMVGK3L35X6BU 4 Tags: fields, custom fields, pods, cck, more fields, extra fields 4 Tags: fields, custom fields, pods, cck, more fields, extra fields, gravity forms 5 5 Requires at least: 3.2 6 Tested up to: 3.3 6 Tested up to: 3.3.1 7 7 Stable tag: trunk 8 8 … … 12 12 13 13 Visually create custom fields that can be used on any edit page. 14 15 Now with Gravity Forms integration! 14 16 15 17 = Field Types = … … 41 43 42 44 == Changelog == 45 46 = 1.3.0 = 47 * Gravity Forms integration! 48 * Better error handling for the API save() method 43 49 44 50 = 1.2.6 =
Note: See TracChangeset
for help on using the changeset viewer.