@@ -1,18 +1,18 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // vars |
4 | -$json = acf_extract_var( $args, 'json'); |
|
4 | +$json = acf_extract_var($args, 'json'); |
|
5 | 5 | |
6 | 6 | ?> |
7 | 7 | <div class="wrap acf-settings-wrap"> |
8 | 8 | |
9 | - <h1><?php _e("Add-ons",'acf'); ?></h1> |
|
9 | + <h1><?php _e("Add-ons", 'acf'); ?></h1> |
|
10 | 10 | |
11 | 11 | <div class="add-ons-list acf-cf"> |
12 | 12 | |
13 | - <?php if( !empty($json) ): ?> |
|
13 | + <?php if ( ! empty($json)): ?> |
|
14 | 14 | |
15 | - <?php foreach( $json as $addon ): |
|
15 | + <?php foreach ($json as $addon): |
|
16 | 16 | |
17 | 17 | $addon = acf_parse_args($addon, array( |
18 | 18 | "title" => "", |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | "description" => "", |
21 | 21 | "thumbnail" => "", |
22 | 22 | "url" => "", |
23 | - "btn" => __("Download & Install",'acf'), |
|
23 | + "btn" => __("Download & Install", 'acf'), |
|
24 | 24 | "btn_color" => "" |
25 | 25 | )); |
26 | 26 | |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | <p><?php echo $addon['description']; ?></p> |
39 | 39 | </div> |
40 | 40 | <div class="footer"> |
41 | - <?php if( apply_filters("acf/is_add_on_active/slug={$addon['slug']}", false ) ): ?> |
|
42 | - <a class="acf-button" disabled="disabled"><?php _e("Installed",'acf'); ?></a> |
|
41 | + <?php if (apply_filters("acf/is_add_on_active/slug={$addon['slug']}", false)): ?> |
|
42 | + <a class="acf-button" disabled="disabled"><?php _e("Installed", 'acf'); ?></a> |
|
43 | 43 | <?php else: ?> |
44 | 44 | <a class="acf-button <?php echo $addon['btn_color']; ?>" target="_blank" href="<?php echo $addon['url']; ?>" ><?php _e($addon['btn']); ?></a> |
45 | 45 | <?php endif; ?> |
46 | 46 | |
47 | - <?php if( !empty($addon['footer']) ): ?> |
|
47 | + <?php if ( ! empty($addon['footer'])): ?> |
|
48 | 48 | <p><?php echo $addon['footer']; ?></p> |
49 | 49 | <?php endif; ?> |
50 | 50 | </div> |
@@ -1,24 +1,24 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // extract args |
4 | -extract( $args ); |
|
4 | +extract($args); |
|
5 | 5 | |
6 | 6 | ?> |
7 | 7 | <div class="wrap about-wrap acf-wrap"> |
8 | 8 | |
9 | - <h1><?php _e("Welcome to Advanced Custom Fields",'acf'); ?> <?php echo $version; ?></h1> |
|
9 | + <h1><?php _e("Welcome to Advanced Custom Fields", 'acf'); ?> <?php echo $version; ?></h1> |
|
10 | 10 | <div class="about-text"><?php printf(__("Thank you for updating! ACF %s is bigger and better than ever before. We hope you like it.", 'acf'), $version); ?></div> |
11 | 11 | <div class="acf-icon logo"> |
12 | 12 | <i class="acf-sprite-logo"></i> |
13 | 13 | </div> |
14 | 14 | |
15 | 15 | <h2 class="nav-tab-wrapper"> |
16 | - <?php foreach( $tabs as $tab_slug => $tab_title ): ?> |
|
17 | - <a class="nav-tab<?php if( $active == $tab_slug ): ?> nav-tab-active<?php endif; ?>" href="<?php echo admin_url("edit.php?post_type=acf-field-group&page=acf-settings-info&tab={$tab_slug}"); ?>"><?php echo $tab_title; ?></a> |
|
16 | + <?php foreach ($tabs as $tab_slug => $tab_title): ?> |
|
17 | + <a class="nav-tab<?php if ($active == $tab_slug): ?> nav-tab-active<?php endif; ?>" href="<?php echo admin_url("edit.php?post_type=acf-field-group&page=acf-settings-info&tab={$tab_slug}"); ?>"><?php echo $tab_title; ?></a> |
|
18 | 18 | <?php endforeach; ?> |
19 | 19 | </h2> |
20 | 20 | |
21 | -<?php if( $active == 'new' ): ?> |
|
21 | +<?php if ($active == 'new'): ?> |
|
22 | 22 | |
23 | 23 | <h2 class="about-headline-callout"><?php _e("A smoother custom field experience", 'acf'); ?></h2> |
24 | 24 | |
@@ -160,27 +160,27 @@ discard block |
||
160 | 160 | |
161 | 161 | |
162 | 162 | |
163 | -<?php elseif( $active == 'changelog' ): ?> |
|
163 | +<?php elseif ($active == 'changelog'): ?> |
|
164 | 164 | |
165 | 165 | <p class="about-description"><?php printf(__("We think you'll love the changes in %s.", 'acf'), $version); ?></p> |
166 | 166 | |
167 | 167 | <?php |
168 | 168 | |
169 | - $items = file_get_contents( acf_get_path('readme.txt') ); |
|
170 | - $items = explode('= ' . $version . ' =', $items); |
|
169 | + $items = file_get_contents(acf_get_path('readme.txt')); |
|
170 | + $items = explode('= '.$version.' =', $items); |
|
171 | 171 | |
172 | - $items = end( $items ); |
|
173 | - $items = current( explode("\n\n", $items) ); |
|
174 | - $items = array_filter( array_map('trim', explode("*", $items)) ); |
|
172 | + $items = end($items); |
|
173 | + $items = current(explode("\n\n", $items)); |
|
174 | + $items = array_filter(array_map('trim', explode("*", $items))); |
|
175 | 175 | |
176 | 176 | ?> |
177 | 177 | <ul class="changelog"> |
178 | - <?php foreach( $items as $item ): |
|
178 | + <?php foreach ($items as $item): |
|
179 | 179 | |
180 | 180 | $item = explode('http', $item); |
181 | 181 | |
182 | 182 | ?> |
183 | - <li><?php echo $item[0]; ?><?php if( isset($item[1]) ): ?><a href="http<?php echo $item[1]; ?>" target="_blank">[...]</a><?php endif; ?></li> |
|
183 | + <li><?php echo $item[0]; ?><?php if (isset($item[1])): ?><a href="http<?php echo $item[1]; ?>" target="_blank">[...]</a><?php endif; ?></li> |
|
184 | 184 | <?php endforeach; ?> |
185 | 185 | </ul> |
186 | 186 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // vars |
4 | -$field_groups = acf_extract_var( $args, 'field_groups'); |
|
4 | +$field_groups = acf_extract_var($args, 'field_groups'); |
|
5 | 5 | |
6 | 6 | |
7 | 7 | // replace |
@@ -32,28 +32,28 @@ discard block |
||
32 | 32 | |
33 | 33 | <textarea class="pre" readonly="true"><?php |
34 | 34 | |
35 | - echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n"; |
|
35 | + echo "if( function_exists('acf_add_local_field_group') ):"."\r\n"."\r\n"; |
|
36 | 36 | |
37 | - foreach( $field_groups as $field_group ) { |
|
37 | + foreach ($field_groups as $field_group) { |
|
38 | 38 | |
39 | 39 | // code |
40 | 40 | $code = var_export($field_group, true); |
41 | 41 | |
42 | 42 | |
43 | 43 | // change double spaces to tabs |
44 | - $code = str_replace( array_keys($str_replace), array_values($str_replace), $code ); |
|
44 | + $code = str_replace(array_keys($str_replace), array_values($str_replace), $code); |
|
45 | 45 | |
46 | 46 | |
47 | 47 | // correctly formats "=> array(" |
48 | - $code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code ); |
|
48 | + $code = preg_replace(array_keys($preg_replace), array_values($preg_replace), $code); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | // esc_textarea |
52 | - $code = esc_textarea( $code ); |
|
52 | + $code = esc_textarea($code); |
|
53 | 53 | |
54 | 54 | |
55 | 55 | // echo |
56 | - echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n"; |
|
56 | + echo "acf_add_local_field_group({$code});"."\r\n"."\r\n"; |
|
57 | 57 | |
58 | 58 | } |
59 | 59 |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | // populate choices |
18 | -if( $field_groups ) { |
|
18 | +if ($field_groups) { |
|
19 | 19 | |
20 | - foreach( $field_groups as $field_group ) { |
|
20 | + foreach ($field_groups as $field_group) { |
|
21 | 21 | |
22 | - $field['choices'][ $field_group['key'] ] = $field_group['title']; |
|
22 | + $field['choices'][$field_group['key']] = $field_group['title']; |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | |
40 | 40 | <form method="post" action=""> |
41 | 41 | <div class="acf-hidden"> |
42 | - <input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce( 'export' ); ?>" /> |
|
42 | + <input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce('export'); ?>" /> |
|
43 | 43 | </div> |
44 | 44 | <table class="form-table"> |
45 | 45 | <tbody> |
46 | - <?php acf_render_field_wrap( $field, 'tr' ); ?> |
|
46 | + <?php acf_render_field_wrap($field, 'tr'); ?> |
|
47 | 47 | <tr> |
48 | 48 | <th></th> |
49 | 49 | <td> |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | <form method="post" action="" enctype="multipart/form-data"> |
70 | 70 | <div class="acf-hidden"> |
71 | - <input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce( 'import' ); ?>" /> |
|
71 | + <input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce('import'); ?>" /> |
|
72 | 72 | </div> |
73 | 73 | <table class="form-table"> |
74 | 74 | <tbody> |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | ?> |
6 | 6 | <div id="acf-upgrade-wrap" class="wrap"> |
7 | 7 | |
8 | - <h1><?php _e("Advanced Custom Fields Database Upgrade",'acf'); ?></h1> |
|
8 | + <h1><?php _e("Advanced Custom Fields Database Upgrade", 'acf'); ?></h1> |
|
9 | 9 | |
10 | - <p><?php _e("The following sites require a DB upgrade. Check the ones you want to update and then click “Upgrade Database”.",'acf'); ?></p> |
|
10 | + <p><?php _e("The following sites require a DB upgrade. Check the ones you want to update and then click “Upgrade Database”.", 'acf'); ?></p> |
|
11 | 11 | |
12 | 12 | <p><input type="submit" name="upgrade" value="Update Sites" class="button" id="upgrade-sites"></p> |
13 | 13 | |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | |
32 | 32 | <tbody id="the-list"> |
33 | 33 | |
34 | - <?php foreach( $sites as $i => $site ): ?> |
|
34 | + <?php foreach ($sites as $i => $site): ?> |
|
35 | 35 | |
36 | - <tr<?php if( $i % 2 == 0 ): ?> class="alternate"<?php endif; ?>> |
|
36 | + <tr<?php if ($i % 2 == 0): ?> class="alternate"<?php endif; ?>> |
|
37 | 37 | <th class="check-column" scope="row"> |
38 | - <?php if( $site['updates'] ): ?> |
|
38 | + <?php if ($site['updates']): ?> |
|
39 | 39 | <input type="checkbox" value="<?php echo $site['blog_id']; ?>" name="checked[]"> |
40 | 40 | <?php endif; ?> |
41 | 41 | </th> |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | <strong><?php echo $site['name']; ?></strong><br /><?php echo $site['url']; ?> |
44 | 44 | </td> |
45 | 45 | <td> |
46 | - <?php if( $site['updates'] ): ?> |
|
46 | + <?php if ($site['updates']): ?> |
|
47 | 47 | <span class="response"><?php printf(__('Site requires database upgrade from %s to %s', 'acf'), $site['acf_version'], $plugin_version); ?></span> |
48 | 48 | <?php else: ?> |
49 | 49 | <?php _e("Site is up to date", 'acf'); ?> |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | <p><input type="submit" name="upgrade" value="Update Sites" class="button" id="upgrade-sites-2"></p> |
61 | 61 | |
62 | - <p class="show-on-complete"><?php _e('Database Upgrade complete', 'acf'); ?>. <a href="<?php echo network_admin_url(); ?>"><?php _e("Return to network dashboard",'acf'); ?></a>.</p> |
|
62 | + <p class="show-on-complete"><?php _e('Database Upgrade complete', 'acf'); ?>. <a href="<?php echo network_admin_url(); ?>"><?php _e("Return to network dashboard", 'acf'); ?></a>.</p> |
|
63 | 63 | |
64 | 64 | <style type="text/css"> |
65 | 65 |
@@ -20,19 +20,19 @@ |
||
20 | 20 | |
21 | 21 | <div class="content"> |
22 | 22 | |
23 | - <h2><?php _e("Database Upgrade Required",'acf'); ?></h2> |
|
23 | + <h2><?php _e("Database Upgrade Required", 'acf'); ?></h2> |
|
24 | 24 | |
25 | - <p><?php printf(__("Thank you for updating to %s v%s!", 'acf'), acf_get_setting('name'), acf_get_setting('version') ); ?><br /><?php _e("Before you start using the new awesome features, please update your database to the newest version.", 'acf'); ?></p> |
|
25 | + <p><?php printf(__("Thank you for updating to %s v%s!", 'acf'), acf_get_setting('name'), acf_get_setting('version')); ?><br /><?php _e("Before you start using the new awesome features, please update your database to the newest version.", 'acf'); ?></p> |
|
26 | 26 | |
27 | 27 | <p><a id="acf-notice-action" href="<?php echo $button_url; ?>" class="acf-button blue"><?php echo $button_text; ?></a></p> |
28 | 28 | |
29 | - <?php if( $confirm ): ?> |
|
29 | + <?php if ($confirm): ?> |
|
30 | 30 | <script type="text/javascript"> |
31 | 31 | (function($) { |
32 | 32 | |
33 | 33 | $("#acf-notice-action").on("click", function(){ |
34 | 34 | |
35 | - var answer = confirm("<?php _e( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf' ); ?>"); |
|
35 | + var answer = confirm("<?php _e('It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'acf'); ?>"); |
|
36 | 36 | return answer; |
37 | 37 | |
38 | 38 | }); |
@@ -5,15 +5,15 @@ |
||
5 | 5 | ?> |
6 | 6 | <div id="acf-upgrade-wrap" class="wrap"> |
7 | 7 | |
8 | - <h1><?php _e("Advanced Custom Fields Database Upgrade",'acf'); ?></h1> |
|
8 | + <h1><?php _e("Advanced Custom Fields Database Upgrade", 'acf'); ?></h1> |
|
9 | 9 | |
10 | -<?php if( !empty($updates) ): ?> |
|
10 | +<?php if ( ! empty($updates)): ?> |
|
11 | 11 | |
12 | 12 | <p><?php _e('Reading upgrade tasks...', 'acf'); ?></p> |
13 | 13 | |
14 | 14 | <p class="show-on-ajax"><i class="acf-loading"></i> <?php printf(__('Upgrading data to version %s', 'acf'), $plugin_version); ?></p> |
15 | 15 | |
16 | - <p class="show-on-complete"><?php _e('Database Upgrade complete', 'acf'); ?>. <a href="<?php echo admin_url('edit.php?post_type=acf-field-group&page=acf-settings-info'); ?>"><?php _e("See what's new",'acf'); ?></a>.</p> |
|
16 | + <p class="show-on-complete"><?php _e('Database Upgrade complete', 'acf'); ?>. <a href="<?php echo admin_url('edit.php?post_type=acf-field-group&page=acf-settings-info'); ?>"><?php _e("See what's new", 'acf'); ?></a>.</p> |
|
17 | 17 | |
18 | 18 | <style type="text/css"> |
19 | 19 |
@@ -13,22 +13,22 @@ discard block |
||
13 | 13 | * @return (boolean) |
14 | 14 | */ |
15 | 15 | |
16 | -function acf_is_field_group_key( $key = '' ) { |
|
16 | +function acf_is_field_group_key($key = '') { |
|
17 | 17 | |
18 | 18 | // bail early if not string |
19 | - if( !is_string($key) ) return false; |
|
19 | + if ( ! is_string($key)) return false; |
|
20 | 20 | |
21 | 21 | |
22 | 22 | // bail early if is numeric (could be numeric string '123') |
23 | - if( is_numeric($key) ) return false; |
|
23 | + if (is_numeric($key)) return false; |
|
24 | 24 | |
25 | 25 | |
26 | 26 | // look for 'field_' prefix |
27 | - if( substr($key, 0, 6) === 'group_' ) return true; |
|
27 | + if (substr($key, 0, 6) === 'group_') return true; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | // allow local field group key to not start with prefix |
31 | - if( acf_is_local_field_group($key) ) return true; |
|
31 | + if (acf_is_local_field_group($key)) return true; |
|
32 | 32 | |
33 | 33 | |
34 | 34 | // return |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | * @return $field_group (array) |
51 | 51 | */ |
52 | 52 | |
53 | -function acf_get_valid_field_group( $field_group = false ) { |
|
53 | +function acf_get_valid_field_group($field_group = false) { |
|
54 | 54 | |
55 | 55 | // parse in defaults |
56 | - $field_group = acf_parse_args( $field_group, array( |
|
56 | + $field_group = acf_parse_args($field_group, array( |
|
57 | 57 | 'ID' => 0, |
58 | 58 | 'key' => '', |
59 | 59 | 'title' => '', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | |
73 | 73 | // translate |
74 | - acf_translate_keys( $field_group, acf_get_setting('l10n_field_group') ); |
|
74 | + acf_translate_keys($field_group, acf_get_setting('l10n_field_group')); |
|
75 | 75 | |
76 | 76 | |
77 | 77 | // filter |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @return $field_groups (array) |
98 | 98 | */ |
99 | 99 | |
100 | -function acf_get_field_groups( $args = false ) { |
|
100 | +function acf_get_field_groups($args = false) { |
|
101 | 101 | |
102 | 102 | // vars |
103 | 103 | $field_groups = array(); |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | |
106 | 106 | // cache |
107 | 107 | $found = false; |
108 | - $cache = wp_cache_get( 'get_field_groups', 'acf', false, $found ); |
|
108 | + $cache = wp_cache_get('get_field_groups', 'acf', false, $found); |
|
109 | 109 | |
110 | - if( $found ) { |
|
110 | + if ($found) { |
|
111 | 111 | |
112 | - return acf_filter_field_groups( $cache, $args ); |
|
112 | + return acf_filter_field_groups($cache, $args); |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | // loop through and load field groups |
130 | - if( $posts ) { |
|
130 | + if ($posts) { |
|
131 | 131 | |
132 | - foreach( $posts as $post ) { |
|
132 | + foreach ($posts as $post) { |
|
133 | 133 | |
134 | 134 | // add to return array |
135 | - $field_groups[] = acf_get_field_group( $post ); |
|
135 | + $field_groups[] = acf_get_field_group($post); |
|
136 | 136 | |
137 | 137 | } |
138 | 138 | |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | |
145 | 145 | |
146 | 146 | // set cache |
147 | - wp_cache_set( 'get_field_groups', $field_groups, 'acf' ); |
|
147 | + wp_cache_set('get_field_groups', $field_groups, 'acf'); |
|
148 | 148 | |
149 | 149 | |
150 | 150 | // return |
151 | - return acf_filter_field_groups( $field_groups, $args ); |
|
151 | + return acf_filter_field_groups($field_groups, $args); |
|
152 | 152 | |
153 | 153 | } |
154 | 154 | |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | * @return $field_groups (array) |
168 | 168 | */ |
169 | 169 | |
170 | -function acf_filter_field_groups( $field_groups, $args = false ) { |
|
170 | +function acf_filter_field_groups($field_groups, $args = false) { |
|
171 | 171 | |
172 | 172 | // bail early if empty sargs |
173 | - if( empty($args) || empty($field_groups) ) { |
|
173 | + if (empty($args) || empty($field_groups)) { |
|
174 | 174 | |
175 | 175 | return $field_groups; |
176 | 176 | |
@@ -178,20 +178,20 @@ discard block |
||
178 | 178 | |
179 | 179 | |
180 | 180 | // vars |
181 | - $keys = array_keys( $field_groups ); |
|
181 | + $keys = array_keys($field_groups); |
|
182 | 182 | |
183 | 183 | |
184 | 184 | // loop through keys |
185 | - foreach( $keys as $key ) { |
|
185 | + foreach ($keys as $key) { |
|
186 | 186 | |
187 | 187 | // get visibility |
188 | - $visibility = acf_get_field_group_visibility( $field_groups[ $key ], $args ); |
|
188 | + $visibility = acf_get_field_group_visibility($field_groups[$key], $args); |
|
189 | 189 | |
190 | 190 | |
191 | 191 | // unset |
192 | - if( !$visibility ) { |
|
192 | + if ( ! $visibility) { |
|
193 | 193 | |
194 | - unset($field_groups[ $key ]); |
|
194 | + unset($field_groups[$key]); |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | |
201 | 201 | // re assign index |
202 | - $field_groups = array_values( $field_groups ); |
|
202 | + $field_groups = array_values($field_groups); |
|
203 | 203 | |
204 | 204 | |
205 | 205 | // return |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @return $field_group (array) |
223 | 223 | */ |
224 | 224 | |
225 | -function acf_get_field_group( $selector = false ) { |
|
225 | +function acf_get_field_group($selector = false) { |
|
226 | 226 | |
227 | 227 | // vars |
228 | 228 | $field_group = false; |
@@ -231,16 +231,16 @@ discard block |
||
231 | 231 | |
232 | 232 | |
233 | 233 | // $post_id or $key |
234 | - if( is_numeric($selector) ) { |
|
234 | + if (is_numeric($selector)) { |
|
235 | 235 | |
236 | 236 | $v = $selector; |
237 | 237 | |
238 | - } elseif( is_string($selector) ) { |
|
238 | + } elseif (is_string($selector)) { |
|
239 | 239 | |
240 | 240 | $k = 'key'; |
241 | 241 | $v = $selector; |
242 | 242 | |
243 | - } elseif( is_object($selector) ) { |
|
243 | + } elseif (is_object($selector)) { |
|
244 | 244 | |
245 | 245 | $v = $selector->ID; |
246 | 246 | |
@@ -257,19 +257,19 @@ discard block |
||
257 | 257 | |
258 | 258 | // get cache |
259 | 259 | $found = false; |
260 | - $cache = wp_cache_get( $cache_key, 'acf', false, $found ); |
|
260 | + $cache = wp_cache_get($cache_key, 'acf', false, $found); |
|
261 | 261 | |
262 | - if( $found ) return $cache; |
|
262 | + if ($found) return $cache; |
|
263 | 263 | |
264 | 264 | |
265 | 265 | // get field group from ID or key |
266 | - if( $k == 'ID' ) { |
|
266 | + if ($k == 'ID') { |
|
267 | 267 | |
268 | - $field_group = _acf_get_field_group_by_id( $v ); |
|
268 | + $field_group = _acf_get_field_group_by_id($v); |
|
269 | 269 | |
270 | 270 | } else { |
271 | 271 | |
272 | - $field_group = _acf_get_field_group_by_key( $v ); |
|
272 | + $field_group = _acf_get_field_group_by_key($v); |
|
273 | 273 | |
274 | 274 | } |
275 | 275 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | |
280 | 280 | |
281 | 281 | // set cache |
282 | - wp_cache_set( $cache_key, $field_group, 'acf' ); |
|
282 | + wp_cache_set($cache_key, $field_group, 'acf'); |
|
283 | 283 | |
284 | 284 | |
285 | 285 | // return |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | * @return $field_group (array) |
301 | 301 | */ |
302 | 302 | |
303 | -function _acf_get_field_group_by_id( $post_id = 0 ) { |
|
303 | +function _acf_get_field_group_by_id($post_id = 0) { |
|
304 | 304 | |
305 | 305 | // get post |
306 | - $post = get_post( $post_id ); |
|
306 | + $post = get_post($post_id); |
|
307 | 307 | |
308 | 308 | |
309 | 309 | // bail early if no post, or is not a field group |
310 | - if( empty($post) || $post->post_type != 'acf-field-group' ) { |
|
310 | + if (empty($post) || $post->post_type != 'acf-field-group') { |
|
311 | 311 | |
312 | 312 | return false; |
313 | 313 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | |
316 | 316 | |
317 | 317 | // modify post_status (new field-group starts as auto-draft) |
318 | - if( $post->post_status == 'auto-draft' ) { |
|
318 | + if ($post->post_status == 'auto-draft') { |
|
319 | 319 | |
320 | 320 | $post->post_status = 'publish'; |
321 | 321 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | |
325 | 325 | // unserialize data |
326 | - $field_group = maybe_unserialize( $post->post_content ); |
|
326 | + $field_group = maybe_unserialize($post->post_content); |
|
327 | 327 | |
328 | 328 | |
329 | 329 | // update attributes |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | |
336 | 336 | |
337 | 337 | // is JSON |
338 | - if( acf_is_local_field_group( $field_group['key'] ) ) { |
|
338 | + if (acf_is_local_field_group($field_group['key'])) { |
|
339 | 339 | |
340 | 340 | // override |
341 | - $field_group = acf_get_local_field_group( $field_group['key'] ); |
|
341 | + $field_group = acf_get_local_field_group($field_group['key']); |
|
342 | 342 | |
343 | 343 | |
344 | 344 | // restore ID |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | |
349 | 349 | |
350 | 350 | // validate |
351 | - $field_group = acf_get_valid_field_group( $field_group ); |
|
351 | + $field_group = acf_get_valid_field_group($field_group); |
|
352 | 352 | |
353 | 353 | |
354 | 354 | // return |
@@ -370,19 +370,19 @@ discard block |
||
370 | 370 | * @return $field_group (array) |
371 | 371 | */ |
372 | 372 | |
373 | -function _acf_get_field_group_by_key( $key = '' ) { |
|
373 | +function _acf_get_field_group_by_key($key = '') { |
|
374 | 374 | |
375 | 375 | // vars |
376 | 376 | $field_group = false; |
377 | 377 | |
378 | 378 | |
379 | 379 | // try JSON before DB to save query time |
380 | - if( acf_is_local_field_group( $key ) ) { |
|
380 | + if (acf_is_local_field_group($key)) { |
|
381 | 381 | |
382 | - $field_group = acf_get_local_field_group( $key ); |
|
382 | + $field_group = acf_get_local_field_group($key); |
|
383 | 383 | |
384 | 384 | // validate |
385 | - $field_group = acf_get_valid_field_group( $field_group ); |
|
385 | + $field_group = acf_get_valid_field_group($field_group); |
|
386 | 386 | |
387 | 387 | // return |
388 | 388 | return $field_group; |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | |
404 | 404 | |
405 | 405 | // load posts |
406 | - $posts = get_posts( $args ); |
|
406 | + $posts = get_posts($args); |
|
407 | 407 | |
408 | 408 | |
409 | 409 | // validate |
410 | - if( empty($posts[0]) ) { |
|
410 | + if (empty($posts[0])) { |
|
411 | 411 | |
412 | 412 | return $field_group; |
413 | 413 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | |
416 | 416 | |
417 | 417 | // load from ID |
418 | - $field_group = _acf_get_field_group_by_id( $posts[0]->ID ); |
|
418 | + $field_group = _acf_get_field_group_by_id($posts[0]->ID); |
|
419 | 419 | |
420 | 420 | |
421 | 421 | // return |
@@ -438,22 +438,22 @@ discard block |
||
438 | 438 | * @return $field_group (array) |
439 | 439 | */ |
440 | 440 | |
441 | -function acf_update_field_group( $field_group = array() ) { |
|
441 | +function acf_update_field_group($field_group = array()) { |
|
442 | 442 | |
443 | 443 | // validate |
444 | - $field_group = acf_get_valid_field_group( $field_group ); |
|
444 | + $field_group = acf_get_valid_field_group($field_group); |
|
445 | 445 | |
446 | 446 | |
447 | 447 | // may have been posted. Remove slashes |
448 | - $field_group = wp_unslash( $field_group ); |
|
448 | + $field_group = wp_unslash($field_group); |
|
449 | 449 | |
450 | 450 | |
451 | 451 | // locations may contain 'uniquid' array keys |
452 | - $field_group['location'] = array_values( $field_group['location'] ); |
|
452 | + $field_group['location'] = array_values($field_group['location']); |
|
453 | 453 | |
454 | - foreach( $field_group['location'] as $k => $v ) { |
|
454 | + foreach ($field_group['location'] as $k => $v) { |
|
455 | 455 | |
456 | - $field_group['location'][ $k ] = array_values( $v ); |
|
456 | + $field_group['location'][$k] = array_values($v); |
|
457 | 457 | |
458 | 458 | } |
459 | 459 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | |
475 | 475 | |
476 | 476 | // vars |
477 | - $data = maybe_serialize( $data ); |
|
477 | + $data = maybe_serialize($data); |
|
478 | 478 | $post_status = $extract['active'] ? 'publish' : 'acf-disabled'; |
479 | 479 | |
480 | 480 | |
@@ -492,17 +492,17 @@ discard block |
||
492 | 492 | |
493 | 493 | |
494 | 494 | // allow field groups to contain the same name |
495 | - add_filter( 'wp_unique_post_slug', 'acf_update_field_group_wp_unique_post_slug', 100, 6 ); |
|
495 | + add_filter('wp_unique_post_slug', 'acf_update_field_group_wp_unique_post_slug', 100, 6); |
|
496 | 496 | |
497 | 497 | |
498 | 498 | // update the field group and update the ID |
499 | - if( $field_group['ID'] ) { |
|
499 | + if ($field_group['ID']) { |
|
500 | 500 | |
501 | - wp_update_post( $save ); |
|
501 | + wp_update_post($save); |
|
502 | 502 | |
503 | 503 | } else { |
504 | 504 | |
505 | - $field_group['ID'] = wp_insert_post( $save ); |
|
505 | + $field_group['ID'] = wp_insert_post($save); |
|
506 | 506 | |
507 | 507 | } |
508 | 508 | |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | |
523 | 523 | } |
524 | 524 | |
525 | -function acf_update_field_group_wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) { |
|
525 | +function acf_update_field_group_wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug) { |
|
526 | 526 | |
527 | - if( $post_type == 'acf-field-group' ) { |
|
527 | + if ($post_type == 'acf-field-group') { |
|
528 | 528 | |
529 | 529 | $slug = $original_slug; |
530 | 530 | |
@@ -548,18 +548,18 @@ discard block |
||
548 | 548 | * @return $field_group (array) |
549 | 549 | */ |
550 | 550 | |
551 | -function acf_duplicate_field_group( $selector = 0, $new_post_id = 0 ) { |
|
551 | +function acf_duplicate_field_group($selector = 0, $new_post_id = 0) { |
|
552 | 552 | |
553 | 553 | // disable JSON to avoid conflicts between DB and JSON |
554 | 554 | acf_disable_local(); |
555 | 555 | |
556 | 556 | |
557 | 557 | // load the origional field gorup |
558 | - $field_group = acf_get_field_group( $selector ); |
|
558 | + $field_group = acf_get_field_group($selector); |
|
559 | 559 | |
560 | 560 | |
561 | 561 | // bail early if field group did not load correctly |
562 | - if( empty($field_group) ) { |
|
562 | + if (empty($field_group)) { |
|
563 | 563 | |
564 | 564 | return false; |
565 | 565 | |
@@ -576,23 +576,23 @@ discard block |
||
576 | 576 | |
577 | 577 | |
578 | 578 | // add (copy) |
579 | - if( !$new_post_id ) { |
|
579 | + if ( ! $new_post_id) { |
|
580 | 580 | |
581 | - $field_group['title'] .= ' (' . __("copy", 'acf') . ')'; |
|
581 | + $field_group['title'] .= ' ('.__("copy", 'acf').')'; |
|
582 | 582 | |
583 | 583 | } |
584 | 584 | |
585 | 585 | |
586 | 586 | // save |
587 | - $field_group = acf_update_field_group( $field_group ); |
|
587 | + $field_group = acf_update_field_group($field_group); |
|
588 | 588 | |
589 | 589 | |
590 | 590 | // get fields |
591 | - $fields = acf_get_fields( $orig_field_group ); |
|
591 | + $fields = acf_get_fields($orig_field_group); |
|
592 | 592 | |
593 | 593 | |
594 | 594 | // duplicate fields |
595 | - acf_duplicate_fields( $fields, $field_group['ID'] ); |
|
595 | + acf_duplicate_fields($fields, $field_group['ID']); |
|
596 | 596 | |
597 | 597 | |
598 | 598 | // action for 3rd party customization |
@@ -618,16 +618,16 @@ discard block |
||
618 | 618 | * @return (int) |
619 | 619 | */ |
620 | 620 | |
621 | -function acf_get_field_count( $field_group ) { |
|
621 | +function acf_get_field_count($field_group) { |
|
622 | 622 | |
623 | 623 | // vars |
624 | 624 | $count = 0; |
625 | 625 | |
626 | 626 | |
627 | 627 | // local |
628 | - if( !$field_group['ID'] ) { |
|
628 | + if ( ! $field_group['ID']) { |
|
629 | 629 | |
630 | - $count = acf_count_local_fields( $field_group['key'] ); |
|
630 | + $count = acf_count_local_fields($field_group['key']); |
|
631 | 631 | |
632 | 632 | // DB |
633 | 633 | } else { |
@@ -672,29 +672,29 @@ discard block |
||
672 | 672 | * @return (boolean) |
673 | 673 | */ |
674 | 674 | |
675 | -function acf_delete_field_group( $selector = 0 ) { |
|
675 | +function acf_delete_field_group($selector = 0) { |
|
676 | 676 | |
677 | 677 | // disable JSON to avoid conflicts between DB and JSON |
678 | 678 | acf_disable_local(); |
679 | 679 | |
680 | 680 | |
681 | 681 | // load the origional field gorup |
682 | - $field_group = acf_get_field_group( $selector ); |
|
682 | + $field_group = acf_get_field_group($selector); |
|
683 | 683 | |
684 | 684 | |
685 | 685 | // bail early if field group did not load correctly |
686 | - if( empty($field_group) ) return false; |
|
686 | + if (empty($field_group)) return false; |
|
687 | 687 | |
688 | 688 | |
689 | 689 | // get fields |
690 | 690 | $fields = acf_get_fields($field_group); |
691 | 691 | |
692 | 692 | |
693 | - if( !empty($fields) ) { |
|
693 | + if ( ! empty($fields)) { |
|
694 | 694 | |
695 | - foreach( $fields as $field ) { |
|
695 | + foreach ($fields as $field) { |
|
696 | 696 | |
697 | - acf_delete_field( $field['ID'] ); |
|
697 | + acf_delete_field($field['ID']); |
|
698 | 698 | |
699 | 699 | } |
700 | 700 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | |
703 | 703 | |
704 | 704 | // delete |
705 | - wp_delete_post( $field_group['ID'] ); |
|
705 | + wp_delete_post($field_group['ID']); |
|
706 | 706 | |
707 | 707 | |
708 | 708 | // action for 3rd party customization |
@@ -727,29 +727,29 @@ discard block |
||
727 | 727 | * @return (boolean) |
728 | 728 | */ |
729 | 729 | |
730 | -function acf_trash_field_group( $selector = 0 ) { |
|
730 | +function acf_trash_field_group($selector = 0) { |
|
731 | 731 | |
732 | 732 | // disable JSON to avoid conflicts between DB and JSON |
733 | 733 | acf_disable_local(); |
734 | 734 | |
735 | 735 | |
736 | 736 | // load the origional field gorup |
737 | - $field_group = acf_get_field_group( $selector ); |
|
737 | + $field_group = acf_get_field_group($selector); |
|
738 | 738 | |
739 | 739 | |
740 | 740 | // bail early if field group did not load correctly |
741 | - if( empty($field_group) ) return false; |
|
741 | + if (empty($field_group)) return false; |
|
742 | 742 | |
743 | 743 | |
744 | 744 | // get fields |
745 | 745 | $fields = acf_get_fields($field_group); |
746 | 746 | |
747 | 747 | |
748 | - if( !empty($fields) ) { |
|
748 | + if ( ! empty($fields)) { |
|
749 | 749 | |
750 | - foreach( $fields as $field ) { |
|
750 | + foreach ($fields as $field) { |
|
751 | 751 | |
752 | - acf_trash_field( $field['ID'] ); |
|
752 | + acf_trash_field($field['ID']); |
|
753 | 753 | |
754 | 754 | } |
755 | 755 | |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | |
758 | 758 | |
759 | 759 | // delete |
760 | - wp_trash_post( $field_group['ID'] ); |
|
760 | + wp_trash_post($field_group['ID']); |
|
761 | 761 | |
762 | 762 | |
763 | 763 | // action for 3rd party customization |
@@ -782,29 +782,29 @@ discard block |
||
782 | 782 | * @return (boolean) |
783 | 783 | */ |
784 | 784 | |
785 | -function acf_untrash_field_group( $selector = 0 ) { |
|
785 | +function acf_untrash_field_group($selector = 0) { |
|
786 | 786 | |
787 | 787 | // disable JSON to avoid conflicts between DB and JSON |
788 | 788 | acf_disable_local(); |
789 | 789 | |
790 | 790 | |
791 | 791 | // load the origional field gorup |
792 | - $field_group = acf_get_field_group( $selector ); |
|
792 | + $field_group = acf_get_field_group($selector); |
|
793 | 793 | |
794 | 794 | |
795 | 795 | // bail early if field group did not load correctly |
796 | - if( empty($field_group) ) return false; |
|
796 | + if (empty($field_group)) return false; |
|
797 | 797 | |
798 | 798 | |
799 | 799 | // get fields |
800 | 800 | $fields = acf_get_fields($field_group); |
801 | 801 | |
802 | 802 | |
803 | - if( !empty($fields) ) { |
|
803 | + if ( ! empty($fields)) { |
|
804 | 804 | |
805 | - foreach( $fields as $field ) { |
|
805 | + foreach ($fields as $field) { |
|
806 | 806 | |
807 | - acf_untrash_field( $field['ID'] ); |
|
807 | + acf_untrash_field($field['ID']); |
|
808 | 808 | |
809 | 809 | } |
810 | 810 | |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | |
813 | 813 | |
814 | 814 | // delete |
815 | - wp_untrash_post( $field_group['ID'] ); |
|
815 | + wp_untrash_post($field_group['ID']); |
|
816 | 816 | |
817 | 817 | |
818 | 818 | // action for 3rd party customization |
@@ -838,91 +838,91 @@ discard block |
||
838 | 838 | * @return n/a |
839 | 839 | */ |
840 | 840 | |
841 | -function acf_get_field_group_style( $field_group ) { |
|
841 | +function acf_get_field_group_style($field_group) { |
|
842 | 842 | |
843 | 843 | // vars |
844 | 844 | $e = ''; |
845 | 845 | |
846 | 846 | |
847 | 847 | // validate |
848 | - if( !is_array($field_group['hide_on_screen']) ) |
|
848 | + if ( ! is_array($field_group['hide_on_screen'])) |
|
849 | 849 | { |
850 | 850 | return $e; |
851 | 851 | } |
852 | 852 | |
853 | 853 | |
854 | 854 | // add style to html |
855 | - if( in_array('permalink',$field_group['hide_on_screen']) ) |
|
855 | + if (in_array('permalink', $field_group['hide_on_screen'])) |
|
856 | 856 | { |
857 | 857 | $e .= '#edit-slug-box {display: none;} '; |
858 | 858 | } |
859 | 859 | |
860 | - if( in_array('the_content',$field_group['hide_on_screen']) ) |
|
860 | + if (in_array('the_content', $field_group['hide_on_screen'])) |
|
861 | 861 | { |
862 | 862 | $e .= '#postdivrich {display: none;} '; |
863 | 863 | } |
864 | 864 | |
865 | - if( in_array('excerpt',$field_group['hide_on_screen']) ) |
|
865 | + if (in_array('excerpt', $field_group['hide_on_screen'])) |
|
866 | 866 | { |
867 | 867 | $e .= '#postexcerpt, #screen-meta label[for=postexcerpt-hide] {display: none;} '; |
868 | 868 | } |
869 | 869 | |
870 | - if( in_array('custom_fields',$field_group['hide_on_screen']) ) |
|
870 | + if (in_array('custom_fields', $field_group['hide_on_screen'])) |
|
871 | 871 | { |
872 | 872 | $e .= '#postcustom, #screen-meta label[for=postcustom-hide] { display: none; } '; |
873 | 873 | } |
874 | 874 | |
875 | - if( in_array('discussion',$field_group['hide_on_screen']) ) |
|
875 | + if (in_array('discussion', $field_group['hide_on_screen'])) |
|
876 | 876 | { |
877 | 877 | $e .= '#commentstatusdiv, #screen-meta label[for=commentstatusdiv-hide] {display: none;} '; |
878 | 878 | } |
879 | 879 | |
880 | - if( in_array('comments',$field_group['hide_on_screen']) ) |
|
880 | + if (in_array('comments', $field_group['hide_on_screen'])) |
|
881 | 881 | { |
882 | 882 | $e .= '#commentsdiv, #screen-meta label[for=commentsdiv-hide] {display: none;} '; |
883 | 883 | } |
884 | 884 | |
885 | - if( in_array('slug',$field_group['hide_on_screen']) ) |
|
885 | + if (in_array('slug', $field_group['hide_on_screen'])) |
|
886 | 886 | { |
887 | 887 | $e .= '#slugdiv, #screen-meta label[for=slugdiv-hide] {display: none;} '; |
888 | 888 | } |
889 | 889 | |
890 | - if( in_array('author',$field_group['hide_on_screen']) ) |
|
890 | + if (in_array('author', $field_group['hide_on_screen'])) |
|
891 | 891 | { |
892 | 892 | $e .= '#authordiv, #screen-meta label[for=authordiv-hide] {display: none;} '; |
893 | 893 | } |
894 | 894 | |
895 | - if( in_array('format',$field_group['hide_on_screen']) ) |
|
895 | + if (in_array('format', $field_group['hide_on_screen'])) |
|
896 | 896 | { |
897 | 897 | $e .= '#formatdiv, #screen-meta label[for=formatdiv-hide] {display: none;} '; |
898 | 898 | } |
899 | 899 | |
900 | - if( in_array('page_attributes',$field_group['hide_on_screen']) ) |
|
900 | + if (in_array('page_attributes', $field_group['hide_on_screen'])) |
|
901 | 901 | { |
902 | 902 | $e .= '#pageparentdiv {display: none;} '; |
903 | 903 | } |
904 | 904 | |
905 | - if( in_array('featured_image',$field_group['hide_on_screen']) ) |
|
905 | + if (in_array('featured_image', $field_group['hide_on_screen'])) |
|
906 | 906 | { |
907 | 907 | $e .= '#postimagediv, #screen-meta label[for=postimagediv-hide] {display: none;} '; |
908 | 908 | } |
909 | 909 | |
910 | - if( in_array('revisions',$field_group['hide_on_screen']) ) |
|
910 | + if (in_array('revisions', $field_group['hide_on_screen'])) |
|
911 | 911 | { |
912 | 912 | $e .= '#revisionsdiv, #screen-meta label[for=revisionsdiv-hide] {display: none;} '; |
913 | 913 | } |
914 | 914 | |
915 | - if( in_array('categories',$field_group['hide_on_screen']) ) |
|
915 | + if (in_array('categories', $field_group['hide_on_screen'])) |
|
916 | 916 | { |
917 | 917 | $e .= '#categorydiv, #screen-meta label[for=categorydiv-hide] {display: none;} '; |
918 | 918 | } |
919 | 919 | |
920 | - if( in_array('tags',$field_group['hide_on_screen']) ) |
|
920 | + if (in_array('tags', $field_group['hide_on_screen'])) |
|
921 | 921 | { |
922 | 922 | $e .= '#tagsdiv-post_tag, #screen-meta label[for=tagsdiv-post_tag-hide] {display: none;} '; |
923 | 923 | } |
924 | 924 | |
925 | - if( in_array('send-trackbacks',$field_group['hide_on_screen']) ) |
|
925 | + if (in_array('send-trackbacks', $field_group['hide_on_screen'])) |
|
926 | 926 | { |
927 | 927 | $e .= '#trackbacksdiv, #screen-meta label[for=trackbacksdiv-hide] {display: none;} '; |
928 | 928 | } |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | * @return $id (int) |
947 | 947 | */ |
948 | 948 | |
949 | -function acf_import_field_group( $field_group ) { |
|
949 | +function acf_import_field_group($field_group) { |
|
950 | 950 | |
951 | 951 | // vars |
952 | 952 | $ref = array(); |
@@ -958,24 +958,24 @@ discard block |
||
958 | 958 | |
959 | 959 | |
960 | 960 | // format fields |
961 | - $fields = acf_prepare_fields_for_import( $fields ); |
|
961 | + $fields = acf_prepare_fields_for_import($fields); |
|
962 | 962 | |
963 | 963 | |
964 | 964 | // remove old fields |
965 | - if( $field_group['ID'] ) { |
|
965 | + if ($field_group['ID']) { |
|
966 | 966 | |
967 | 967 | // disable local - important as to avoid 'acf_get_fields_by_id' returning fields with ID = 0 |
968 | 968 | acf_disable_local(); |
969 | 969 | |
970 | 970 | |
971 | 971 | // load fields |
972 | - $db_fields = acf_get_fields_by_id( $field_group['ID'] ); |
|
973 | - $db_fields = acf_prepare_fields_for_import( $db_fields ); |
|
972 | + $db_fields = acf_get_fields_by_id($field_group['ID']); |
|
973 | + $db_fields = acf_prepare_fields_for_import($db_fields); |
|
974 | 974 | |
975 | 975 | |
976 | 976 | // get field keys |
977 | 977 | $keys = array(); |
978 | - foreach( $fields as $field ) { |
|
978 | + foreach ($fields as $field) { |
|
979 | 979 | |
980 | 980 | $keys[] = $field['key']; |
981 | 981 | |
@@ -983,15 +983,15 @@ discard block |
||
983 | 983 | |
984 | 984 | |
985 | 985 | // loop over db fields |
986 | - foreach( $db_fields as $field ) { |
|
986 | + foreach ($db_fields as $field) { |
|
987 | 987 | |
988 | 988 | // add to ref |
989 | - $ref[ $field['key'] ] = $field['ID']; |
|
989 | + $ref[$field['key']] = $field['ID']; |
|
990 | 990 | |
991 | 991 | |
992 | - if( !in_array($field['key'], $keys) ) { |
|
992 | + if ( ! in_array($field['key'], $keys)) { |
|
993 | 993 | |
994 | - acf_delete_field( $field['ID'] ); |
|
994 | + acf_delete_field($field['ID']); |
|
995 | 995 | |
996 | 996 | } |
997 | 997 | |
@@ -1005,57 +1005,57 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | |
1007 | 1007 | // save field group |
1008 | - $field_group = acf_update_field_group( $field_group ); |
|
1008 | + $field_group = acf_update_field_group($field_group); |
|
1009 | 1009 | |
1010 | 1010 | |
1011 | 1011 | // add to ref |
1012 | - $ref[ $field_group['key'] ] = $field_group['ID']; |
|
1012 | + $ref[$field_group['key']] = $field_group['ID']; |
|
1013 | 1013 | |
1014 | 1014 | |
1015 | 1015 | // add to order |
1016 | - $order[ $field_group['ID'] ] = 0; |
|
1016 | + $order[$field_group['ID']] = 0; |
|
1017 | 1017 | |
1018 | 1018 | |
1019 | 1019 | // add fields |
1020 | - foreach( $fields as $field ) { |
|
1020 | + foreach ($fields as $field) { |
|
1021 | 1021 | |
1022 | 1022 | // add ID |
1023 | - if( !$field['ID'] && isset($ref[ $field['key'] ]) ) { |
|
1023 | + if ( ! $field['ID'] && isset($ref[$field['key']])) { |
|
1024 | 1024 | |
1025 | - $field['ID'] = $ref[ $field['key'] ]; |
|
1025 | + $field['ID'] = $ref[$field['key']]; |
|
1026 | 1026 | |
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | |
1030 | 1030 | // add parent |
1031 | - if( empty($field['parent']) ) { |
|
1031 | + if (empty($field['parent'])) { |
|
1032 | 1032 | |
1033 | 1033 | $field['parent'] = $field_group['ID']; |
1034 | 1034 | |
1035 | - } elseif( isset($ref[ $field['parent'] ]) ) { |
|
1035 | + } elseif (isset($ref[$field['parent']])) { |
|
1036 | 1036 | |
1037 | - $field['parent'] = $ref[ $field['parent'] ]; |
|
1037 | + $field['parent'] = $ref[$field['parent']]; |
|
1038 | 1038 | |
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | // add field menu_order |
1043 | - if( !isset($order[ $field['parent'] ]) ) { |
|
1043 | + if ( ! isset($order[$field['parent']])) { |
|
1044 | 1044 | |
1045 | - $order[ $field['parent'] ] = 0; |
|
1045 | + $order[$field['parent']] = 0; |
|
1046 | 1046 | |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - $field['menu_order'] = $order[ $field['parent'] ]; |
|
1050 | - $order[ $field['parent'] ]++; |
|
1049 | + $field['menu_order'] = $order[$field['parent']]; |
|
1050 | + $order[$field['parent']]++; |
|
1051 | 1051 | |
1052 | 1052 | |
1053 | 1053 | // save field |
1054 | - $field = acf_update_field( $field ); |
|
1054 | + $field = acf_update_field($field); |
|
1055 | 1055 | |
1056 | 1056 | |
1057 | 1057 | // add to ref |
1058 | - $ref[ $field['key'] ] = $field['ID']; |
|
1058 | + $ref[$field['key']] = $field['ID']; |
|
1059 | 1059 | |
1060 | 1060 | } |
1061 | 1061 | |
@@ -1079,14 +1079,14 @@ discard block |
||
1079 | 1079 | * @return $post_id (int) |
1080 | 1080 | */ |
1081 | 1081 | |
1082 | -function acf_prepare_field_group_for_export( $field_group ) { |
|
1082 | +function acf_prepare_field_group_for_export($field_group) { |
|
1083 | 1083 | |
1084 | 1084 | // extract field group ID |
1085 | - $id = acf_extract_var( $field_group, 'ID' ); |
|
1085 | + $id = acf_extract_var($field_group, 'ID'); |
|
1086 | 1086 | |
1087 | 1087 | |
1088 | 1088 | // prepare fields |
1089 | - $field_group['fields'] = acf_prepare_fields_for_export( $field_group['fields'] ); |
|
1089 | + $field_group['fields'] = acf_prepare_fields_for_export($field_group['fields']); |
|
1090 | 1090 | |
1091 | 1091 | |
1092 | 1092 | // filter for 3rd party customization |
@@ -33,18 +33,18 @@ discard block |
||
33 | 33 | * @return (array) |
34 | 34 | */ |
35 | 35 | |
36 | -function acf_get_field_type_label( $field_type ) { |
|
36 | +function acf_get_field_type_label($field_type) { |
|
37 | 37 | |
38 | 38 | // vars |
39 | 39 | $field_types = acf_get_field_types(); |
40 | 40 | |
41 | 41 | |
42 | 42 | // loop through categories |
43 | - foreach( $field_types as $category ) { |
|
43 | + foreach ($field_types as $category) { |
|
44 | 44 | |
45 | - if( isset( $category[ $field_type ] ) ) { |
|
45 | + if (isset($category[$field_type])) { |
|
46 | 46 | |
47 | - return $category[ $field_type ]; |
|
47 | + return $category[$field_type]; |
|
48 | 48 | |
49 | 49 | } |
50 | 50 | |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @return (boolean) |
71 | 71 | */ |
72 | 72 | |
73 | -function acf_field_type_exists( $field_type ) { |
|
73 | +function acf_field_type_exists($field_type) { |
|
74 | 74 | |
75 | 75 | // vars |
76 | - $label = acf_get_field_type_label( $field_type ); |
|
76 | + $label = acf_get_field_type_label($field_type); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | // return true if label exists |
80 | - if( $label !== '' ) return true; |
|
80 | + if ($label !== '') return true; |
|
81 | 81 | |
82 | 82 | |
83 | 83 | // return |
@@ -99,22 +99,22 @@ discard block |
||
99 | 99 | * @return (boolean) |
100 | 100 | */ |
101 | 101 | |
102 | -function acf_is_field_key( $key = '' ) { |
|
102 | +function acf_is_field_key($key = '') { |
|
103 | 103 | |
104 | 104 | // bail early if not string |
105 | - if( !is_string($key) ) return false; |
|
105 | + if ( ! is_string($key)) return false; |
|
106 | 106 | |
107 | 107 | |
108 | 108 | // bail early if is numeric (could be numeric string '123') |
109 | - if( is_numeric($key) ) return false; |
|
109 | + if (is_numeric($key)) return false; |
|
110 | 110 | |
111 | 111 | |
112 | 112 | // default - starts with 'field_' |
113 | - if( substr($key, 0, 6) === 'field_' ) return true; |
|
113 | + if (substr($key, 0, 6) === 'field_') return true; |
|
114 | 114 | |
115 | 115 | |
116 | 116 | // special - allow local field key to be any string |
117 | - if( acf_is_local_field($key) ) return true; |
|
117 | + if (acf_is_local_field($key)) return true; |
|
118 | 118 | |
119 | 119 | |
120 | 120 | // return |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | * @return $field (array) |
137 | 137 | */ |
138 | 138 | |
139 | -function acf_get_valid_field( $field = false ) { |
|
139 | +function acf_get_valid_field($field = false) { |
|
140 | 140 | |
141 | 141 | // $field must be an array |
142 | - if( !is_array($field) ) $field = array(); |
|
142 | + if ( ! is_array($field)) $field = array(); |
|
143 | 143 | |
144 | 144 | |
145 | 145 | // bail ealry if already valid |
146 | - if( !empty($field['_valid']) ) return $field; |
|
146 | + if ( ! empty($field['_valid'])) return $field; |
|
147 | 147 | |
148 | 148 | |
149 | 149 | // defaults |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | |
179 | 179 | |
180 | 180 | // translate |
181 | - acf_translate_keys( $field, acf_get_setting('l10n_field') ); |
|
181 | + acf_translate_keys($field, acf_get_setting('l10n_field')); |
|
182 | 182 | |
183 | 183 | |
184 | 184 | // field specific defaults |
185 | - $field = apply_filters( "acf/get_valid_field", $field ); |
|
186 | - $field = apply_filters( "acf/get_valid_field/type={$field['type']}", $field ); |
|
185 | + $field = apply_filters("acf/get_valid_field", $field); |
|
186 | + $field = apply_filters("acf/get_valid_field/type={$field['type']}", $field); |
|
187 | 187 | |
188 | 188 | |
189 | 189 | // field is now valid |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | * @return $field (array) |
209 | 209 | */ |
210 | 210 | |
211 | -function acf_prepare_field( $field ) { |
|
211 | +function acf_prepare_field($field) { |
|
212 | 212 | |
213 | 213 | // bail early if already prepared |
214 | - if( $field['_input'] ) return $field; |
|
214 | + if ($field['_input']) return $field; |
|
215 | 215 | |
216 | 216 | |
217 | 217 | // _input |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | // _input: key overrides name |
222 | - if( $field['key'] ) { |
|
222 | + if ($field['key']) { |
|
223 | 223 | |
224 | 224 | $field['_input'] = $field['key']; |
225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | |
229 | 229 | // _input: prefix prepends name |
230 | - if( $field['prefix'] ) { |
|
230 | + if ($field['prefix']) { |
|
231 | 231 | |
232 | 232 | $field['_input'] = "{$field['prefix']}[{$field['_input']}]"; |
233 | 233 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | |
237 | 237 | // add id (may be custom set) |
238 | - if( !$field['id'] ) { |
|
238 | + if ( ! $field['id']) { |
|
239 | 239 | |
240 | 240 | $field['id'] = str_replace(array('][', '[', ']'), array('-', '-', ''), $field['_input']); |
241 | 241 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | |
244 | 244 | |
245 | 245 | // filter to 3rd party customization |
246 | - $field = apply_filters( "acf/prepare_field", $field ); |
|
247 | - $field = apply_filters( "acf/prepare_field/type={$field['type']}", $field ); |
|
248 | - $field = apply_filters( "acf/prepare_field/name={$field['name']}", $field ); |
|
249 | - $field = apply_filters( "acf/prepare_field/key={$field['key']}", $field ); |
|
246 | + $field = apply_filters("acf/prepare_field", $field); |
|
247 | + $field = apply_filters("acf/prepare_field/type={$field['type']}", $field); |
|
248 | + $field = apply_filters("acf/prepare_field/name={$field['name']}", $field); |
|
249 | + $field = apply_filters("acf/prepare_field/key={$field['key']}", $field); |
|
250 | 250 | |
251 | 251 | |
252 | 252 | // return |
@@ -268,14 +268,14 @@ discard block |
||
268 | 268 | * @return (boolean) |
269 | 269 | */ |
270 | 270 | |
271 | -function acf_is_sub_field( $field ) { |
|
271 | +function acf_is_sub_field($field) { |
|
272 | 272 | |
273 | 273 | // local field uses a field instead of ID |
274 | - if( acf_is_field_key($field['parent']) ) return true; |
|
274 | + if (acf_is_field_key($field['parent'])) return true; |
|
275 | 275 | |
276 | 276 | |
277 | 277 | // attempt to load parent field |
278 | - if( acf_get_field($field['parent']) ) return true; |
|
278 | + if (acf_get_field($field['parent'])) return true; |
|
279 | 279 | |
280 | 280 | |
281 | 281 | // return |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * @return $label (string) |
298 | 298 | */ |
299 | 299 | |
300 | -function acf_get_field_label( $field ) { |
|
300 | +function acf_get_field_label($field) { |
|
301 | 301 | |
302 | 302 | // vars |
303 | 303 | $label = $field['label']; |
304 | 304 | |
305 | 305 | |
306 | - if( $field['required'] ) { |
|
306 | + if ($field['required']) { |
|
307 | 307 | |
308 | 308 | $label .= ' <span class="acf-required">*</span>'; |
309 | 309 | |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | |
316 | 316 | } |
317 | 317 | |
318 | -function acf_the_field_label( $field ) { |
|
318 | +function acf_the_field_label($field) { |
|
319 | 319 | |
320 | - echo acf_get_field_label( $field ); |
|
320 | + echo acf_get_field_label($field); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | * @return n/a |
340 | 340 | */ |
341 | 341 | |
342 | -function acf_render_fields( $post_id = 0, $fields, $el = 'div', $instruction = 'label' ) { |
|
342 | +function acf_render_fields($post_id = 0, $fields, $el = 'div', $instruction = 'label') { |
|
343 | 343 | |
344 | 344 | // bail early if no fields |
345 | - if( empty($fields) ) return false; |
|
345 | + if (empty($fields)) return false; |
|
346 | 346 | |
347 | 347 | |
348 | 348 | // remove corrupt fields |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | |
351 | 351 | |
352 | 352 | // loop through fields |
353 | - foreach( $fields as $field ) { |
|
353 | + foreach ($fields as $field) { |
|
354 | 354 | |
355 | 355 | // load value |
356 | - if( $field['value'] === null ) { |
|
356 | + if ($field['value'] === null) { |
|
357 | 357 | |
358 | - $field['value'] = acf_get_value( $post_id, $field ); |
|
358 | + $field['value'] = acf_get_value($post_id, $field); |
|
359 | 359 | |
360 | 360 | } |
361 | 361 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | |
366 | 366 | |
367 | 367 | // render |
368 | - acf_render_field_wrap( $field, $el, $instruction ); |
|
368 | + acf_render_field_wrap($field, $el, $instruction); |
|
369 | 369 | |
370 | 370 | } |
371 | 371 | |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | * @return n/a |
386 | 386 | */ |
387 | 387 | |
388 | -function acf_render_field( $field = false ) { |
|
388 | +function acf_render_field($field = false) { |
|
389 | 389 | |
390 | 390 | // get valid field |
391 | - $field = acf_get_valid_field( $field ); |
|
391 | + $field = acf_get_valid_field($field); |
|
392 | 392 | |
393 | 393 | |
394 | 394 | // prepare field for input |
395 | - $field = acf_prepare_field( $field ); |
|
395 | + $field = acf_prepare_field($field); |
|
396 | 396 | |
397 | 397 | |
398 | 398 | // update $field['name'] |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | |
401 | 401 | |
402 | 402 | // create field specific html |
403 | - do_action( "acf/render_field", $field ); |
|
404 | - do_action( "acf/render_field/type={$field['type']}", $field ); |
|
403 | + do_action("acf/render_field", $field); |
|
404 | + do_action("acf/render_field/type={$field['type']}", $field); |
|
405 | 405 | |
406 | 406 | } |
407 | 407 | |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | * @return N/A |
423 | 423 | */ |
424 | 424 | |
425 | -function acf_render_field_wrap( $field, $el = 'div', $instruction = 'label' ) { |
|
425 | +function acf_render_field_wrap($field, $el = 'div', $instruction = 'label') { |
|
426 | 426 | |
427 | 427 | // get valid field |
428 | - $field = acf_get_valid_field( $field ); |
|
428 | + $field = acf_get_valid_field($field); |
|
429 | 429 | |
430 | 430 | |
431 | 431 | // prepare field for input |
432 | - $field = acf_prepare_field( $field ); |
|
432 | + $field = acf_prepare_field($field); |
|
433 | 433 | |
434 | 434 | |
435 | 435 | // el |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | |
445 | 445 | |
446 | 446 | // validate $el |
447 | - if( !array_key_exists($el, $elements) ) { |
|
447 | + if ( ! array_key_exists($el, $elements)) { |
|
448 | 448 | |
449 | 449 | $el = 'div'; |
450 | 450 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | |
465 | 465 | |
466 | 466 | // add required |
467 | - if( $field['required'] ) { |
|
467 | + if ($field['required']) { |
|
468 | 468 | |
469 | 469 | $wrapper['data-required'] = 1; |
470 | 470 | |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | |
477 | 477 | |
478 | 478 | // add key |
479 | - if( $field['key'] ) { |
|
479 | + if ($field['key']) { |
|
480 | 480 | |
481 | 481 | $wrapper['class'] .= " acf-field-{$field['key']}"; |
482 | 482 | $wrapper['data-key'] = $field['key']; |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | |
491 | 491 | |
492 | 492 | // wrap classes have changed (5.2.7) |
493 | - if( acf_get_compatibility('field_wrapper_class') ) { |
|
493 | + if (acf_get_compatibility('field_wrapper_class')) { |
|
494 | 494 | |
495 | 495 | $wrapper['class'] .= " field_type-{$field['type']}"; |
496 | 496 | |
497 | - if( $field['key'] ) { |
|
497 | + if ($field['key']) { |
|
498 | 498 | |
499 | 499 | $wrapper['class'] .= " field_key-{$field['key']}"; |
500 | 500 | |
@@ -504,17 +504,17 @@ discard block |
||
504 | 504 | |
505 | 505 | |
506 | 506 | // merge in atts |
507 | - $wrapper = acf_merge_atts( $wrapper, $field['wrapper'] ); |
|
507 | + $wrapper = acf_merge_atts($wrapper, $field['wrapper']); |
|
508 | 508 | |
509 | 509 | |
510 | 510 | // add width |
511 | - $width = (int) acf_extract_var( $wrapper, 'width' ); |
|
511 | + $width = (int) acf_extract_var($wrapper, 'width'); |
|
512 | 512 | |
513 | - if( $el == 'tr' || $el == 'td' ) { |
|
513 | + if ($el == 'tr' || $el == 'td') { |
|
514 | 514 | |
515 | 515 | $width = 0; |
516 | 516 | |
517 | - } elseif( $width > 0 && $width < 100 ) { |
|
517 | + } elseif ($width > 0 && $width < 100) { |
|
518 | 518 | |
519 | 519 | $wrapper['data-width'] = $width; |
520 | 520 | $wrapper['style'] .= " width:{$width}%;"; |
@@ -523,9 +523,9 @@ discard block |
||
523 | 523 | |
524 | 524 | |
525 | 525 | // remove empty attributes |
526 | - foreach( $wrapper as $k => $v ) { |
|
526 | + foreach ($wrapper as $k => $v) { |
|
527 | 527 | |
528 | - if( $v == '' ) { |
|
528 | + if ($v == '') { |
|
529 | 529 | |
530 | 530 | unset($wrapper[$k]); |
531 | 531 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | // vars |
538 | 538 | $show_label = true; |
539 | 539 | |
540 | - if( $el == 'td' ) { |
|
540 | + if ($el == 'td') { |
|
541 | 541 | |
542 | 542 | $show_label = false; |
543 | 543 | |
@@ -545,22 +545,22 @@ discard block |
||
545 | 545 | |
546 | 546 | |
547 | 547 | ?><<?php echo $el; ?> <?php echo acf_esc_attr($wrapper); ?>> |
548 | -<?php if( $show_label ): ?> |
|
549 | - <<?php echo $elements[ $el ]; ?> class="acf-label"> |
|
548 | +<?php if ($show_label): ?> |
|
549 | + <<?php echo $elements[$el]; ?> class="acf-label"> |
|
550 | 550 | <label for="<?php echo $field['id']; ?>"><?php echo acf_get_field_label($field); ?></label> |
551 | -<?php if( $instruction == 'label' && $field['instructions'] ): ?> |
|
551 | +<?php if ($instruction == 'label' && $field['instructions']): ?> |
|
552 | 552 | <p class="description"><?php echo $field['instructions']; ?></p> |
553 | 553 | <?php endif; ?> |
554 | - </<?php echo $elements[ $el ]; ?>> |
|
554 | + </<?php echo $elements[$el]; ?>> |
|
555 | 555 | <?php endif; ?> |
556 | - <<?php echo $elements[ $el ]; ?> class="acf-input"> |
|
557 | - <?php acf_render_field( $field ); ?> |
|
556 | + <<?php echo $elements[$el]; ?> class="acf-input"> |
|
557 | + <?php acf_render_field($field); ?> |
|
558 | 558 | |
559 | -<?php if( $instruction == 'field' && $field['instructions'] ): ?> |
|
559 | +<?php if ($instruction == 'field' && $field['instructions']): ?> |
|
560 | 560 | <p class="description"><?php echo $field['instructions']; ?></p> |
561 | 561 | <?php endif; ?> |
562 | - </<?php echo $elements[ $el ]; ?>> |
|
563 | -<?php if( !empty($field['conditional_logic'])): ?> |
|
562 | + </<?php echo $elements[$el]; ?>> |
|
563 | +<?php if ( ! empty($field['conditional_logic'])): ?> |
|
564 | 564 | <script type="text/javascript"> |
565 | 565 | if(typeof acf !== 'undefined'){ acf.conditional_logic.add( '<?php echo $field['key']; ?>', <?php echo json_encode($field['conditional_logic']); ?>); } |
566 | 566 | </script> |
@@ -585,14 +585,14 @@ discard block |
||
585 | 585 | * @return n/a |
586 | 586 | */ |
587 | 587 | |
588 | -function acf_render_field_setting( $field, $setting, $global = false ) { |
|
588 | +function acf_render_field_setting($field, $setting, $global = false) { |
|
589 | 589 | |
590 | 590 | // validate |
591 | - $setting = acf_get_valid_field( $setting ); |
|
591 | + $setting = acf_get_valid_field($setting); |
|
592 | 592 | |
593 | 593 | |
594 | 594 | // if this setting is not global, add a data attribute |
595 | - if( !$global ) { |
|
595 | + if ( ! $global) { |
|
596 | 596 | |
597 | 597 | $setting['wrapper']['data-setting'] = $field['type']; |
598 | 598 | |
@@ -604,15 +604,15 @@ discard block |
||
604 | 604 | |
605 | 605 | |
606 | 606 | // copy across the $setting value |
607 | - if( isset($field[ $setting['name'] ]) ) { |
|
607 | + if (isset($field[$setting['name']])) { |
|
608 | 608 | |
609 | - $setting['value'] = $field[ $setting['name'] ]; |
|
609 | + $setting['value'] = $field[$setting['name']]; |
|
610 | 610 | |
611 | 611 | } |
612 | 612 | |
613 | 613 | |
614 | 614 | // render |
615 | - acf_render_field_wrap( $setting, 'tr', 'label' ); |
|
615 | + acf_render_field_wrap($setting, 'tr', 'label'); |
|
616 | 616 | |
617 | 617 | } |
618 | 618 | |
@@ -630,18 +630,18 @@ discard block |
||
630 | 630 | * @return (array) |
631 | 631 | */ |
632 | 632 | |
633 | -function acf_get_fields( $parent = false ) { |
|
633 | +function acf_get_fields($parent = false) { |
|
634 | 634 | |
635 | 635 | // allow $parent to be a field group ID |
636 | - if( !is_array($parent) ) { |
|
636 | + if ( ! is_array($parent)) { |
|
637 | 637 | |
638 | - $parent = acf_get_field_group( $parent ); |
|
638 | + $parent = acf_get_field_group($parent); |
|
639 | 639 | |
640 | 640 | } |
641 | 641 | |
642 | 642 | |
643 | 643 | // bail early if no parent |
644 | - if( !$parent ) return false; |
|
644 | + if ( ! $parent) return false; |
|
645 | 645 | |
646 | 646 | |
647 | 647 | // vars |
@@ -649,13 +649,13 @@ discard block |
||
649 | 649 | |
650 | 650 | |
651 | 651 | // try JSON before DB to save query time |
652 | - if( acf_have_local_fields( $parent['key'] ) ) { |
|
652 | + if (acf_have_local_fields($parent['key'])) { |
|
653 | 653 | |
654 | - $fields = acf_get_local_fields( $parent['key'] ); |
|
654 | + $fields = acf_get_local_fields($parent['key']); |
|
655 | 655 | |
656 | 656 | } else { |
657 | 657 | |
658 | - $fields = acf_get_fields_by_id( $parent['ID'] ); |
|
658 | + $fields = acf_get_fields_by_id($parent['ID']); |
|
659 | 659 | |
660 | 660 | } |
661 | 661 | |
@@ -679,21 +679,21 @@ discard block |
||
679 | 679 | * @return $fields (array) |
680 | 680 | */ |
681 | 681 | |
682 | -function acf_get_fields_by_id( $id = 0 ) { |
|
682 | +function acf_get_fields_by_id($id = 0) { |
|
683 | 683 | |
684 | 684 | // vars |
685 | 685 | $fields = array(); |
686 | 686 | |
687 | 687 | |
688 | 688 | // bail early if no ID |
689 | - if( empty($id) ) return false; |
|
689 | + if (empty($id)) return false; |
|
690 | 690 | |
691 | 691 | |
692 | 692 | // cache |
693 | 693 | $found = false; |
694 | - $cache = wp_cache_get( 'get_fields/parent=' . $id, 'acf', false, $found ); |
|
694 | + $cache = wp_cache_get('get_fields/parent='.$id, 'acf', false, $found); |
|
695 | 695 | |
696 | - if( $found ) return $cache; |
|
696 | + if ($found) return $cache; |
|
697 | 697 | |
698 | 698 | |
699 | 699 | // args |
@@ -710,13 +710,13 @@ discard block |
||
710 | 710 | |
711 | 711 | |
712 | 712 | // load fields |
713 | - $posts = get_posts( $args ); |
|
713 | + $posts = get_posts($args); |
|
714 | 714 | |
715 | - if( $posts ) { |
|
715 | + if ($posts) { |
|
716 | 716 | |
717 | - foreach( $posts as $post ) { |
|
717 | + foreach ($posts as $post) { |
|
718 | 718 | |
719 | - $fields[] = acf_get_field( $post->ID ); |
|
719 | + $fields[] = acf_get_field($post->ID); |
|
720 | 720 | |
721 | 721 | } |
722 | 722 | |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | |
725 | 725 | |
726 | 726 | // set cache |
727 | - wp_cache_set( 'get_fields/parent=' . $id, $fields, 'acf' ); |
|
727 | + wp_cache_set('get_fields/parent='.$id, $fields, 'acf'); |
|
728 | 728 | |
729 | 729 | |
730 | 730 | // return |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | * @return $field (array) |
748 | 748 | */ |
749 | 749 | |
750 | -function acf_get_field( $selector = null, $db_only = false ) { |
|
750 | +function acf_get_field($selector = null, $db_only = false) { |
|
751 | 751 | |
752 | 752 | // vars |
753 | 753 | $field = false; |
@@ -755,17 +755,17 @@ discard block |
||
755 | 755 | |
756 | 756 | |
757 | 757 | // is $selector an ID |
758 | - if( is_numeric($selector) ) { |
|
758 | + if (is_numeric($selector)) { |
|
759 | 759 | |
760 | 760 | // do nothing |
761 | 761 | |
762 | 762 | // is $selector a string (name|key) |
763 | - } elseif( is_string($selector) ) { |
|
763 | + } elseif (is_string($selector)) { |
|
764 | 764 | |
765 | 765 | $type = acf_is_field_key($selector) ? 'key' : 'name'; |
766 | 766 | |
767 | 767 | // is $selector an object |
768 | - } elseif( is_object($selector) ) { |
|
768 | + } elseif (is_object($selector)) { |
|
769 | 769 | |
770 | 770 | $selector = $selector->ID; |
771 | 771 | |
@@ -782,34 +782,34 @@ discard block |
||
782 | 782 | |
783 | 783 | |
784 | 784 | // get cache |
785 | - if( !$db_only ) { |
|
785 | + if ( ! $db_only) { |
|
786 | 786 | |
787 | 787 | $found = false; |
788 | - $cache = wp_cache_get( $cache_key, 'acf', false, $found ); |
|
788 | + $cache = wp_cache_get($cache_key, 'acf', false, $found); |
|
789 | 789 | |
790 | - if( $found ) return $cache; |
|
790 | + if ($found) return $cache; |
|
791 | 791 | |
792 | 792 | } |
793 | 793 | |
794 | 794 | |
795 | 795 | // get field group from ID or key |
796 | - if( $type == 'ID' ) { |
|
796 | + if ($type == 'ID') { |
|
797 | 797 | |
798 | - $field = _acf_get_field_by_id( $selector, $db_only ); |
|
798 | + $field = _acf_get_field_by_id($selector, $db_only); |
|
799 | 799 | |
800 | - } elseif( $type == 'name' ) { |
|
800 | + } elseif ($type == 'name') { |
|
801 | 801 | |
802 | - $field = _acf_get_field_by_name( $selector, $db_only ); |
|
802 | + $field = _acf_get_field_by_name($selector, $db_only); |
|
803 | 803 | |
804 | 804 | } else { |
805 | 805 | |
806 | - $field = _acf_get_field_by_key( $selector, $db_only ); |
|
806 | + $field = _acf_get_field_by_key($selector, $db_only); |
|
807 | 807 | |
808 | 808 | } |
809 | 809 | |
810 | 810 | |
811 | 811 | // bail early if db only value (no need to update cache) |
812 | - if( $db_only ) { |
|
812 | + if ($db_only) { |
|
813 | 813 | |
814 | 814 | return $field; |
815 | 815 | |
@@ -817,18 +817,18 @@ discard block |
||
817 | 817 | |
818 | 818 | |
819 | 819 | // filter for 3rd party customization |
820 | - if( $field ) { |
|
820 | + if ($field) { |
|
821 | 821 | |
822 | - $field = apply_filters( "acf/load_field", $field); |
|
823 | - $field = apply_filters( "acf/load_field/type={$field['type']}", $field ); |
|
824 | - $field = apply_filters( "acf/load_field/name={$field['name']}", $field ); |
|
825 | - $field = apply_filters( "acf/load_field/key={$field['key']}", $field ); |
|
822 | + $field = apply_filters("acf/load_field", $field); |
|
823 | + $field = apply_filters("acf/load_field/type={$field['type']}", $field); |
|
824 | + $field = apply_filters("acf/load_field/name={$field['name']}", $field); |
|
825 | + $field = apply_filters("acf/load_field/key={$field['key']}", $field); |
|
826 | 826 | |
827 | 827 | } |
828 | 828 | |
829 | 829 | |
830 | 830 | // set cache |
831 | - wp_cache_set( $cache_key, $field, 'acf' ); |
|
831 | + wp_cache_set($cache_key, $field, 'acf'); |
|
832 | 832 | |
833 | 833 | |
834 | 834 | // return |
@@ -850,14 +850,14 @@ discard block |
||
850 | 850 | * @return $field (array) |
851 | 851 | */ |
852 | 852 | |
853 | -function _acf_get_field_by_id( $post_id = 0, $db_only = false ) { |
|
853 | +function _acf_get_field_by_id($post_id = 0, $db_only = false) { |
|
854 | 854 | |
855 | 855 | // get post |
856 | - $post = get_post( $post_id ); |
|
856 | + $post = get_post($post_id); |
|
857 | 857 | |
858 | 858 | |
859 | 859 | // bail early if no post, or is not a field |
860 | - if( empty($post) || $post->post_type != 'acf-field' ) { |
|
860 | + if (empty($post) || $post->post_type != 'acf-field') { |
|
861 | 861 | |
862 | 862 | return false; |
863 | 863 | |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | |
866 | 866 | |
867 | 867 | // unserialize |
868 | - $field = maybe_unserialize( $post->post_content ); |
|
868 | + $field = maybe_unserialize($post->post_content); |
|
869 | 869 | |
870 | 870 | |
871 | 871 | // update attributes |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | |
879 | 879 | |
880 | 880 | // override with JSON |
881 | - if( !$db_only && acf_is_local_field($field['key']) ) { |
|
881 | + if ( ! $db_only && acf_is_local_field($field['key'])) { |
|
882 | 882 | |
883 | 883 | // extract some args |
884 | 884 | $backup = acf_extract_vars($field, array( |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | |
889 | 889 | |
890 | 890 | // load JSON field |
891 | - $field = acf_get_local_field( $field['key'] ); |
|
891 | + $field = acf_get_local_field($field['key']); |
|
892 | 892 | |
893 | 893 | |
894 | 894 | // merge in backup |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | |
899 | 899 | |
900 | 900 | // validate |
901 | - $field = acf_get_valid_field( $field ); |
|
901 | + $field = acf_get_valid_field($field); |
|
902 | 902 | |
903 | 903 | |
904 | 904 | // return |
@@ -920,15 +920,15 @@ discard block |
||
920 | 920 | * @return $field (array) |
921 | 921 | */ |
922 | 922 | |
923 | -function _acf_get_field_by_key( $key = '', $db_only = false ) { |
|
923 | +function _acf_get_field_by_key($key = '', $db_only = false) { |
|
924 | 924 | |
925 | 925 | // try JSON before DB to save query time |
926 | - if( !$db_only && acf_is_local_field( $key ) ) { |
|
926 | + if ( ! $db_only && acf_is_local_field($key)) { |
|
927 | 927 | |
928 | - $field = acf_get_local_field( $key ); |
|
928 | + $field = acf_get_local_field($key); |
|
929 | 929 | |
930 | 930 | // validate |
931 | - $field = acf_get_valid_field( $field ); |
|
931 | + $field = acf_get_valid_field($field); |
|
932 | 932 | |
933 | 933 | // return |
934 | 934 | return $field; |
@@ -937,15 +937,15 @@ discard block |
||
937 | 937 | |
938 | 938 | |
939 | 939 | // vars |
940 | - $post_id = acf_get_field_id( $key ); |
|
940 | + $post_id = acf_get_field_id($key); |
|
941 | 941 | |
942 | 942 | |
943 | 943 | // bail early if no post_id |
944 | - if( !$post_id ) return false; |
|
944 | + if ( ! $post_id) return false; |
|
945 | 945 | |
946 | 946 | |
947 | 947 | // return |
948 | - return _acf_get_field_by_id( $post_id, $db_only ); |
|
948 | + return _acf_get_field_by_id($post_id, $db_only); |
|
949 | 949 | |
950 | 950 | } |
951 | 951 | |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | * @return $field (array) |
964 | 964 | */ |
965 | 965 | |
966 | -function _acf_get_field_by_name( $name = '', $db_only = false ) { |
|
966 | +function _acf_get_field_by_name($name = '', $db_only = false) { |
|
967 | 967 | |
968 | 968 | // vars |
969 | 969 | $args = array( |
@@ -977,15 +977,15 @@ discard block |
||
977 | 977 | |
978 | 978 | |
979 | 979 | // load posts |
980 | - $posts = get_posts( $args ); |
|
980 | + $posts = get_posts($args); |
|
981 | 981 | |
982 | 982 | |
983 | 983 | // bail early if no posts |
984 | - if( empty($posts) ) return false; |
|
984 | + if (empty($posts)) return false; |
|
985 | 985 | |
986 | 986 | |
987 | 987 | // return |
988 | - return _acf_get_field_by_id( $posts[0]->ID, $db_only ); |
|
988 | + return _acf_get_field_by_id($posts[0]->ID, $db_only); |
|
989 | 989 | |
990 | 990 | } |
991 | 991 | |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | * @return $field (array) |
1007 | 1007 | */ |
1008 | 1008 | |
1009 | -function acf_maybe_get_field( $selector, $post_id = false, $strict = true ) { |
|
1009 | +function acf_maybe_get_field($selector, $post_id = false, $strict = true) { |
|
1010 | 1010 | |
1011 | 1011 | // complete init |
1012 | 1012 | // this function may be used in a theme file before the init action has been run |
@@ -1018,25 +1018,25 @@ discard block |
||
1018 | 1018 | |
1019 | 1019 | |
1020 | 1020 | // get valid post_id |
1021 | - $post_id = acf_get_valid_post_id( $post_id ); |
|
1021 | + $post_id = acf_get_valid_post_id($post_id); |
|
1022 | 1022 | |
1023 | 1023 | |
1024 | 1024 | // load field reference if not a field_key |
1025 | - if( !acf_is_field_key($selector) ) { |
|
1025 | + if ( ! acf_is_field_key($selector)) { |
|
1026 | 1026 | |
1027 | 1027 | // save selector as field_name (could be sub field name) |
1028 | 1028 | $field_name = $selector; |
1029 | 1029 | |
1030 | 1030 | |
1031 | 1031 | // get reference |
1032 | - $field_key = acf_get_field_reference( $selector, $post_id ); |
|
1032 | + $field_key = acf_get_field_reference($selector, $post_id); |
|
1033 | 1033 | |
1034 | 1034 | |
1035 | - if( $field_key ) { |
|
1035 | + if ($field_key) { |
|
1036 | 1036 | |
1037 | 1037 | $selector = $field_key; |
1038 | 1038 | |
1039 | - } elseif( $strict ) { |
|
1039 | + } elseif ($strict) { |
|
1040 | 1040 | |
1041 | 1041 | return false; |
1042 | 1042 | |
@@ -1046,15 +1046,15 @@ discard block |
||
1046 | 1046 | |
1047 | 1047 | |
1048 | 1048 | // get field key |
1049 | - $field = acf_get_field( $selector ); |
|
1049 | + $field = acf_get_field($selector); |
|
1050 | 1050 | |
1051 | 1051 | |
1052 | 1052 | // bail early if no field |
1053 | - if( !$field ) return false; |
|
1053 | + if ( ! $field) return false; |
|
1054 | 1054 | |
1055 | 1055 | |
1056 | 1056 | // Override name - allows the $selector to be a sub field (images_0_image) |
1057 | - if( $field_name ) { |
|
1057 | + if ($field_name) { |
|
1058 | 1058 | |
1059 | 1059 | $field['name'] = $field_name; |
1060 | 1060 | |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | * @return $post_id (int) |
1082 | 1082 | */ |
1083 | 1083 | |
1084 | -function acf_get_field_id( $key = '' ) { |
|
1084 | +function acf_get_field_id($key = '') { |
|
1085 | 1085 | |
1086 | 1086 | // vars |
1087 | 1087 | $args = array( |
@@ -1095,11 +1095,11 @@ discard block |
||
1095 | 1095 | |
1096 | 1096 | |
1097 | 1097 | // load posts |
1098 | - $posts = get_posts( $args ); |
|
1098 | + $posts = get_posts($args); |
|
1099 | 1099 | |
1100 | 1100 | |
1101 | 1101 | // validate |
1102 | - if( empty($posts) ) return 0; |
|
1102 | + if (empty($posts)) return 0; |
|
1103 | 1103 | |
1104 | 1104 | |
1105 | 1105 | // return |
@@ -1122,25 +1122,25 @@ discard block |
||
1122 | 1122 | * @return $field (array) |
1123 | 1123 | */ |
1124 | 1124 | |
1125 | -function acf_update_field( $field = false, $specific = false ) { |
|
1125 | +function acf_update_field($field = false, $specific = false) { |
|
1126 | 1126 | |
1127 | 1127 | // $field must be an array |
1128 | - if( !is_array($field) ) return false; |
|
1128 | + if ( ! is_array($field)) return false; |
|
1129 | 1129 | |
1130 | 1130 | |
1131 | 1131 | // validate |
1132 | - $field = acf_get_valid_field( $field ); |
|
1132 | + $field = acf_get_valid_field($field); |
|
1133 | 1133 | |
1134 | 1134 | |
1135 | 1135 | // may have been posted. Remove slashes |
1136 | - $field = wp_unslash( $field ); |
|
1136 | + $field = wp_unslash($field); |
|
1137 | 1137 | |
1138 | 1138 | |
1139 | 1139 | // clean up conditional logic keys |
1140 | - if( !empty($field['conditional_logic']) ) { |
|
1140 | + if ( ! empty($field['conditional_logic'])) { |
|
1141 | 1141 | |
1142 | 1142 | // extract groups |
1143 | - $groups = acf_extract_var( $field, 'conditional_logic' ); |
|
1143 | + $groups = acf_extract_var($field, 'conditional_logic'); |
|
1144 | 1144 | |
1145 | 1145 | |
1146 | 1146 | // clean array |
@@ -1149,10 +1149,10 @@ discard block |
||
1149 | 1149 | |
1150 | 1150 | |
1151 | 1151 | // clean rules |
1152 | - foreach( array_keys($groups) as $i ) { |
|
1152 | + foreach (array_keys($groups) as $i) { |
|
1153 | 1153 | |
1154 | - $groups[ $i ] = array_filter($groups[ $i ]); |
|
1155 | - $groups[ $i ] = array_values($groups[ $i ]); |
|
1154 | + $groups[$i] = array_filter($groups[$i]); |
|
1155 | + $groups[$i] = array_values($groups[$i]); |
|
1156 | 1156 | |
1157 | 1157 | } |
1158 | 1158 | |
@@ -1164,23 +1164,23 @@ discard block |
||
1164 | 1164 | |
1165 | 1165 | |
1166 | 1166 | // find correct parent |
1167 | - if( acf_is_field_key($field['parent']) ) { |
|
1167 | + if (acf_is_field_key($field['parent'])) { |
|
1168 | 1168 | |
1169 | 1169 | // get parent |
1170 | - $parent = acf_get_field( $field['parent'] ); |
|
1170 | + $parent = acf_get_field($field['parent']); |
|
1171 | 1171 | |
1172 | 1172 | |
1173 | 1173 | // update to ID |
1174 | - $field['parent'] = acf_maybe_get( $parent, 'ID', 0 ); |
|
1174 | + $field['parent'] = acf_maybe_get($parent, 'ID', 0); |
|
1175 | 1175 | |
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | |
1179 | 1179 | // filter for 3rd party customization |
1180 | - $field = apply_filters( "acf/update_field", $field); |
|
1181 | - $field = apply_filters( "acf/update_field/type={$field['type']}", $field ); |
|
1182 | - $field = apply_filters( "acf/update_field/name={$field['name']}", $field ); |
|
1183 | - $field = apply_filters( "acf/update_field/key={$field['key']}", $field ); |
|
1180 | + $field = apply_filters("acf/update_field", $field); |
|
1181 | + $field = apply_filters("acf/update_field/type={$field['type']}", $field); |
|
1182 | + $field = apply_filters("acf/update_field/name={$field['name']}", $field); |
|
1183 | + $field = apply_filters("acf/update_field/key={$field['key']}", $field); |
|
1184 | 1184 | |
1185 | 1185 | |
1186 | 1186 | // store origional field for return |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | |
1207 | 1207 | |
1208 | 1208 | // serialize for DB |
1209 | - $data = maybe_serialize( $data ); |
|
1209 | + $data = maybe_serialize($data); |
|
1210 | 1210 | |
1211 | 1211 | |
1212 | 1212 | // save |
@@ -1224,10 +1224,10 @@ discard block |
||
1224 | 1224 | |
1225 | 1225 | |
1226 | 1226 | // $specific |
1227 | - if( !empty($specific) ) { |
|
1227 | + if ( ! empty($specific)) { |
|
1228 | 1228 | |
1229 | 1229 | // prepend ID |
1230 | - array_unshift( $specific, 'ID' ); |
|
1230 | + array_unshift($specific, 'ID'); |
|
1231 | 1231 | |
1232 | 1232 | |
1233 | 1233 | // vars |
@@ -1239,9 +1239,9 @@ discard block |
||
1239 | 1239 | |
1240 | 1240 | |
1241 | 1241 | // appen data |
1242 | - foreach( $specific as $key ) { |
|
1242 | + foreach ($specific as $key) { |
|
1243 | 1243 | |
1244 | - $save[ $key ] = $_save[ $key ]; |
|
1244 | + $save[$key] = $_save[$key]; |
|
1245 | 1245 | |
1246 | 1246 | } |
1247 | 1247 | |
@@ -1249,25 +1249,25 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | |
1251 | 1251 | // allow fields to contain the same name |
1252 | - add_filter( 'wp_unique_post_slug', 'acf_update_field_wp_unique_post_slug', 100, 6 ); |
|
1252 | + add_filter('wp_unique_post_slug', 'acf_update_field_wp_unique_post_slug', 100, 6); |
|
1253 | 1253 | |
1254 | 1254 | |
1255 | 1255 | // update the field and update the ID |
1256 | - if( $field['ID'] ) { |
|
1256 | + if ($field['ID']) { |
|
1257 | 1257 | |
1258 | - wp_update_post( $save ); |
|
1258 | + wp_update_post($save); |
|
1259 | 1259 | |
1260 | - } else { |
|
1260 | + } else { |
|
1261 | 1261 | |
1262 | - $field['ID'] = wp_insert_post( $save ); |
|
1262 | + $field['ID'] = wp_insert_post($save); |
|
1263 | 1263 | |
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | |
1267 | 1267 | // clear cache |
1268 | - wp_cache_delete( "get_field/ID={$field['ID']}", 'acf' ); |
|
1269 | - wp_cache_delete( "get_field/key={$field['key']}", 'acf' ); |
|
1270 | - wp_cache_delete( "get_fields/parent={$field['parent']}", 'acf' ); |
|
1268 | + wp_cache_delete("get_field/ID={$field['ID']}", 'acf'); |
|
1269 | + wp_cache_delete("get_field/key={$field['key']}", 'acf'); |
|
1270 | + wp_cache_delete("get_fields/parent={$field['parent']}", 'acf'); |
|
1271 | 1271 | |
1272 | 1272 | |
1273 | 1273 | // return |
@@ -1275,9 +1275,9 @@ discard block |
||
1275 | 1275 | |
1276 | 1276 | } |
1277 | 1277 | |
1278 | -function acf_update_field_wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) { |
|
1278 | +function acf_update_field_wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug) { |
|
1279 | 1279 | |
1280 | - if( $post_type == 'acf-field' ) { |
|
1280 | + if ($post_type == 'acf-field') { |
|
1281 | 1281 | |
1282 | 1282 | $slug = $original_slug; |
1283 | 1283 | |
@@ -1303,28 +1303,28 @@ discard block |
||
1303 | 1303 | * @return n/a |
1304 | 1304 | */ |
1305 | 1305 | |
1306 | -function acf_duplicate_fields( $fields, $new_parent = 0 ) { |
|
1306 | +function acf_duplicate_fields($fields, $new_parent = 0) { |
|
1307 | 1307 | |
1308 | 1308 | // bail early if no fields |
1309 | - if( empty($fields) ) return; |
|
1309 | + if (empty($fields)) return; |
|
1310 | 1310 | |
1311 | 1311 | |
1312 | 1312 | // create new field keys (for conditional logic fixes) |
1313 | - foreach( $fields as $field ) { |
|
1313 | + foreach ($fields as $field) { |
|
1314 | 1314 | |
1315 | 1315 | // ensure a delay for unique ID |
1316 | 1316 | usleep(1); |
1317 | 1317 | |
1318 | - acf_update_setting( 'duplicate_key_' . $field['key'] , uniqid('field_') ); |
|
1318 | + acf_update_setting('duplicate_key_'.$field['key'], uniqid('field_')); |
|
1319 | 1319 | |
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | |
1323 | 1323 | // duplicate fields |
1324 | - foreach( $fields as $field ) { |
|
1324 | + foreach ($fields as $field) { |
|
1325 | 1325 | |
1326 | 1326 | // duplicate |
1327 | - acf_duplicate_field( $field['ID'], $new_parent ); |
|
1327 | + acf_duplicate_field($field['ID'], $new_parent); |
|
1328 | 1328 | |
1329 | 1329 | } |
1330 | 1330 | |
@@ -1345,18 +1345,18 @@ discard block |
||
1345 | 1345 | * @return $field (array) the new field |
1346 | 1346 | */ |
1347 | 1347 | |
1348 | -function acf_duplicate_field( $selector = 0, $new_parent = 0 ){ |
|
1348 | +function acf_duplicate_field($selector = 0, $new_parent = 0) { |
|
1349 | 1349 | |
1350 | 1350 | // disable JSON to avoid conflicts between DB and JSON |
1351 | 1351 | acf_disable_local(); |
1352 | 1352 | |
1353 | 1353 | |
1354 | 1354 | // load the origional field |
1355 | - $field = acf_get_field( $selector ); |
|
1355 | + $field = acf_get_field($selector); |
|
1356 | 1356 | |
1357 | 1357 | |
1358 | 1358 | // bail early if field did not load correctly |
1359 | - if( empty($field) ) { |
|
1359 | + if (empty($field)) { |
|
1360 | 1360 | |
1361 | 1361 | return false; |
1362 | 1362 | |
@@ -1368,11 +1368,11 @@ discard block |
||
1368 | 1368 | |
1369 | 1369 | |
1370 | 1370 | // try duplicate keys |
1371 | - $field['key'] = acf_get_setting( 'duplicate_key_' . $field['key'] ); |
|
1371 | + $field['key'] = acf_get_setting('duplicate_key_'.$field['key']); |
|
1372 | 1372 | |
1373 | 1373 | |
1374 | 1374 | // default key |
1375 | - if( empty($field['key']) ) { |
|
1375 | + if (empty($field['key'])) { |
|
1376 | 1376 | |
1377 | 1377 | $field['key'] = uniqid('field_'); |
1378 | 1378 | |
@@ -1380,7 +1380,7 @@ discard block |
||
1380 | 1380 | |
1381 | 1381 | |
1382 | 1382 | // update parent |
1383 | - if( $new_parent ) { |
|
1383 | + if ($new_parent) { |
|
1384 | 1384 | |
1385 | 1385 | $field['parent'] = $new_parent; |
1386 | 1386 | |
@@ -1388,21 +1388,21 @@ discard block |
||
1388 | 1388 | |
1389 | 1389 | |
1390 | 1390 | // update conditional logic references (because field keys have changed) |
1391 | - if( !empty($field['conditional_logic']) ) { |
|
1391 | + if ( ! empty($field['conditional_logic'])) { |
|
1392 | 1392 | |
1393 | 1393 | // extract groups |
1394 | - $groups = acf_extract_var( $field, 'conditional_logic' ); |
|
1394 | + $groups = acf_extract_var($field, 'conditional_logic'); |
|
1395 | 1395 | |
1396 | 1396 | |
1397 | 1397 | // loop over groups |
1398 | - foreach( array_keys($groups) as $g ) { |
|
1398 | + foreach (array_keys($groups) as $g) { |
|
1399 | 1399 | |
1400 | 1400 | // extract group |
1401 | - $group = acf_extract_var( $groups, $g ); |
|
1401 | + $group = acf_extract_var($groups, $g); |
|
1402 | 1402 | |
1403 | 1403 | |
1404 | 1404 | // bail early if empty |
1405 | - if( empty($group) ) { |
|
1405 | + if (empty($group)) { |
|
1406 | 1406 | |
1407 | 1407 | continue; |
1408 | 1408 | |
@@ -1410,18 +1410,18 @@ discard block |
||
1410 | 1410 | |
1411 | 1411 | |
1412 | 1412 | // loop over rules |
1413 | - foreach( array_keys($group) as $r ) { |
|
1413 | + foreach (array_keys($group) as $r) { |
|
1414 | 1414 | |
1415 | 1415 | // extract rule |
1416 | - $rule = acf_extract_var( $group, $r ); |
|
1416 | + $rule = acf_extract_var($group, $r); |
|
1417 | 1417 | |
1418 | 1418 | |
1419 | 1419 | // vars |
1420 | - $new_key = acf_get_setting( 'duplicate_key_' . $rule['field'] ); |
|
1420 | + $new_key = acf_get_setting('duplicate_key_'.$rule['field']); |
|
1421 | 1421 | |
1422 | 1422 | |
1423 | 1423 | // update rule with new key |
1424 | - if( $new_key ) { |
|
1424 | + if ($new_key) { |
|
1425 | 1425 | |
1426 | 1426 | $rule['field'] = $new_key; |
1427 | 1427 | |
@@ -1429,13 +1429,13 @@ discard block |
||
1429 | 1429 | |
1430 | 1430 | |
1431 | 1431 | // append to group |
1432 | - $group[ $r ] = $rule; |
|
1432 | + $group[$r] = $rule; |
|
1433 | 1433 | |
1434 | 1434 | } |
1435 | 1435 | |
1436 | 1436 | |
1437 | 1437 | // append to groups |
1438 | - $groups[ $g ] = $group; |
|
1438 | + $groups[$g] = $group; |
|
1439 | 1439 | |
1440 | 1440 | } |
1441 | 1441 | |
@@ -1448,12 +1448,12 @@ discard block |
||
1448 | 1448 | |
1449 | 1449 | |
1450 | 1450 | // filter for 3rd party customization |
1451 | - $field = apply_filters( "acf/duplicate_field", $field); |
|
1452 | - $field = apply_filters( "acf/duplicate_field/type={$field['type']}", $field ); |
|
1451 | + $field = apply_filters("acf/duplicate_field", $field); |
|
1452 | + $field = apply_filters("acf/duplicate_field/type={$field['type']}", $field); |
|
1453 | 1453 | |
1454 | 1454 | |
1455 | 1455 | // save |
1456 | - return acf_update_field( $field ); |
|
1456 | + return acf_update_field($field); |
|
1457 | 1457 | |
1458 | 1458 | } |
1459 | 1459 | |
@@ -1471,33 +1471,33 @@ discard block |
||
1471 | 1471 | * @return (boolean) |
1472 | 1472 | */ |
1473 | 1473 | |
1474 | -function acf_delete_field( $selector = 0 ) { |
|
1474 | +function acf_delete_field($selector = 0) { |
|
1475 | 1475 | |
1476 | 1476 | // disable JSON to avoid conflicts between DB and JSON |
1477 | 1477 | acf_disable_local(); |
1478 | 1478 | |
1479 | 1479 | |
1480 | 1480 | // load the origional field gorup |
1481 | - $field = acf_get_field( $selector ); |
|
1481 | + $field = acf_get_field($selector); |
|
1482 | 1482 | |
1483 | 1483 | |
1484 | 1484 | // bail early if field did not load correctly |
1485 | - if( empty($field) ) return false; |
|
1485 | + if (empty($field)) return false; |
|
1486 | 1486 | |
1487 | 1487 | |
1488 | 1488 | // delete field |
1489 | - wp_delete_post( $field['ID'], true ); |
|
1489 | + wp_delete_post($field['ID'], true); |
|
1490 | 1490 | |
1491 | 1491 | |
1492 | 1492 | // action for 3rd party customisation |
1493 | - do_action( "acf/delete_field", $field); |
|
1494 | - do_action( "acf/delete_field/type={$field['type']}", $field ); |
|
1493 | + do_action("acf/delete_field", $field); |
|
1494 | + do_action("acf/delete_field/type={$field['type']}", $field); |
|
1495 | 1495 | |
1496 | 1496 | |
1497 | 1497 | // clear cache |
1498 | - wp_cache_delete( "get_field/ID={$field['ID']}", 'acf' ); |
|
1499 | - wp_cache_delete( "get_field/key={$field['key']}", 'acf' ); |
|
1500 | - wp_cache_delete( "get_fields/parent={$field['parent']}", 'acf' ); |
|
1498 | + wp_cache_delete("get_field/ID={$field['ID']}", 'acf'); |
|
1499 | + wp_cache_delete("get_field/key={$field['key']}", 'acf'); |
|
1500 | + wp_cache_delete("get_fields/parent={$field['parent']}", 'acf'); |
|
1501 | 1501 | |
1502 | 1502 | |
1503 | 1503 | // return |
@@ -1518,26 +1518,26 @@ discard block |
||
1518 | 1518 | * @return (boolean) |
1519 | 1519 | */ |
1520 | 1520 | |
1521 | -function acf_trash_field( $selector = 0 ) { |
|
1521 | +function acf_trash_field($selector = 0) { |
|
1522 | 1522 | |
1523 | 1523 | // disable JSON to avoid conflicts between DB and JSON |
1524 | 1524 | acf_disable_local(); |
1525 | 1525 | |
1526 | 1526 | |
1527 | 1527 | // load the origional field gorup |
1528 | - $field = acf_get_field( $selector ); |
|
1528 | + $field = acf_get_field($selector); |
|
1529 | 1529 | |
1530 | 1530 | |
1531 | 1531 | // bail early if field did not load correctly |
1532 | - if( empty($field) ) return false; |
|
1532 | + if (empty($field)) return false; |
|
1533 | 1533 | |
1534 | 1534 | |
1535 | 1535 | // delete field |
1536 | - wp_trash_post( $field['ID'] ); |
|
1536 | + wp_trash_post($field['ID']); |
|
1537 | 1537 | |
1538 | 1538 | |
1539 | 1539 | // action for 3rd party customisation |
1540 | - do_action( 'acf/trash_field', $field ); |
|
1540 | + do_action('acf/trash_field', $field); |
|
1541 | 1541 | |
1542 | 1542 | |
1543 | 1543 | // return |
@@ -1558,26 +1558,26 @@ discard block |
||
1558 | 1558 | * @return (boolean) |
1559 | 1559 | */ |
1560 | 1560 | |
1561 | -function acf_untrash_field( $selector = 0 ) { |
|
1561 | +function acf_untrash_field($selector = 0) { |
|
1562 | 1562 | |
1563 | 1563 | // disable JSON to avoid conflicts between DB and JSON |
1564 | 1564 | acf_disable_local(); |
1565 | 1565 | |
1566 | 1566 | |
1567 | 1567 | // load the origional field gorup |
1568 | - $field = acf_get_field( $selector ); |
|
1568 | + $field = acf_get_field($selector); |
|
1569 | 1569 | |
1570 | 1570 | |
1571 | 1571 | // bail early if field did not load correctly |
1572 | - if( empty($field) ) return false; |
|
1572 | + if (empty($field)) return false; |
|
1573 | 1573 | |
1574 | 1574 | |
1575 | 1575 | // delete field |
1576 | - wp_untrash_post( $field['ID'] ); |
|
1576 | + wp_untrash_post($field['ID']); |
|
1577 | 1577 | |
1578 | 1578 | |
1579 | 1579 | // action for 3rd party customisation |
1580 | - do_action( 'acf/untrash_field', $field ); |
|
1580 | + do_action('acf/untrash_field', $field); |
|
1581 | 1581 | |
1582 | 1582 | |
1583 | 1583 | // return |
@@ -1598,17 +1598,17 @@ discard block |
||
1598 | 1598 | * @return $post_id (int) |
1599 | 1599 | */ |
1600 | 1600 | |
1601 | -function acf_prepare_fields_for_export( $fields = false ) { |
|
1601 | +function acf_prepare_fields_for_export($fields = false) { |
|
1602 | 1602 | |
1603 | 1603 | // validate |
1604 | - if( empty($fields) ) return $fields; |
|
1604 | + if (empty($fields)) return $fields; |
|
1605 | 1605 | |
1606 | 1606 | |
1607 | 1607 | // format |
1608 | - foreach( array_keys($fields) as $i ) { |
|
1608 | + foreach (array_keys($fields) as $i) { |
|
1609 | 1609 | |
1610 | 1610 | // prepare |
1611 | - $fields[ $i ] = acf_prepare_field_for_export( $fields[ $i ] ); |
|
1611 | + $fields[$i] = acf_prepare_field_for_export($fields[$i]); |
|
1612 | 1612 | |
1613 | 1613 | } |
1614 | 1614 | |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | * @return $post_id (int) |
1633 | 1633 | */ |
1634 | 1634 | |
1635 | -function acf_prepare_field_for_export( $field ) { |
|
1635 | +function acf_prepare_field_for_export($field) { |
|
1636 | 1636 | |
1637 | 1637 | // extract some args |
1638 | 1638 | $extract = acf_extract_vars($field, array( |
@@ -1650,7 +1650,7 @@ discard block |
||
1650 | 1650 | |
1651 | 1651 | |
1652 | 1652 | // filter for 3rd party customization |
1653 | - $field = apply_filters( "acf/prepare_field_for_export", $field ); |
|
1653 | + $field = apply_filters("acf/prepare_field_for_export", $field); |
|
1654 | 1654 | |
1655 | 1655 | |
1656 | 1656 | // return |
@@ -1671,10 +1671,10 @@ discard block |
||
1671 | 1671 | * @return $post_id (int) |
1672 | 1672 | */ |
1673 | 1673 | |
1674 | -function acf_prepare_fields_for_import( $fields = false ) { |
|
1674 | +function acf_prepare_fields_for_import($fields = false) { |
|
1675 | 1675 | |
1676 | 1676 | // validate |
1677 | - if( empty($fields) ) return $fields; |
|
1677 | + if (empty($fields)) return $fields; |
|
1678 | 1678 | |
1679 | 1679 | |
1680 | 1680 | // re-index array |
@@ -1686,14 +1686,14 @@ discard block |
||
1686 | 1686 | |
1687 | 1687 | |
1688 | 1688 | // format |
1689 | - while( $i < count($fields) ) { |
|
1689 | + while ($i < count($fields)) { |
|
1690 | 1690 | |
1691 | 1691 | // prepare field |
1692 | - $field = acf_prepare_field_for_import( $fields[ $i ] ); |
|
1692 | + $field = acf_prepare_field_for_import($fields[$i]); |
|
1693 | 1693 | |
1694 | 1694 | |
1695 | 1695 | // $field may be an array of multiple fields (including sub fields) |
1696 | - if( !isset($field['key']) ) { |
|
1696 | + if ( ! isset($field['key'])) { |
|
1697 | 1697 | |
1698 | 1698 | $extra = $field; |
1699 | 1699 | |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | } |
1704 | 1704 | |
1705 | 1705 | // prepare |
1706 | - $fields[ $i ] = $field; |
|
1706 | + $fields[$i] = $field; |
|
1707 | 1707 | |
1708 | 1708 | |
1709 | 1709 | // $i |
@@ -1734,7 +1734,7 @@ discard block |
||
1734 | 1734 | * @return $post_id (int) |
1735 | 1735 | */ |
1736 | 1736 | |
1737 | -function acf_prepare_field_for_import( $field ) { |
|
1737 | +function acf_prepare_field_for_import($field) { |
|
1738 | 1738 | |
1739 | 1739 | // extract some args |
1740 | 1740 | $extract = acf_extract_vars($field, array( |
@@ -1748,7 +1748,7 @@ discard block |
||
1748 | 1748 | |
1749 | 1749 | |
1750 | 1750 | // filter for 3rd party customization |
1751 | - $field = apply_filters( "acf/prepare_field_for_import", $field ); |
|
1751 | + $field = apply_filters("acf/prepare_field_for_import", $field); |
|
1752 | 1752 | |
1753 | 1753 | |
1754 | 1754 | // return |
@@ -1770,19 +1770,19 @@ discard block |
||
1770 | 1770 | * @return $field (array) |
1771 | 1771 | */ |
1772 | 1772 | |
1773 | -function acf_get_sub_field( $selector, $field ) { |
|
1773 | +function acf_get_sub_field($selector, $field) { |
|
1774 | 1774 | |
1775 | 1775 | // sub fields |
1776 | - if( $field['type'] == 'repeater' ) { |
|
1776 | + if ($field['type'] == 'repeater') { |
|
1777 | 1777 | |
1778 | 1778 | // extract sub fields |
1779 | - $sub_fields = acf_extract_var( $field, 'sub_fields'); |
|
1779 | + $sub_fields = acf_extract_var($field, 'sub_fields'); |
|
1780 | 1780 | |
1781 | - if( !empty($sub_fields) ) { |
|
1781 | + if ( ! empty($sub_fields)) { |
|
1782 | 1782 | |
1783 | - foreach( $sub_fields as $sub_field ) { |
|
1783 | + foreach ($sub_fields as $sub_field) { |
|
1784 | 1784 | |
1785 | - if( $sub_field['name'] == $selector || $sub_field['key'] == $selector ) { |
|
1785 | + if ($sub_field['name'] == $selector || $sub_field['key'] == $selector) { |
|
1786 | 1786 | |
1787 | 1787 | // return |
1788 | 1788 | return $sub_field; |
@@ -1796,19 +1796,19 @@ discard block |
||
1796 | 1796 | } |
1797 | 1797 | // if |
1798 | 1798 | |
1799 | - } elseif( $field['type'] == 'flexible_content' ) { |
|
1799 | + } elseif ($field['type'] == 'flexible_content') { |
|
1800 | 1800 | |
1801 | 1801 | // vars |
1802 | - $layouts = acf_extract_var( $field, 'layouts'); |
|
1802 | + $layouts = acf_extract_var($field, 'layouts'); |
|
1803 | 1803 | $current = get_row_layout(); |
1804 | 1804 | |
1805 | 1805 | |
1806 | - if( !empty($layouts) ) { |
|
1806 | + if ( ! empty($layouts)) { |
|
1807 | 1807 | |
1808 | - foreach( $layouts as $layout ) { |
|
1808 | + foreach ($layouts as $layout) { |
|
1809 | 1809 | |
1810 | 1810 | // skip layout if the current layout key does not match |
1811 | - if( $current && $current !== $layout['name'] ) { |
|
1811 | + if ($current && $current !== $layout['name']) { |
|
1812 | 1812 | |
1813 | 1813 | continue; |
1814 | 1814 | |
@@ -1816,13 +1816,13 @@ discard block |
||
1816 | 1816 | |
1817 | 1817 | |
1818 | 1818 | // extract sub fields |
1819 | - $sub_fields = acf_extract_var( $layout, 'sub_fields'); |
|
1819 | + $sub_fields = acf_extract_var($layout, 'sub_fields'); |
|
1820 | 1820 | |
1821 | - if( !empty($sub_fields) ) { |
|
1821 | + if ( ! empty($sub_fields)) { |
|
1822 | 1822 | |
1823 | - foreach( $sub_fields as $sub_field ) { |
|
1823 | + foreach ($sub_fields as $sub_field) { |
|
1824 | 1824 | |
1825 | - if( $sub_field['name'] == $selector || $sub_field['key'] == $selector ) { |
|
1825 | + if ($sub_field['name'] == $selector || $sub_field['key'] == $selector) { |
|
1826 | 1826 | |
1827 | 1827 | // return |
1828 | 1828 | return $sub_field; |