PluginProbe
Advanced Custom Fields (ACF®) / 2.0.3
Advanced Custom Fields (ACF®) v2.0.3
6.8.9 6.8.8 6.8.7 6.8.6 6.8.5 6.8.4 6.8.3 6.8.2 6.8.1 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 All 230 releases
advanced-custom-fields / core / input_save.php

input_save.php in Advanced Custom Fields (ACF®) 2.0.3, at core/input_save.php

78 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*---------------------------------------------------------------------------------------------
3 Fields Meta Box
4 ---------------------------------------------------------------------------------------------*/
5 if(isset($_POST['input_meta_box']) && $_POST['input_meta_box'] == 'true')
6 {
7
8 // If acf was not posted, don't go any further
9 if(!isset($_POST['acf']))
10 {
11 return true;
12 }
13
14
15 // set table name
16 global $wpdb;
17 $table_name = $wpdb->prefix.'acf_values';
18
19 // remove all old values from the database
20 $wpdb->query("DELETE FROM $table_name WHERE post_id = '$post_id'");
21
22 foreach($_POST['acf'] as $field)
23 {
24 if(method_exists($this->fields[$field['field_type']], 'save_input'))
25 {
26 $this->fields[$field['field_type']]->save_input($post_id, $field);
27 }
28 else
29 {
30 //$field = apply_filters('wp_insert_post_data', $field);
31 $field = stripslashes_deep( $field );
32
33
34 // if select is a multiple (multiple select value), you need to save it as an array!
35 if(is_array($field['value']))
36 {
37 $field['value'] = serialize($field['value']);
38 }
39
40
41 // create data object to save
42 $data = array(
43 'post_id' => $post_id,
44 'field_id' => $field['field_id'],
45 'value' => $field['value']
46 );
47
48 // if there is an id, this value already exists, so save it in the same ID spot
49 if($field['row_id'])
50 {
51 $data['id'] = $field['row_id'];
52 }
53
54
55 // insert new data
56 $new_id = $wpdb->insert($table_name, $data);
57 }
58
59
60
61 // save as standard cf
62 if(isset($field['save_as_cf']))
63 {
64 if(is_array($field['value']))
65 {
66 $field['value'] = serialize($field['value']);
67 }
68
69 update_post_meta($post_id, $field['save_as_cf'], $field['value']);
70 }
71
72
73 }
74
75
76 }
77
78 ?>