@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_oembed') ) : |
|
| 14 | +if ( ! class_exists('acf_field_oembed')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_oembed extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'oembed'; |
| 36 | - $this->label = __("oEmbed",'acf'); |
|
| 36 | + $this->label = __("oEmbed", 'acf'); |
|
| 37 | 37 | $this->category = 'content'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'width' => '', |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | // extra |
| 49 | - add_action('wp_ajax_acf/fields/oembed/search', array($this, 'ajax_search')); |
|
| 50 | - add_action('wp_ajax_nopriv_acf/fields/oembed/search', array($this, 'ajax_search')); |
|
| 49 | + add_action('wp_ajax_acf/fields/oembed/search', array($this, 'ajax_search')); |
|
| 50 | + add_action('wp_ajax_nopriv_acf/fields/oembed/search', array($this, 'ajax_search')); |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | // do not delete! |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return $post_id (int) |
| 70 | 70 | */ |
| 71 | 71 | |
| 72 | - function wp_oembed_get( $url = '', $width = 0, $height = 0 ) { |
|
| 72 | + function wp_oembed_get($url = '', $width = 0, $height = 0) { |
|
| 73 | 73 | |
| 74 | 74 | // vars |
| 75 | 75 | $embed = ''; |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | // get emebed |
| 83 | - $embed = @wp_oembed_get( $url, $res ); |
|
| 83 | + $embed = @wp_oembed_get($url, $res); |
|
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | // try shortcode |
| 87 | - if( !$embed ) { |
|
| 87 | + if ( ! $embed) { |
|
| 88 | 88 | |
| 89 | 89 | // global |
| 90 | 90 | global $wp_embed; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | function ajax_search() { |
| 118 | 118 | |
| 119 | 119 | // options |
| 120 | - $args = acf_parse_args( $_POST, array( |
|
| 120 | + $args = acf_parse_args($_POST, array( |
|
| 121 | 121 | 's' => '', |
| 122 | 122 | 'nonce' => '', |
| 123 | 123 | 'width' => 0, |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | |
| 128 | 128 | // width and height |
| 129 | - if( !$args['width'] ) { |
|
| 129 | + if ( ! $args['width']) { |
|
| 130 | 130 | |
| 131 | 131 | $args['width'] = $this->default_values['width']; |
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if( !$args['height'] ) { |
|
| 135 | + if ( ! $args['height']) { |
|
| 136 | 136 | |
| 137 | 137 | $args['height'] = $this->default_values['height']; |
| 138 | 138 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | // validate |
| 143 | - if( ! wp_verify_nonce($args['nonce'], 'acf_nonce') ) { |
|
| 143 | + if ( ! wp_verify_nonce($args['nonce'], 'acf_nonce')) { |
|
| 144 | 144 | |
| 145 | 145 | die(); |
| 146 | 146 | |
@@ -169,14 +169,14 @@ discard block |
||
| 169 | 169 | * @date 23/01/13 |
| 170 | 170 | */ |
| 171 | 171 | |
| 172 | - function render_field( $field ) { |
|
| 172 | + function render_field($field) { |
|
| 173 | 173 | |
| 174 | 174 | // default options |
| 175 | - foreach( $this->default_values as $k => $v ) { |
|
| 175 | + foreach ($this->default_values as $k => $v) { |
|
| 176 | 176 | |
| 177 | - if( empty($field[ $k ]) ) { |
|
| 177 | + if (empty($field[$k])) { |
|
| 178 | 178 | |
| 179 | - $field[ $k ] = $v; |
|
| 179 | + $field[$k] = $v; |
|
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | 'data-height' => $field['height'] |
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - if( $field['value'] ) { |
|
| 193 | + if ($field['value']) { |
|
| 194 | 194 | |
| 195 | 195 | $atts['class'] .= ' has-value'; |
| 196 | 196 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | </div> |
| 227 | 227 | |
| 228 | 228 | <div class="canvas-media" data-name="value-embed"> |
| 229 | - <?php if( !empty( $field['value'] ) ): ?> |
|
| 229 | + <?php if ( ! empty($field['value'])): ?> |
|
| 230 | 230 | <?php echo $this->wp_oembed_get($field['value'], $field['width'], $field['height']); ?> |
| 231 | 231 | <?php endif; ?> |
| 232 | 232 | </div> |
@@ -254,11 +254,11 @@ discard block |
||
| 254 | 254 | * @date 23/01/13 |
| 255 | 255 | */ |
| 256 | 256 | |
| 257 | - function render_field_settings( $field ) { |
|
| 257 | + function render_field_settings($field) { |
|
| 258 | 258 | |
| 259 | 259 | // width |
| 260 | - acf_render_field_setting( $field, array( |
|
| 261 | - 'label' => __('Embed Size','acf'), |
|
| 260 | + acf_render_field_setting($field, array( |
|
| 261 | + 'label' => __('Embed Size', 'acf'), |
|
| 262 | 262 | 'type' => 'text', |
| 263 | 263 | 'name' => 'width', |
| 264 | 264 | 'prepend' => __('Width', 'acf'), |
@@ -268,8 +268,8 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | |
| 270 | 270 | // height |
| 271 | - acf_render_field_setting( $field, array( |
|
| 272 | - 'label' => __('Embed Size','acf'), |
|
| 271 | + acf_render_field_setting($field, array( |
|
| 272 | + 'label' => __('Embed Size', 'acf'), |
|
| 273 | 273 | 'type' => 'text', |
| 274 | 274 | 'name' => 'height', |
| 275 | 275 | 'prepend' => __('Height', 'acf'), |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | * @return $value (mixed) the modified value |
| 300 | 300 | */ |
| 301 | 301 | |
| 302 | - function format_value( $value, $post_id, $field ) { |
|
| 302 | + function format_value($value, $post_id, $field) { |
|
| 303 | 303 | |
| 304 | 304 | // bail early if no value |
| 305 | - if( empty($value) ) { |
|
| 305 | + if (empty($value)) { |
|
| 306 | 306 | |
| 307 | 307 | return $value; |
| 308 | 308 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // do not delete! |
| 53 | - parent::__construct(); |
|
| 53 | + parent::__construct(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_page_link') ) : |
|
| 14 | +if ( ! class_exists('acf_field_page_link')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_page_link extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'page_link'; |
| 36 | - $this->label = __("Page Link",'acf'); |
|
| 36 | + $this->label = __("Page Link", 'acf'); |
|
| 37 | 37 | $this->category = 'relational'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'post_type' => array(), |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | // extra |
| 47 | - add_action('wp_ajax_acf/fields/page_link/query', array($this, 'ajax_query')); |
|
| 48 | - add_action('wp_ajax_nopriv_acf/fields/page_link/query', array($this, 'ajax_query')); |
|
| 47 | + add_action('wp_ajax_acf/fields/page_link/query', array($this, 'ajax_query')); |
|
| 48 | + add_action('wp_ajax_nopriv_acf/fields/page_link/query', array($this, 'ajax_query')); |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | // do not delete! |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @return (array) |
| 68 | 68 | */ |
| 69 | 69 | |
| 70 | - function get_choices( $options = array() ) { |
|
| 70 | + function get_choices($options = array()) { |
|
| 71 | 71 | |
| 72 | 72 | // defaults |
| 73 | 73 | $options = acf_parse_args($options, array( |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | // load field |
| 93 | - $field = acf_get_field( $options['field_key'] ); |
|
| 93 | + $field = acf_get_field($options['field_key']); |
|
| 94 | 94 | |
| 95 | - if( !$field ) { |
|
| 95 | + if ( ! $field) { |
|
| 96 | 96 | |
| 97 | 97 | return false; |
| 98 | 98 | |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | // update $args |
| 103 | - if( !empty($field['post_type']) ) { |
|
| 103 | + if ( ! empty($field['post_type'])) { |
|
| 104 | 104 | |
| 105 | - $args['post_type'] = acf_get_array( $field['post_type'] ); |
|
| 105 | + $args['post_type'] = acf_get_array($field['post_type']); |
|
| 106 | 106 | |
| 107 | 107 | } else { |
| 108 | 108 | |
@@ -111,18 +111,18 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // create tax queries |
| 114 | - if( !empty($field['taxonomy']) ) { |
|
| 114 | + if ( ! empty($field['taxonomy'])) { |
|
| 115 | 115 | |
| 116 | 116 | // append to $args |
| 117 | 117 | $args['tax_query'] = array(); |
| 118 | 118 | |
| 119 | 119 | |
| 120 | 120 | // decode terms |
| 121 | - $taxonomies = acf_decode_taxonomy_terms( $field['taxonomy'] ); |
|
| 121 | + $taxonomies = acf_decode_taxonomy_terms($field['taxonomy']); |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | // now create the tax queries |
| 125 | - foreach( $taxonomies as $taxonomy => $terms ) { |
|
| 125 | + foreach ($taxonomies as $taxonomy => $terms) { |
|
| 126 | 126 | |
| 127 | 127 | $args['tax_query'][] = array( |
| 128 | 128 | 'taxonomy' => $taxonomy, |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | // search |
| 138 | - if( $options['s'] ) { |
|
| 138 | + if ($options['s']) { |
|
| 139 | 139 | |
| 140 | 140 | $args['s'] = $options['s']; |
| 141 | 141 | |
@@ -144,12 +144,12 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | // filters |
| 146 | 146 | $args = apply_filters('acf/fields/page_link/query', $args, $field, $options['post_id']); |
| 147 | - $args = apply_filters('acf/fields/page_link/query/name=' . $field['name'], $args, $field, $options['post_id'] ); |
|
| 148 | - $args = apply_filters('acf/fields/page_link/query/key=' . $field['key'], $args, $field, $options['post_id'] ); |
|
| 147 | + $args = apply_filters('acf/fields/page_link/query/name='.$field['name'], $args, $field, $options['post_id']); |
|
| 148 | + $args = apply_filters('acf/fields/page_link/query/key='.$field['key'], $args, $field, $options['post_id']); |
|
| 149 | 149 | |
| 150 | 150 | |
| 151 | 151 | // add archives to $r |
| 152 | - if( $args['paged'] == 1 ) { |
|
| 152 | + if ($args['paged'] == 1) { |
|
| 153 | 153 | |
| 154 | 154 | $archives = array(); |
| 155 | 155 | $archives[] = array( |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | 'text' => home_url() |
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | - foreach( $args['post_type'] as $post_type ) { |
|
| 160 | + foreach ($args['post_type'] as $post_type) { |
|
| 161 | 161 | |
| 162 | - $archive_link = get_post_type_archive_link( $post_type ); |
|
| 162 | + $archive_link = get_post_type_archive_link($post_type); |
|
| 163 | 163 | |
| 164 | - if( $archive_link ) { |
|
| 164 | + if ($archive_link) { |
|
| 165 | 165 | |
| 166 | 166 | $archives[] = array( |
| 167 | 167 | 'id' => $archive_link, |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | // search |
| 177 | - if( !empty($args['s']) ) { |
|
| 177 | + if ( ! empty($args['s'])) { |
|
| 178 | 178 | |
| 179 | - foreach( array_keys($archives) as $i ) { |
|
| 179 | + foreach (array_keys($archives) as $i) { |
|
| 180 | 180 | |
| 181 | - if( strpos( $archives[$i]['text'], $args['s'] ) === false ) { |
|
| 181 | + if (strpos($archives[$i]['text'], $args['s']) === false) { |
|
| 182 | 182 | |
| 183 | 183 | unset($archives[$i]); |
| 184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
| 194 | - if( !empty($archives) ) { |
|
| 194 | + if ( ! empty($archives)) { |
|
| 195 | 195 | |
| 196 | 196 | $r[] = array( |
| 197 | 197 | 'text' => __('Archives', 'acf'), |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | |
| 206 | 206 | // get posts grouped by post type |
| 207 | - $groups = acf_get_grouped_posts( $args ); |
|
| 207 | + $groups = acf_get_grouped_posts($args); |
|
| 208 | 208 | |
| 209 | - if( !empty($groups) ) { |
|
| 209 | + if ( ! empty($groups)) { |
|
| 210 | 210 | |
| 211 | - foreach( array_keys($groups) as $group_title ) { |
|
| 211 | + foreach (array_keys($groups) as $group_title) { |
|
| 212 | 212 | |
| 213 | 213 | // vars |
| 214 | - $posts = acf_extract_var( $groups, $group_title ); |
|
| 214 | + $posts = acf_extract_var($groups, $group_title); |
|
| 215 | 215 | $titles = array(); |
| 216 | 216 | |
| 217 | 217 | |
@@ -222,28 +222,28 @@ discard block |
||
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | 224 | |
| 225 | - foreach( array_keys($posts) as $post_id ) { |
|
| 225 | + foreach (array_keys($posts) as $post_id) { |
|
| 226 | 226 | |
| 227 | 227 | // override data |
| 228 | - $posts[ $post_id ] = $this->get_post_title( $posts[ $post_id ], $field, $options['post_id'] ); |
|
| 228 | + $posts[$post_id] = $this->get_post_title($posts[$post_id], $field, $options['post_id']); |
|
| 229 | 229 | |
| 230 | 230 | }; |
| 231 | 231 | |
| 232 | 232 | |
| 233 | 233 | // order by search |
| 234 | - if( !empty($args['s']) ) { |
|
| 234 | + if ( ! empty($args['s'])) { |
|
| 235 | 235 | |
| 236 | - $posts = acf_order_by_search( $posts, $args['s'] ); |
|
| 236 | + $posts = acf_order_by_search($posts, $args['s']); |
|
| 237 | 237 | |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | |
| 241 | 241 | // append to $data |
| 242 | - foreach( array_keys($posts) as $post_id ) { |
|
| 242 | + foreach (array_keys($posts) as $post_id) { |
|
| 243 | 243 | |
| 244 | 244 | $data['children'][] = array( |
| 245 | 245 | 'id' => $post_id, |
| 246 | - 'text' => $posts[ $post_id ] |
|
| 246 | + 'text' => $posts[$post_id] |
|
| 247 | 247 | ); |
| 248 | 248 | |
| 249 | 249 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | function ajax_query() { |
| 280 | 280 | |
| 281 | 281 | // validate |
| 282 | - if( !acf_verify_ajax() ) { |
|
| 282 | + if ( ! acf_verify_ajax()) { |
|
| 283 | 283 | |
| 284 | 284 | die(); |
| 285 | 285 | |
@@ -287,11 +287,11 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | |
| 289 | 289 | // get choices |
| 290 | - $choices = $this->get_choices( $_POST ); |
|
| 290 | + $choices = $this->get_choices($_POST); |
|
| 291 | 291 | |
| 292 | 292 | |
| 293 | 293 | // validate |
| 294 | - if( !$choices ) { |
|
| 294 | + if ( ! $choices) { |
|
| 295 | 295 | |
| 296 | 296 | die(); |
| 297 | 297 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | |
| 301 | 301 | // return JSON |
| 302 | - echo json_encode( $choices ); |
|
| 302 | + echo json_encode($choices); |
|
| 303 | 303 | die(); |
| 304 | 304 | |
| 305 | 305 | } |
@@ -320,14 +320,14 @@ discard block |
||
| 320 | 320 | * @return (string) |
| 321 | 321 | */ |
| 322 | 322 | |
| 323 | - function get_post_title( $post, $field, $post_id = 0 ) { |
|
| 323 | + function get_post_title($post, $field, $post_id = 0) { |
|
| 324 | 324 | |
| 325 | 325 | // get post_id |
| 326 | - if( !$post_id ) { |
|
| 326 | + if ( ! $post_id) { |
|
| 327 | 327 | |
| 328 | 328 | $form_data = acf_get_setting('form_data'); |
| 329 | 329 | |
| 330 | - if( !empty($form_data['post_id']) ) { |
|
| 330 | + if ( ! empty($form_data['post_id'])) { |
|
| 331 | 331 | |
| 332 | 332 | $post_id = $form_data['post_id']; |
| 333 | 333 | |
@@ -341,13 +341,13 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | |
| 343 | 343 | // vars |
| 344 | - $title = acf_get_post_title( $post ); |
|
| 344 | + $title = acf_get_post_title($post); |
|
| 345 | 345 | |
| 346 | 346 | |
| 347 | 347 | // filters |
| 348 | 348 | $title = apply_filters('acf/fields/page_link/result', $title, $post, $field, $post_id); |
| 349 | - $title = apply_filters('acf/fields/page_link/result/name=' . $field['_name'], $title, $post, $field, $post_id); |
|
| 350 | - $title = apply_filters('acf/fields/page_link/result/key=' . $field['key'], $title, $post, $field, $post_id); |
|
| 349 | + $title = apply_filters('acf/fields/page_link/result/name='.$field['_name'], $title, $post, $field, $post_id); |
|
| 350 | + $title = apply_filters('acf/fields/page_link/result/key='.$field['key'], $title, $post, $field, $post_id); |
|
| 351 | 351 | |
| 352 | 352 | |
| 353 | 353 | // return |
@@ -368,18 +368,18 @@ discard block |
||
| 368 | 368 | * @return $value |
| 369 | 369 | */ |
| 370 | 370 | |
| 371 | - function get_posts( $value, $field ) { |
|
| 371 | + function get_posts($value, $field) { |
|
| 372 | 372 | |
| 373 | 373 | // force value to array |
| 374 | - $value = acf_get_array( $value ); |
|
| 374 | + $value = acf_get_array($value); |
|
| 375 | 375 | |
| 376 | 376 | |
| 377 | 377 | // get selected post ID's |
| 378 | 378 | $post__in = array(); |
| 379 | 379 | |
| 380 | - foreach( $value as $k => $v ) { |
|
| 380 | + foreach ($value as $k => $v) { |
|
| 381 | 381 | |
| 382 | - if( is_numeric($v) ) { |
|
| 382 | + if (is_numeric($v)) { |
|
| 383 | 383 | |
| 384 | 384 | // append to $post__in |
| 385 | 385 | $post__in[] = (int) $v; |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | |
| 392 | 392 | // bail early if no posts |
| 393 | - if( empty($post__in) ) { |
|
| 393 | + if (empty($post__in)) { |
|
| 394 | 394 | |
| 395 | 395 | return $value; |
| 396 | 396 | |
@@ -409,16 +409,16 @@ discard block |
||
| 409 | 409 | |
| 410 | 410 | |
| 411 | 411 | // append to $return |
| 412 | - foreach( $value as $k => $v ) { |
|
| 412 | + foreach ($value as $k => $v) { |
|
| 413 | 413 | |
| 414 | - if( is_numeric($v) ) { |
|
| 414 | + if (is_numeric($v)) { |
|
| 415 | 415 | |
| 416 | 416 | // extract first post |
| 417 | - $post = array_shift( $posts ); |
|
| 417 | + $post = array_shift($posts); |
|
| 418 | 418 | |
| 419 | 419 | |
| 420 | 420 | // append |
| 421 | - if( $post ) { |
|
| 421 | + if ($post) { |
|
| 422 | 422 | |
| 423 | 423 | $return[] = $post; |
| 424 | 424 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | * @date 23/01/13 |
| 452 | 452 | */ |
| 453 | 453 | |
| 454 | - function render_field( $field ){ |
|
| 454 | + function render_field($field) { |
|
| 455 | 455 | |
| 456 | 456 | // Change Field into a select |
| 457 | 457 | $field['type'] = 'select'; |
@@ -461,30 +461,30 @@ discard block |
||
| 461 | 461 | |
| 462 | 462 | |
| 463 | 463 | // populate choices if value exists |
| 464 | - if( !empty($field['value']) ) { |
|
| 464 | + if ( ! empty($field['value'])) { |
|
| 465 | 465 | |
| 466 | 466 | // get posts |
| 467 | - $posts = $this->get_posts( $field['value'], $field ); |
|
| 467 | + $posts = $this->get_posts($field['value'], $field); |
|
| 468 | 468 | |
| 469 | 469 | |
| 470 | 470 | // set choices |
| 471 | - if( !empty($posts) ) { |
|
| 471 | + if ( ! empty($posts)) { |
|
| 472 | 472 | |
| 473 | - foreach( array_keys($posts) as $i ) { |
|
| 473 | + foreach (array_keys($posts) as $i) { |
|
| 474 | 474 | |
| 475 | 475 | // vars |
| 476 | - $post = acf_extract_var( $posts, $i ); |
|
| 476 | + $post = acf_extract_var($posts, $i); |
|
| 477 | 477 | |
| 478 | 478 | |
| 479 | - if( is_object($post) ) { |
|
| 479 | + if (is_object($post)) { |
|
| 480 | 480 | |
| 481 | 481 | // append to choices |
| 482 | - $field['choices'][ $post->ID ] = $this->get_post_title( $post, $field ); |
|
| 482 | + $field['choices'][$post->ID] = $this->get_post_title($post, $field); |
|
| 483 | 483 | |
| 484 | 484 | } else { |
| 485 | 485 | |
| 486 | 486 | // append to choices |
| 487 | - $field['choices'][ $post ] = $post; |
|
| 487 | + $field['choices'][$post] = $post; |
|
| 488 | 488 | |
| 489 | 489 | } |
| 490 | 490 | |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | |
| 498 | 498 | // render |
| 499 | - acf_render_field( $field ); |
|
| 499 | + acf_render_field($field); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | |
@@ -513,11 +513,11 @@ discard block |
||
| 513 | 513 | * @param $field - an array holding all the field's data |
| 514 | 514 | */ |
| 515 | 515 | |
| 516 | - function render_field_settings( $field ) { |
|
| 516 | + function render_field_settings($field) { |
|
| 517 | 517 | |
| 518 | 518 | // post_type |
| 519 | - acf_render_field_setting( $field, array( |
|
| 520 | - 'label' => __('Filter by Post Type','acf'), |
|
| 519 | + acf_render_field_setting($field, array( |
|
| 520 | + 'label' => __('Filter by Post Type', 'acf'), |
|
| 521 | 521 | 'instructions' => '', |
| 522 | 522 | 'type' => 'select', |
| 523 | 523 | 'name' => 'post_type', |
@@ -525,13 +525,13 @@ discard block |
||
| 525 | 525 | 'multiple' => 1, |
| 526 | 526 | 'ui' => 1, |
| 527 | 527 | 'allow_null' => 1, |
| 528 | - 'placeholder' => __("All post types",'acf'), |
|
| 528 | + 'placeholder' => __("All post types", 'acf'), |
|
| 529 | 529 | )); |
| 530 | 530 | |
| 531 | 531 | |
| 532 | 532 | // taxonomy |
| 533 | - acf_render_field_setting( $field, array( |
|
| 534 | - 'label' => __('Filter by Taxonomy','acf'), |
|
| 533 | + acf_render_field_setting($field, array( |
|
| 534 | + 'label' => __('Filter by Taxonomy', 'acf'), |
|
| 535 | 535 | 'instructions' => '', |
| 536 | 536 | 'type' => 'select', |
| 537 | 537 | 'name' => 'taxonomy', |
@@ -539,33 +539,33 @@ discard block |
||
| 539 | 539 | 'multiple' => 1, |
| 540 | 540 | 'ui' => 1, |
| 541 | 541 | 'allow_null' => 1, |
| 542 | - 'placeholder' => __("All taxonomies",'acf'), |
|
| 542 | + 'placeholder' => __("All taxonomies", 'acf'), |
|
| 543 | 543 | )); |
| 544 | 544 | |
| 545 | 545 | |
| 546 | 546 | // allow_null |
| 547 | - acf_render_field_setting( $field, array( |
|
| 548 | - 'label' => __('Allow Null?','acf'), |
|
| 547 | + acf_render_field_setting($field, array( |
|
| 548 | + 'label' => __('Allow Null?', 'acf'), |
|
| 549 | 549 | 'instructions' => '', |
| 550 | 550 | 'type' => 'radio', |
| 551 | 551 | 'name' => 'allow_null', |
| 552 | 552 | 'choices' => array( |
| 553 | - 1 => __("Yes",'acf'), |
|
| 554 | - 0 => __("No",'acf'), |
|
| 553 | + 1 => __("Yes", 'acf'), |
|
| 554 | + 0 => __("No", 'acf'), |
|
| 555 | 555 | ), |
| 556 | 556 | 'layout' => 'horizontal', |
| 557 | 557 | )); |
| 558 | 558 | |
| 559 | 559 | |
| 560 | 560 | // multiple |
| 561 | - acf_render_field_setting( $field, array( |
|
| 562 | - 'label' => __('Select multiple values?','acf'), |
|
| 561 | + acf_render_field_setting($field, array( |
|
| 562 | + 'label' => __('Select multiple values?', 'acf'), |
|
| 563 | 563 | 'instructions' => '', |
| 564 | 564 | 'type' => 'radio', |
| 565 | 565 | 'name' => 'multiple', |
| 566 | 566 | 'choices' => array( |
| 567 | - 1 => __("Yes",'acf'), |
|
| 568 | - 0 => __("No",'acf'), |
|
| 567 | + 1 => __("Yes", 'acf'), |
|
| 568 | + 0 => __("No", 'acf'), |
|
| 569 | 569 | ), |
| 570 | 570 | 'layout' => 'horizontal', |
| 571 | 571 | )); |
@@ -589,10 +589,10 @@ discard block |
||
| 589 | 589 | * @return $value (mixed) the modified value |
| 590 | 590 | */ |
| 591 | 591 | |
| 592 | - function format_value( $value, $post_id, $field ) { |
|
| 592 | + function format_value($value, $post_id, $field) { |
|
| 593 | 593 | |
| 594 | 594 | // ACF4 null |
| 595 | - if( $value === 'null' ) { |
|
| 595 | + if ($value === 'null') { |
|
| 596 | 596 | |
| 597 | 597 | return false; |
| 598 | 598 | |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | |
| 601 | 601 | |
| 602 | 602 | // bail early if no value |
| 603 | - if( empty($value) ) { |
|
| 603 | + if (empty($value)) { |
|
| 604 | 604 | |
| 605 | 605 | return $value; |
| 606 | 606 | |
@@ -608,32 +608,32 @@ discard block |
||
| 608 | 608 | |
| 609 | 609 | |
| 610 | 610 | // get posts |
| 611 | - $value = $this->get_posts( $value, $field ); |
|
| 611 | + $value = $this->get_posts($value, $field); |
|
| 612 | 612 | |
| 613 | 613 | |
| 614 | 614 | // set choices |
| 615 | - foreach( array_keys($value) as $i ) { |
|
| 615 | + foreach (array_keys($value) as $i) { |
|
| 616 | 616 | |
| 617 | 617 | // vars |
| 618 | - $post = acf_extract_var( $value, $i ); |
|
| 618 | + $post = acf_extract_var($value, $i); |
|
| 619 | 619 | |
| 620 | 620 | |
| 621 | 621 | // convert $post to permalink |
| 622 | - if( is_object($post) ) { |
|
| 622 | + if (is_object($post)) { |
|
| 623 | 623 | |
| 624 | - $post = get_permalink( $post ); |
|
| 624 | + $post = get_permalink($post); |
|
| 625 | 625 | |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | |
| 629 | 629 | // append back to $value |
| 630 | - $value[ $i ] = $post; |
|
| 630 | + $value[$i] = $post; |
|
| 631 | 631 | |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | |
| 635 | 635 | // convert back from array if neccessary |
| 636 | - if( !$field['multiple'] ) { |
|
| 636 | + if ( ! $field['multiple']) { |
|
| 637 | 637 | |
| 638 | 638 | $value = array_shift($value); |
| 639 | 639 | |
@@ -662,10 +662,10 @@ discard block |
||
| 662 | 662 | * @return $value - the modified value |
| 663 | 663 | */ |
| 664 | 664 | |
| 665 | - function update_value( $value, $post_id, $field ) { |
|
| 665 | + function update_value($value, $post_id, $field) { |
|
| 666 | 666 | |
| 667 | 667 | // validate |
| 668 | - if( empty($value) ) { |
|
| 668 | + if (empty($value)) { |
|
| 669 | 669 | |
| 670 | 670 | return $value; |
| 671 | 671 | |
@@ -673,15 +673,15 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | |
| 675 | 675 | // format |
| 676 | - if( is_array($value) ) { |
|
| 676 | + if (is_array($value)) { |
|
| 677 | 677 | |
| 678 | 678 | // array |
| 679 | - foreach( $value as $k => $v ){ |
|
| 679 | + foreach ($value as $k => $v) { |
|
| 680 | 680 | |
| 681 | 681 | // object? |
| 682 | - if( is_object($v) && isset($v->ID) ) |
|
| 682 | + if (is_object($v) && isset($v->ID)) |
|
| 683 | 683 | { |
| 684 | - $value[ $k ] = $v->ID; |
|
| 684 | + $value[$k] = $v->ID; |
|
| 685 | 685 | } |
| 686 | 686 | } |
| 687 | 687 | |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | // save value as strings, so we can clearly search for them in SQL LIKE statements |
| 690 | 690 | $value = array_map('strval', $value); |
| 691 | 691 | |
| 692 | - } elseif( is_object($value) && isset($value->ID) ) { |
|
| 692 | + } elseif (is_object($value) && isset($value->ID)) { |
|
| 693 | 693 | |
| 694 | 694 | // object |
| 695 | 695 | $value = $value->ID; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // do not delete! |
| 53 | - parent::__construct(); |
|
| 53 | + parent::__construct(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_password') ) : |
|
| 14 | +if ( ! class_exists('acf_field_password')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_password extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'password'; |
| 36 | - $this->label = __("Password",'acf'); |
|
| 36 | + $this->label = __("Password", 'acf'); |
|
| 37 | 37 | $this->defaults = array( |
| 38 | 38 | 'placeholder' => '', |
| 39 | 39 | 'prepend' => '', |
@@ -60,46 +60,46 @@ discard block |
||
| 60 | 60 | * @date 23/01/13 |
| 61 | 61 | */ |
| 62 | 62 | |
| 63 | - function render_field( $field ) { |
|
| 63 | + function render_field($field) { |
|
| 64 | 64 | |
| 65 | 65 | // vars |
| 66 | - $o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' ); |
|
| 66 | + $o = array('type', 'id', 'class', 'name', 'value', 'placeholder'); |
|
| 67 | 67 | $e = ''; |
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | // prepend |
| 71 | - if( $field['prepend'] !== "" ) { |
|
| 71 | + if ($field['prepend'] !== "") { |
|
| 72 | 72 | |
| 73 | 73 | $field['class'] .= ' acf-is-prepended'; |
| 74 | - $e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>'; |
|
| 74 | + $e .= '<div class="acf-input-prepend">'.$field['prepend'].'</div>'; |
|
| 75 | 75 | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | // append |
| 80 | - if( $field['append'] !== "" ) { |
|
| 80 | + if ($field['append'] !== "") { |
|
| 81 | 81 | |
| 82 | 82 | $field['class'] .= ' acf-is-appended'; |
| 83 | - $e .= '<div class="acf-input-append">' . $field['append'] . '</div>'; |
|
| 83 | + $e .= '<div class="acf-input-append">'.$field['append'].'</div>'; |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | // populate atts |
| 89 | 89 | $atts = array(); |
| 90 | - foreach( $o as $k ) { |
|
| 90 | + foreach ($o as $k) { |
|
| 91 | 91 | |
| 92 | - $atts[ $k ] = $field[ $k ]; |
|
| 92 | + $atts[$k] = $field[$k]; |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
| 97 | 97 | // special atts |
| 98 | - foreach( array( 'readonly', 'disabled' ) as $k ) { |
|
| 98 | + foreach (array('readonly', 'disabled') as $k) { |
|
| 99 | 99 | |
| 100 | - if( $field[ $k ] ) { |
|
| 100 | + if ($field[$k]) { |
|
| 101 | 101 | |
| 102 | - $atts[ $k ] = $k; |
|
| 102 | + $atts[$k] = $k; |
|
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // render |
| 110 | 110 | $e .= '<div class="acf-input-wrap">'; |
| 111 | - $e .= '<input ' . acf_esc_attr( $atts ) . ' />'; |
|
| 111 | + $e .= '<input '.acf_esc_attr($atts).' />'; |
|
| 112 | 112 | $e .= '</div>'; |
| 113 | 113 | |
| 114 | 114 | |
@@ -130,30 +130,30 @@ discard block |
||
| 130 | 130 | * @param $field - an array holding all the field's data |
| 131 | 131 | */ |
| 132 | 132 | |
| 133 | - function render_field_settings( $field ) { |
|
| 133 | + function render_field_settings($field) { |
|
| 134 | 134 | |
| 135 | 135 | // placeholder |
| 136 | - acf_render_field_setting( $field, array( |
|
| 137 | - 'label' => __('Placeholder Text','acf'), |
|
| 138 | - 'instructions' => __('Appears within the input','acf'), |
|
| 136 | + acf_render_field_setting($field, array( |
|
| 137 | + 'label' => __('Placeholder Text', 'acf'), |
|
| 138 | + 'instructions' => __('Appears within the input', 'acf'), |
|
| 139 | 139 | 'type' => 'text', |
| 140 | 140 | 'name' => 'placeholder', |
| 141 | 141 | )); |
| 142 | 142 | |
| 143 | 143 | |
| 144 | 144 | // prepend |
| 145 | - acf_render_field_setting( $field, array( |
|
| 146 | - 'label' => __('Prepend','acf'), |
|
| 147 | - 'instructions' => __('Appears before the input','acf'), |
|
| 145 | + acf_render_field_setting($field, array( |
|
| 146 | + 'label' => __('Prepend', 'acf'), |
|
| 147 | + 'instructions' => __('Appears before the input', 'acf'), |
|
| 148 | 148 | 'type' => 'text', |
| 149 | 149 | 'name' => 'prepend', |
| 150 | 150 | )); |
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | // append |
| 154 | - acf_render_field_setting( $field, array( |
|
| 155 | - 'label' => __('Append','acf'), |
|
| 156 | - 'instructions' => __('Appears after the input','acf'), |
|
| 154 | + acf_render_field_setting($field, array( |
|
| 155 | + 'label' => __('Append', 'acf'), |
|
| 156 | + 'instructions' => __('Appears after the input', 'acf'), |
|
| 157 | 157 | 'type' => 'text', |
| 158 | 158 | 'name' => 'append', |
| 159 | 159 | )); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // do not delete! |
| 53 | - parent::__construct(); |
|
| 53 | + parent::__construct(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_post_object') ) : |
|
| 14 | +if ( ! class_exists('acf_field_post_object')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_post_object extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'post_object'; |
| 36 | - $this->label = __("Post Object",'acf'); |
|
| 36 | + $this->label = __("Post Object", 'acf'); |
|
| 37 | 37 | $this->category = 'relational'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'post_type' => array(), |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | // extra |
| 49 | - add_action('wp_ajax_acf/fields/post_object/query', array($this, 'ajax_query')); |
|
| 50 | - add_action('wp_ajax_nopriv_acf/fields/post_object/query', array($this, 'ajax_query')); |
|
| 49 | + add_action('wp_ajax_acf/fields/post_object/query', array($this, 'ajax_query')); |
|
| 50 | + add_action('wp_ajax_nopriv_acf/fields/post_object/query', array($this, 'ajax_query')); |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | // do not delete! |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return (array) |
| 70 | 70 | */ |
| 71 | 71 | |
| 72 | - function get_choices( $options = array() ) { |
|
| 72 | + function get_choices($options = array()) { |
|
| 73 | 73 | |
| 74 | 74 | // defaults |
| 75 | 75 | $options = acf_parse_args($options, array( |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | |
| 93 | 93 | // load field |
| 94 | - $field = acf_get_field( $options['field_key'] ); |
|
| 94 | + $field = acf_get_field($options['field_key']); |
|
| 95 | 95 | |
| 96 | - if( !$field ) { |
|
| 96 | + if ( ! $field) { |
|
| 97 | 97 | |
| 98 | 98 | return false; |
| 99 | 99 | |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | // update $args |
| 104 | - if( !empty($field['post_type']) ) { |
|
| 104 | + if ( ! empty($field['post_type'])) { |
|
| 105 | 105 | |
| 106 | - $args['post_type'] = acf_get_array( $field['post_type'] ); |
|
| 106 | + $args['post_type'] = acf_get_array($field['post_type']); |
|
| 107 | 107 | |
| 108 | 108 | } else { |
| 109 | 109 | |
@@ -113,18 +113,18 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | // create tax queries |
| 116 | - if( !empty($field['taxonomy']) ) { |
|
| 116 | + if ( ! empty($field['taxonomy'])) { |
|
| 117 | 117 | |
| 118 | 118 | // append to $args |
| 119 | 119 | $args['tax_query'] = array(); |
| 120 | 120 | |
| 121 | 121 | |
| 122 | 122 | // decode terms |
| 123 | - $taxonomies = acf_decode_taxonomy_terms( $field['taxonomy'] ); |
|
| 123 | + $taxonomies = acf_decode_taxonomy_terms($field['taxonomy']); |
|
| 124 | 124 | |
| 125 | 125 | |
| 126 | 126 | // now create the tax queries |
| 127 | - foreach( $taxonomies as $taxonomy => $terms ) { |
|
| 127 | + foreach ($taxonomies as $taxonomy => $terms) { |
|
| 128 | 128 | |
| 129 | 129 | $args['tax_query'][] = array( |
| 130 | 130 | 'taxonomy' => $taxonomy, |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | // search |
| 141 | - if( $options['s'] ) { |
|
| 141 | + if ($options['s']) { |
|
| 142 | 142 | |
| 143 | 143 | $args['s'] = $options['s']; |
| 144 | 144 | |
@@ -147,19 +147,19 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | // filters |
| 149 | 149 | $args = apply_filters('acf/fields/post_object/query', $args, $field, $options['post_id']); |
| 150 | - $args = apply_filters('acf/fields/post_object/query/name=' . $field['name'], $args, $field, $options['post_id'] ); |
|
| 151 | - $args = apply_filters('acf/fields/post_object/query/key=' . $field['key'], $args, $field, $options['post_id'] ); |
|
| 150 | + $args = apply_filters('acf/fields/post_object/query/name='.$field['name'], $args, $field, $options['post_id']); |
|
| 151 | + $args = apply_filters('acf/fields/post_object/query/key='.$field['key'], $args, $field, $options['post_id']); |
|
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | // get posts grouped by post type |
| 155 | - $groups = acf_get_grouped_posts( $args ); |
|
| 155 | + $groups = acf_get_grouped_posts($args); |
|
| 156 | 156 | |
| 157 | - if( !empty($groups) ) { |
|
| 157 | + if ( ! empty($groups)) { |
|
| 158 | 158 | |
| 159 | - foreach( array_keys($groups) as $group_title ) { |
|
| 159 | + foreach (array_keys($groups) as $group_title) { |
|
| 160 | 160 | |
| 161 | 161 | // vars |
| 162 | - $posts = acf_extract_var( $groups, $group_title ); |
|
| 162 | + $posts = acf_extract_var($groups, $group_title); |
|
| 163 | 163 | $titles = array(); |
| 164 | 164 | |
| 165 | 165 | |
@@ -170,28 +170,28 @@ discard block |
||
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | |
| 173 | - foreach( array_keys($posts) as $post_id ) { |
|
| 173 | + foreach (array_keys($posts) as $post_id) { |
|
| 174 | 174 | |
| 175 | 175 | // override data |
| 176 | - $posts[ $post_id ] = $this->get_post_title( $posts[ $post_id ], $field, $options['post_id'] ); |
|
| 176 | + $posts[$post_id] = $this->get_post_title($posts[$post_id], $field, $options['post_id']); |
|
| 177 | 177 | |
| 178 | 178 | }; |
| 179 | 179 | |
| 180 | 180 | |
| 181 | 181 | // order by search |
| 182 | - if( !empty($args['s']) ) { |
|
| 182 | + if ( ! empty($args['s'])) { |
|
| 183 | 183 | |
| 184 | - $posts = acf_order_by_search( $posts, $args['s'] ); |
|
| 184 | + $posts = acf_order_by_search($posts, $args['s']); |
|
| 185 | 185 | |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | // append to $data |
| 190 | - foreach( array_keys($posts) as $post_id ) { |
|
| 190 | + foreach (array_keys($posts) as $post_id) { |
|
| 191 | 191 | |
| 192 | 192 | $data['children'][] = array( |
| 193 | 193 | 'id' => $post_id, |
| 194 | - 'text' => $posts[ $post_id ] |
|
| 194 | + 'text' => $posts[$post_id] |
|
| 195 | 195 | ); |
| 196 | 196 | |
| 197 | 197 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | |
| 206 | 206 | // optgroup or single |
| 207 | - if( count($args['post_type']) == 1 ) { |
|
| 207 | + if (count($args['post_type']) == 1) { |
|
| 208 | 208 | |
| 209 | 209 | $r = $r[0]['children']; |
| 210 | 210 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | function ajax_query() { |
| 236 | 236 | |
| 237 | 237 | // validate |
| 238 | - if( !acf_verify_ajax() ) { |
|
| 238 | + if ( ! acf_verify_ajax()) { |
|
| 239 | 239 | |
| 240 | 240 | die(); |
| 241 | 241 | |
@@ -243,11 +243,11 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | |
| 245 | 245 | // get choices |
| 246 | - $choices = $this->get_choices( $_POST ); |
|
| 246 | + $choices = $this->get_choices($_POST); |
|
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | // validate |
| 250 | - if( !$choices ) { |
|
| 250 | + if ( ! $choices) { |
|
| 251 | 251 | |
| 252 | 252 | die(); |
| 253 | 253 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | |
| 257 | 257 | // return JSON |
| 258 | - echo json_encode( $choices ); |
|
| 258 | + echo json_encode($choices); |
|
| 259 | 259 | die(); |
| 260 | 260 | |
| 261 | 261 | } |
@@ -276,14 +276,14 @@ discard block |
||
| 276 | 276 | * @return (string) |
| 277 | 277 | */ |
| 278 | 278 | |
| 279 | - function get_post_title( $post, $field, $post_id = 0 ) { |
|
| 279 | + function get_post_title($post, $field, $post_id = 0) { |
|
| 280 | 280 | |
| 281 | 281 | // get post_id |
| 282 | - if( !$post_id ) { |
|
| 282 | + if ( ! $post_id) { |
|
| 283 | 283 | |
| 284 | 284 | $form_data = acf_get_setting('form_data'); |
| 285 | 285 | |
| 286 | - if( !empty($form_data['post_id']) ) { |
|
| 286 | + if ( ! empty($form_data['post_id'])) { |
|
| 287 | 287 | |
| 288 | 288 | $post_id = $form_data['post_id']; |
| 289 | 289 | |
@@ -297,13 +297,13 @@ discard block |
||
| 297 | 297 | |
| 298 | 298 | |
| 299 | 299 | // vars |
| 300 | - $title = acf_get_post_title( $post ); |
|
| 300 | + $title = acf_get_post_title($post); |
|
| 301 | 301 | |
| 302 | 302 | |
| 303 | 303 | // filters |
| 304 | 304 | $title = apply_filters('acf/fields/post_object/result', $title, $post, $field, $post_id); |
| 305 | - $title = apply_filters('acf/fields/post_object/result/name=' . $field['_name'], $title, $post, $field, $post_id); |
|
| 306 | - $title = apply_filters('acf/fields/post_object/result/key=' . $field['key'], $title, $post, $field, $post_id); |
|
| 305 | + $title = apply_filters('acf/fields/post_object/result/name='.$field['_name'], $title, $post, $field, $post_id); |
|
| 306 | + $title = apply_filters('acf/fields/post_object/result/key='.$field['key'], $title, $post, $field, $post_id); |
|
| 307 | 307 | |
| 308 | 308 | |
| 309 | 309 | // return |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @date 23/01/13 |
| 324 | 324 | */ |
| 325 | 325 | |
| 326 | - function render_field( $field ) { |
|
| 326 | + function render_field($field) { |
|
| 327 | 327 | |
| 328 | 328 | // Change Field into a select |
| 329 | 329 | $field['type'] = 'select'; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | |
| 335 | 335 | // populate choices if value exists |
| 336 | - if( !empty($field['value']) ) { |
|
| 336 | + if ( ! empty($field['value'])) { |
|
| 337 | 337 | |
| 338 | 338 | // get posts |
| 339 | 339 | $posts = acf_get_posts(array( |
@@ -343,16 +343,16 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | |
| 345 | 345 | // set choices |
| 346 | - if( !empty($posts) ) { |
|
| 346 | + if ( ! empty($posts)) { |
|
| 347 | 347 | |
| 348 | - foreach( array_keys($posts) as $i ) { |
|
| 348 | + foreach (array_keys($posts) as $i) { |
|
| 349 | 349 | |
| 350 | 350 | // vars |
| 351 | - $post = acf_extract_var( $posts, $i ); |
|
| 351 | + $post = acf_extract_var($posts, $i); |
|
| 352 | 352 | |
| 353 | 353 | |
| 354 | 354 | // append to choices |
| 355 | - $field['choices'][ $post->ID ] = $this->get_post_title( $post, $field ); |
|
| 355 | + $field['choices'][$post->ID] = $this->get_post_title($post, $field); |
|
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | |
| 364 | 364 | // render |
| 365 | - acf_render_field( $field ); |
|
| 365 | + acf_render_field($field); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | |
@@ -379,11 +379,11 @@ discard block |
||
| 379 | 379 | * @param $field - an array holding all the field's data |
| 380 | 380 | */ |
| 381 | 381 | |
| 382 | - function render_field_settings( $field ) { |
|
| 382 | + function render_field_settings($field) { |
|
| 383 | 383 | |
| 384 | 384 | // default_value |
| 385 | - acf_render_field_setting( $field, array( |
|
| 386 | - 'label' => __('Filter by Post Type','acf'), |
|
| 385 | + acf_render_field_setting($field, array( |
|
| 386 | + 'label' => __('Filter by Post Type', 'acf'), |
|
| 387 | 387 | 'instructions' => '', |
| 388 | 388 | 'type' => 'select', |
| 389 | 389 | 'name' => 'post_type', |
@@ -391,13 +391,13 @@ discard block |
||
| 391 | 391 | 'multiple' => 1, |
| 392 | 392 | 'ui' => 1, |
| 393 | 393 | 'allow_null' => 1, |
| 394 | - 'placeholder' => __("All post types",'acf'), |
|
| 394 | + 'placeholder' => __("All post types", 'acf'), |
|
| 395 | 395 | )); |
| 396 | 396 | |
| 397 | 397 | |
| 398 | 398 | // default_value |
| 399 | - acf_render_field_setting( $field, array( |
|
| 400 | - 'label' => __('Filter by Taxonomy','acf'), |
|
| 399 | + acf_render_field_setting($field, array( |
|
| 400 | + 'label' => __('Filter by Taxonomy', 'acf'), |
|
| 401 | 401 | 'instructions' => '', |
| 402 | 402 | 'type' => 'select', |
| 403 | 403 | 'name' => 'taxonomy', |
@@ -405,47 +405,47 @@ discard block |
||
| 405 | 405 | 'multiple' => 1, |
| 406 | 406 | 'ui' => 1, |
| 407 | 407 | 'allow_null' => 1, |
| 408 | - 'placeholder' => __("All taxonomies",'acf'), |
|
| 408 | + 'placeholder' => __("All taxonomies", 'acf'), |
|
| 409 | 409 | )); |
| 410 | 410 | |
| 411 | 411 | |
| 412 | 412 | // allow_null |
| 413 | - acf_render_field_setting( $field, array( |
|
| 414 | - 'label' => __('Allow Null?','acf'), |
|
| 413 | + acf_render_field_setting($field, array( |
|
| 414 | + 'label' => __('Allow Null?', 'acf'), |
|
| 415 | 415 | 'instructions' => '', |
| 416 | 416 | 'type' => 'radio', |
| 417 | 417 | 'name' => 'allow_null', |
| 418 | 418 | 'choices' => array( |
| 419 | - 1 => __("Yes",'acf'), |
|
| 420 | - 0 => __("No",'acf'), |
|
| 419 | + 1 => __("Yes", 'acf'), |
|
| 420 | + 0 => __("No", 'acf'), |
|
| 421 | 421 | ), |
| 422 | 422 | 'layout' => 'horizontal', |
| 423 | 423 | )); |
| 424 | 424 | |
| 425 | 425 | |
| 426 | 426 | // multiple |
| 427 | - acf_render_field_setting( $field, array( |
|
| 428 | - 'label' => __('Select multiple values?','acf'), |
|
| 427 | + acf_render_field_setting($field, array( |
|
| 428 | + 'label' => __('Select multiple values?', 'acf'), |
|
| 429 | 429 | 'instructions' => '', |
| 430 | 430 | 'type' => 'radio', |
| 431 | 431 | 'name' => 'multiple', |
| 432 | 432 | 'choices' => array( |
| 433 | - 1 => __("Yes",'acf'), |
|
| 434 | - 0 => __("No",'acf'), |
|
| 433 | + 1 => __("Yes", 'acf'), |
|
| 434 | + 0 => __("No", 'acf'), |
|
| 435 | 435 | ), |
| 436 | 436 | 'layout' => 'horizontal', |
| 437 | 437 | )); |
| 438 | 438 | |
| 439 | 439 | |
| 440 | 440 | // return_format |
| 441 | - acf_render_field_setting( $field, array( |
|
| 442 | - 'label' => __('Return Format','acf'), |
|
| 441 | + acf_render_field_setting($field, array( |
|
| 442 | + 'label' => __('Return Format', 'acf'), |
|
| 443 | 443 | 'instructions' => '', |
| 444 | 444 | 'type' => 'radio', |
| 445 | 445 | 'name' => 'return_format', |
| 446 | 446 | 'choices' => array( |
| 447 | - 'object' => __("Post Object",'acf'), |
|
| 448 | - 'id' => __("Post ID",'acf'), |
|
| 447 | + 'object' => __("Post Object", 'acf'), |
|
| 448 | + 'id' => __("Post ID", 'acf'), |
|
| 449 | 449 | ), |
| 450 | 450 | 'layout' => 'horizontal', |
| 451 | 451 | )); |
@@ -468,10 +468,10 @@ discard block |
||
| 468 | 468 | * @return $value |
| 469 | 469 | */ |
| 470 | 470 | |
| 471 | - function load_value( $value, $post_id, $field ) { |
|
| 471 | + function load_value($value, $post_id, $field) { |
|
| 472 | 472 | |
| 473 | 473 | // ACF4 null |
| 474 | - if( $value === 'null' ) { |
|
| 474 | + if ($value === 'null') { |
|
| 475 | 475 | |
| 476 | 476 | return false; |
| 477 | 477 | |
@@ -499,10 +499,10 @@ discard block |
||
| 499 | 499 | * @return $value (mixed) the modified value |
| 500 | 500 | */ |
| 501 | 501 | |
| 502 | - function format_value( $value, $post_id, $field ) { |
|
| 502 | + function format_value($value, $post_id, $field) { |
|
| 503 | 503 | |
| 504 | 504 | // bail early if no value |
| 505 | - if( empty($value) ) { |
|
| 505 | + if (empty($value)) { |
|
| 506 | 506 | |
| 507 | 507 | return $value; |
| 508 | 508 | |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | |
| 511 | 511 | |
| 512 | 512 | // force value to array |
| 513 | - $value = acf_get_array( $value ); |
|
| 513 | + $value = acf_get_array($value); |
|
| 514 | 514 | |
| 515 | 515 | |
| 516 | 516 | // convert values to int |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | |
| 519 | 519 | |
| 520 | 520 | // load posts if needed |
| 521 | - if( $field['return_format'] == 'object' ) { |
|
| 521 | + if ($field['return_format'] == 'object') { |
|
| 522 | 522 | |
| 523 | 523 | // get posts |
| 524 | 524 | $value = acf_get_posts(array( |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | |
| 532 | 532 | // convert back from array if neccessary |
| 533 | - if( !$field['multiple'] ) { |
|
| 533 | + if ( ! $field['multiple']) { |
|
| 534 | 534 | |
| 535 | 535 | $value = array_shift($value); |
| 536 | 536 | |
@@ -559,10 +559,10 @@ discard block |
||
| 559 | 559 | * @return $value - the modified value |
| 560 | 560 | */ |
| 561 | 561 | |
| 562 | - function update_value( $value, $post_id, $field ) { |
|
| 562 | + function update_value($value, $post_id, $field) { |
|
| 563 | 563 | |
| 564 | 564 | // validate |
| 565 | - if( empty($value) ) { |
|
| 565 | + if (empty($value)) { |
|
| 566 | 566 | |
| 567 | 567 | return $value; |
| 568 | 568 | |
@@ -570,15 +570,15 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | |
| 572 | 572 | // format |
| 573 | - if( is_array($value) ) { |
|
| 573 | + if (is_array($value)) { |
|
| 574 | 574 | |
| 575 | 575 | // array |
| 576 | - foreach( $value as $k => $v ){ |
|
| 576 | + foreach ($value as $k => $v) { |
|
| 577 | 577 | |
| 578 | 578 | // object? |
| 579 | - if( is_object($v) && isset($v->ID) ) { |
|
| 579 | + if (is_object($v) && isset($v->ID)) { |
|
| 580 | 580 | |
| 581 | - $value[ $k ] = $v->ID; |
|
| 581 | + $value[$k] = $v->ID; |
|
| 582 | 582 | |
| 583 | 583 | } |
| 584 | 584 | |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | // save value as strings, so we can clearly search for them in SQL LIKE statements |
| 589 | 589 | $value = array_map('strval', $value); |
| 590 | 590 | |
| 591 | - } elseif( is_object($value) && isset($value->ID) ) { |
|
| 591 | + } elseif (is_object($value) && isset($value->ID)) { |
|
| 592 | 592 | |
| 593 | 593 | // object |
| 594 | 594 | $value = $value->ID; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // do not delete! |
| 53 | - parent::__construct(); |
|
| 53 | + parent::__construct(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_radio') ) : |
|
| 14 | +if ( ! class_exists('acf_field_radio')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_radio extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'radio'; |
| 36 | - $this->label = __("Radio Button",'acf'); |
|
| 36 | + $this->label = __("Radio Button", 'acf'); |
|
| 37 | 37 | $this->category = 'choice'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'layout' => 'vertical', |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @return n/a |
| 66 | 66 | */ |
| 67 | 67 | |
| 68 | - function render_field( $field ) { |
|
| 68 | + function render_field($field) { |
|
| 69 | 69 | |
| 70 | 70 | // vars |
| 71 | 71 | $i = 0; |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | // e |
| 81 | - $e = '<ul ' . acf_esc_attr(array( 'class' => $field['class'] )) . '>'; |
|
| 81 | + $e = '<ul '.acf_esc_attr(array('class' => $field['class'])).'>'; |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | // other choice |
| 85 | - if( $field['other_choice'] ) { |
|
| 85 | + if ($field['other_choice']) { |
|
| 86 | 86 | |
| 87 | 87 | // vars |
| 88 | 88 | $input = array( |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | // select other choice if value is not a valid choice |
| 97 | - if( !isset($field['choices'][ $field['value'] ]) ) { |
|
| 97 | + if ( ! isset($field['choices'][$field['value']])) { |
|
| 98 | 98 | |
| 99 | 99 | unset($input['disabled']); |
| 100 | 100 | $input['value'] = $field['value']; |
@@ -103,16 +103,16 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
| 106 | - $field['choices']['other'] = '</label><input type="text" ' . acf_esc_attr($input) . ' /><label>'; |
|
| 106 | + $field['choices']['other'] = '</label><input type="text" '.acf_esc_attr($input).' /><label>'; |
|
| 107 | 107 | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | // require choices |
| 112 | - if( !empty($field['choices']) ) { |
|
| 112 | + if ( ! empty($field['choices'])) { |
|
| 113 | 113 | |
| 114 | 114 | // select first choice if value is not a valid choice |
| 115 | - if( !isset($field['choices'][ $field['value'] ]) ) { |
|
| 115 | + if ( ! isset($field['choices'][$field['value']])) { |
|
| 116 | 116 | |
| 117 | 117 | $field['value'] = key($field['choices']); |
| 118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | |
| 122 | 122 | // foreach choices |
| 123 | - foreach( $field['choices'] as $value => $label ) { |
|
| 123 | + foreach ($field['choices'] as $value => $label) { |
|
| 124 | 124 | |
| 125 | 125 | // increase counter |
| 126 | 126 | $i++; |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | 137 | |
| 138 | - if( strval($value) === strval($field['value']) ) { |
|
| 138 | + if (strval($value) === strval($field['value'])) { |
|
| 139 | 139 | |
| 140 | 140 | $atts['checked'] = 'checked'; |
| 141 | 141 | $checked = true; |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if( isset($field['disabled']) && acf_in_array($value, $field['disabled']) ) { |
|
| 145 | + if (isset($field['disabled']) && acf_in_array($value, $field['disabled'])) { |
|
| 146 | 146 | |
| 147 | 147 | $atts['disabled'] = 'disabled'; |
| 148 | 148 | |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | // each input ID is generated with the $key, however, the first input must not use $key so that it matches the field's label for attribute |
| 153 | - if( $i > 1 ) { |
|
| 153 | + if ($i > 1) { |
|
| 154 | 154 | |
| 155 | - $atts['id'] .= '-' . $value; |
|
| 155 | + $atts['id'] .= '-'.$value; |
|
| 156 | 156 | |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $e .= '<li><label><input ' . acf_esc_attr( $atts ) . '/>' . $label . '</label></li>'; |
|
| 159 | + $e .= '<li><label><input '.acf_esc_attr($atts).'/>'.$label.'</label></li>'; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | } |
@@ -182,24 +182,24 @@ discard block |
||
| 182 | 182 | * @param $field - an array holding all the field's data |
| 183 | 183 | */ |
| 184 | 184 | |
| 185 | - function render_field_settings( $field ) { |
|
| 185 | + function render_field_settings($field) { |
|
| 186 | 186 | |
| 187 | 187 | // encode choices (convert from array) |
| 188 | 188 | $field['choices'] = acf_encode_choices($field['choices']); |
| 189 | 189 | |
| 190 | 190 | |
| 191 | 191 | // choices |
| 192 | - acf_render_field_setting( $field, array( |
|
| 193 | - 'label' => __('Choices','acf'), |
|
| 194 | - 'instructions' => __('Enter each choice on a new line.','acf') . '<br /><br />' . __('For more control, you may specify both a value and label like this:','acf'). '<br /><br />' . __('red : Red','acf'), |
|
| 192 | + acf_render_field_setting($field, array( |
|
| 193 | + 'label' => __('Choices', 'acf'), |
|
| 194 | + 'instructions' => __('Enter each choice on a new line.', 'acf').'<br /><br />'.__('For more control, you may specify both a value and label like this:', 'acf').'<br /><br />'.__('red : Red', 'acf'), |
|
| 195 | 195 | 'type' => 'textarea', |
| 196 | 196 | 'name' => 'choices', |
| 197 | 197 | )); |
| 198 | 198 | |
| 199 | 199 | |
| 200 | 200 | // other_choice |
| 201 | - acf_render_field_setting( $field, array( |
|
| 202 | - 'label' => __('Other','acf'), |
|
| 201 | + acf_render_field_setting($field, array( |
|
| 202 | + 'label' => __('Other', 'acf'), |
|
| 203 | 203 | 'instructions' => '', |
| 204 | 204 | 'type' => 'true_false', |
| 205 | 205 | 'name' => 'other_choice', |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | // save_other_choice |
| 211 | - acf_render_field_setting( $field, array( |
|
| 212 | - 'label' => __('Save Other','acf'), |
|
| 211 | + acf_render_field_setting($field, array( |
|
| 212 | + 'label' => __('Save Other', 'acf'), |
|
| 213 | 213 | 'instructions' => '', |
| 214 | 214 | 'type' => 'true_false', |
| 215 | 215 | 'name' => 'save_other_choice', |
@@ -218,24 +218,24 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | // default_value |
| 221 | - acf_render_field_setting( $field, array( |
|
| 222 | - 'label' => __('Default Value','acf'), |
|
| 223 | - 'instructions' => __('Appears when creating a new post','acf'), |
|
| 221 | + acf_render_field_setting($field, array( |
|
| 222 | + 'label' => __('Default Value', 'acf'), |
|
| 223 | + 'instructions' => __('Appears when creating a new post', 'acf'), |
|
| 224 | 224 | 'type' => 'text', |
| 225 | 225 | 'name' => 'default_value', |
| 226 | 226 | )); |
| 227 | 227 | |
| 228 | 228 | |
| 229 | 229 | // layout |
| 230 | - acf_render_field_setting( $field, array( |
|
| 231 | - 'label' => __('Layout','acf'), |
|
| 230 | + acf_render_field_setting($field, array( |
|
| 231 | + 'label' => __('Layout', 'acf'), |
|
| 232 | 232 | 'instructions' => '', |
| 233 | 233 | 'type' => 'radio', |
| 234 | 234 | 'name' => 'layout', |
| 235 | 235 | 'layout' => 'horizontal', |
| 236 | 236 | 'choices' => array( |
| 237 | - 'vertical' => __("Vertical",'acf'), |
|
| 238 | - 'horizontal' => __("Horizontal",'acf') |
|
| 237 | + 'vertical' => __("Vertical", 'acf'), |
|
| 238 | + 'horizontal' => __("Horizontal", 'acf') |
|
| 239 | 239 | ) |
| 240 | 240 | )); |
| 241 | 241 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @return $field - the modified field |
| 259 | 259 | */ |
| 260 | 260 | |
| 261 | - function update_field( $field ) { |
|
| 261 | + function update_field($field) { |
|
| 262 | 262 | |
| 263 | 263 | // decode choices (convert to array) |
| 264 | 264 | $field['choices'] = acf_decode_choices($field['choices']); |
@@ -286,24 +286,24 @@ discard block |
||
| 286 | 286 | * @return $value - the modified value |
| 287 | 287 | */ |
| 288 | 288 | |
| 289 | - function update_value( $value, $post_id, $field ) { |
|
| 289 | + function update_value($value, $post_id, $field) { |
|
| 290 | 290 | |
| 291 | 291 | // save_other_choice |
| 292 | - if( $field['save_other_choice'] ) { |
|
| 292 | + if ($field['save_other_choice']) { |
|
| 293 | 293 | |
| 294 | 294 | // value isn't in choices yet |
| 295 | - if( !isset($field['choices'][ $value ]) ) { |
|
| 295 | + if ( ! isset($field['choices'][$value])) { |
|
| 296 | 296 | |
| 297 | 297 | // get ID if local |
| 298 | - if( !$field['ID'] ) { |
|
| 298 | + if ( ! $field['ID']) { |
|
| 299 | 299 | |
| 300 | - $field = acf_get_field( $field['key'], true ); |
|
| 300 | + $field = acf_get_field($field['key'], true); |
|
| 301 | 301 | |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | // bail early if no ID |
| 306 | - if( !$field['ID'] ) { |
|
| 306 | + if ( ! $field['ID']) { |
|
| 307 | 307 | |
| 308 | 308 | return $value; |
| 309 | 309 | |
@@ -311,11 +311,11 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | |
| 313 | 313 | // update $field |
| 314 | - $field['choices'][ $value ] = $value; |
|
| 314 | + $field['choices'][$value] = $value; |
|
| 315 | 315 | |
| 316 | 316 | |
| 317 | 317 | // save |
| 318 | - acf_update_field( $field ); |
|
| 318 | + acf_update_field($field); |
|
| 319 | 319 | |
| 320 | 320 | } |
| 321 | 321 | |
@@ -343,10 +343,10 @@ discard block |
||
| 343 | 343 | * @return $value - the value to be saved in te database |
| 344 | 344 | */ |
| 345 | 345 | |
| 346 | - function load_value( $value, $post_id, $field ) { |
|
| 346 | + function load_value($value, $post_id, $field) { |
|
| 347 | 347 | |
| 348 | 348 | // must be single value |
| 349 | - if( is_array($value) ) { |
|
| 349 | + if (is_array($value)) { |
|
| 350 | 350 | |
| 351 | 351 | $value = array_pop($value); |
| 352 | 352 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // do not delete! |
| 53 | - parent::__construct(); |
|
| 53 | + parent::__construct(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_relationship') ) : |
|
| 14 | +if ( ! class_exists('acf_field_relationship')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_relationship extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'relationship'; |
| 36 | - $this->label = __("Relationship",'acf'); |
|
| 36 | + $this->label = __("Relationship", 'acf'); |
|
| 37 | 37 | $this->category = 'relational'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'post_type' => array(), |
@@ -45,16 +45,16 @@ discard block |
||
| 45 | 45 | 'return_format' => 'object' |
| 46 | 46 | ); |
| 47 | 47 | $this->l10n = array( |
| 48 | - 'min' => __("Minimum values reached ( {min} values )",'acf'), |
|
| 49 | - 'max' => __("Maximum values reached ( {max} values )",'acf'), |
|
| 50 | - 'loading' => __('Loading','acf'), |
|
| 51 | - 'empty' => __('No matches found','acf'), |
|
| 48 | + 'min' => __("Minimum values reached ( {min} values )", 'acf'), |
|
| 49 | + 'max' => __("Maximum values reached ( {max} values )", 'acf'), |
|
| 50 | + 'loading' => __('Loading', 'acf'), |
|
| 51 | + 'empty' => __('No matches found', 'acf'), |
|
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | // extra |
| 56 | - add_action('wp_ajax_acf/fields/relationship/query', array($this, 'ajax_query')); |
|
| 57 | - add_action('wp_ajax_nopriv_acf/fields/relationship/query', array($this, 'ajax_query')); |
|
| 56 | + add_action('wp_ajax_acf/fields/relationship/query', array($this, 'ajax_query')); |
|
| 57 | + add_action('wp_ajax_nopriv_acf/fields/relationship/query', array($this, 'ajax_query')); |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | // do not delete! |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @return (array) |
| 77 | 77 | */ |
| 78 | 78 | |
| 79 | - function get_choices( $options = array() ) { |
|
| 79 | + function get_choices($options = array()) { |
|
| 80 | 80 | |
| 81 | 81 | // defaults |
| 82 | 82 | $options = acf_parse_args($options, array( |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | // load field |
| 104 | - $field = acf_get_field( $options['field_key'] ); |
|
| 104 | + $field = acf_get_field($options['field_key']); |
|
| 105 | 105 | |
| 106 | - if( !$field ) { |
|
| 106 | + if ( ! $field) { |
|
| 107 | 107 | |
| 108 | 108 | return false; |
| 109 | 109 | |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | // update $args |
| 114 | - if( !empty($options['post_type']) ) { |
|
| 114 | + if ( ! empty($options['post_type'])) { |
|
| 115 | 115 | |
| 116 | - $args['post_type'] = acf_get_array( $options['post_type'] ); |
|
| 116 | + $args['post_type'] = acf_get_array($options['post_type']); |
|
| 117 | 117 | |
| 118 | - } elseif( !empty($field['post_type']) ) { |
|
| 118 | + } elseif ( ! empty($field['post_type'])) { |
|
| 119 | 119 | |
| 120 | - $args['post_type'] = acf_get_array( $field['post_type'] ); |
|
| 120 | + $args['post_type'] = acf_get_array($field['post_type']); |
|
| 121 | 121 | |
| 122 | 122 | } else { |
| 123 | 123 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | // update taxonomy |
| 129 | 129 | $taxonomies = array(); |
| 130 | 130 | |
| 131 | - if( !empty($options['taxonomy']) ) { |
|
| 131 | + if ( ! empty($options['taxonomy'])) { |
|
| 132 | 132 | |
| 133 | 133 | $term = acf_decode_taxonomy_term($options['taxonomy']); |
| 134 | 134 | |
@@ -144,16 +144,16 @@ discard block |
||
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | 146 | |
| 147 | - } elseif( !empty($field['taxonomy']) ) { |
|
| 147 | + } elseif ( ! empty($field['taxonomy'])) { |
|
| 148 | 148 | |
| 149 | - $taxonomies = acf_decode_taxonomy_terms( $field['taxonomy'] ); |
|
| 149 | + $taxonomies = acf_decode_taxonomy_terms($field['taxonomy']); |
|
| 150 | 150 | |
| 151 | 151 | // append to $args |
| 152 | 152 | $args['tax_query'] = array(); |
| 153 | 153 | |
| 154 | 154 | |
| 155 | 155 | // now create the tax queries |
| 156 | - foreach( $taxonomies as $taxonomy => $terms ) { |
|
| 156 | + foreach ($taxonomies as $taxonomy => $terms) { |
|
| 157 | 157 | |
| 158 | 158 | $args['tax_query'][] = array( |
| 159 | 159 | 'taxonomy' => $taxonomy, |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | |
| 169 | 169 | // search |
| 170 | - if( $options['s'] ) { |
|
| 170 | + if ($options['s']) { |
|
| 171 | 171 | |
| 172 | 172 | $args['s'] = $options['s']; |
| 173 | 173 | |
@@ -176,19 +176,19 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | // filters |
| 178 | 178 | $args = apply_filters('acf/fields/relationship/query', $args, $field, $options['post_id']); |
| 179 | - $args = apply_filters('acf/fields/relationship/query/name=' . $field['name'], $args, $field, $options['post_id'] ); |
|
| 180 | - $args = apply_filters('acf/fields/relationship/query/key=' . $field['key'], $args, $field, $options['post_id'] ); |
|
| 179 | + $args = apply_filters('acf/fields/relationship/query/name='.$field['name'], $args, $field, $options['post_id']); |
|
| 180 | + $args = apply_filters('acf/fields/relationship/query/key='.$field['key'], $args, $field, $options['post_id']); |
|
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | // get posts grouped by post type |
| 184 | - $groups = acf_get_grouped_posts( $args ); |
|
| 184 | + $groups = acf_get_grouped_posts($args); |
|
| 185 | 185 | |
| 186 | - if( !empty($groups) ) { |
|
| 186 | + if ( ! empty($groups)) { |
|
| 187 | 187 | |
| 188 | - foreach( array_keys($groups) as $group_title ) { |
|
| 188 | + foreach (array_keys($groups) as $group_title) { |
|
| 189 | 189 | |
| 190 | 190 | // vars |
| 191 | - $posts = acf_extract_var( $groups, $group_title ); |
|
| 191 | + $posts = acf_extract_var($groups, $group_title); |
|
| 192 | 192 | $titles = array(); |
| 193 | 193 | |
| 194 | 194 | |
@@ -199,28 +199,28 @@ discard block |
||
| 199 | 199 | ); |
| 200 | 200 | |
| 201 | 201 | |
| 202 | - foreach( array_keys($posts) as $post_id ) { |
|
| 202 | + foreach (array_keys($posts) as $post_id) { |
|
| 203 | 203 | |
| 204 | 204 | // override data |
| 205 | - $posts[ $post_id ] = $this->get_post_title( $posts[ $post_id ], $field, $options['post_id'] ); |
|
| 205 | + $posts[$post_id] = $this->get_post_title($posts[$post_id], $field, $options['post_id']); |
|
| 206 | 206 | |
| 207 | 207 | }; |
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | // order by search |
| 211 | - if( !empty($args['s']) ) { |
|
| 211 | + if ( ! empty($args['s'])) { |
|
| 212 | 212 | |
| 213 | - $posts = acf_order_by_search( $posts, $args['s'] ); |
|
| 213 | + $posts = acf_order_by_search($posts, $args['s']); |
|
| 214 | 214 | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | // append to $data |
| 219 | - foreach( array_keys($posts) as $post_id ) { |
|
| 219 | + foreach (array_keys($posts) as $post_id) { |
|
| 220 | 220 | |
| 221 | 221 | $data['children'][] = array( |
| 222 | 222 | 'id' => $post_id, |
| 223 | - 'text' => $posts[ $post_id ] |
|
| 223 | + 'text' => $posts[$post_id] |
|
| 224 | 224 | ); |
| 225 | 225 | |
| 226 | 226 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | |
| 235 | 235 | // add as optgroup or results |
| 236 | - if( count($args['post_type']) == 1 ) { |
|
| 236 | + if (count($args['post_type']) == 1) { |
|
| 237 | 237 | |
| 238 | 238 | $r = $r[0]['children']; |
| 239 | 239 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | function ajax_query() { |
| 265 | 265 | |
| 266 | 266 | // validate |
| 267 | - if( !acf_verify_ajax() ) { |
|
| 267 | + if ( ! acf_verify_ajax()) { |
|
| 268 | 268 | |
| 269 | 269 | die(); |
| 270 | 270 | |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | |
| 274 | 274 | // get posts |
| 275 | - $posts = $this->get_choices( $_POST ); |
|
| 275 | + $posts = $this->get_choices($_POST); |
|
| 276 | 276 | |
| 277 | 277 | |
| 278 | 278 | // validate |
| 279 | - if( !$posts ) { |
|
| 279 | + if ( ! $posts) { |
|
| 280 | 280 | |
| 281 | 281 | die(); |
| 282 | 282 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | |
| 286 | 286 | // return JSON |
| 287 | - echo json_encode( $posts ); |
|
| 287 | + echo json_encode($posts); |
|
| 288 | 288 | die(); |
| 289 | 289 | |
| 290 | 290 | } |
@@ -305,10 +305,10 @@ discard block |
||
| 305 | 305 | * @return (string) |
| 306 | 306 | */ |
| 307 | 307 | |
| 308 | - function get_post_title( $post, $field, $post_id = 0 ) { |
|
| 308 | + function get_post_title($post, $field, $post_id = 0) { |
|
| 309 | 309 | |
| 310 | 310 | // get post_id |
| 311 | - if( !$post_id ) { |
|
| 311 | + if ( ! $post_id) { |
|
| 312 | 312 | |
| 313 | 313 | $post_id = acf_get_setting('form_data/post_id', get_the_ID()); |
| 314 | 314 | |
@@ -316,28 +316,28 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | |
| 318 | 318 | // vars |
| 319 | - $title = acf_get_post_title( $post ); |
|
| 319 | + $title = acf_get_post_title($post); |
|
| 320 | 320 | |
| 321 | 321 | |
| 322 | 322 | // elements |
| 323 | - if( !empty($field['elements']) ) { |
|
| 323 | + if ( ! empty($field['elements'])) { |
|
| 324 | 324 | |
| 325 | - if( in_array('featured_image', $field['elements']) ) { |
|
| 325 | + if (in_array('featured_image', $field['elements'])) { |
|
| 326 | 326 | |
| 327 | 327 | $image = ''; |
| 328 | 328 | |
| 329 | - if( $post->post_type == 'attachment' ) { |
|
| 329 | + if ($post->post_type == 'attachment') { |
|
| 330 | 330 | |
| 331 | - $image = wp_get_attachment_image( $post->ID, array(17, 17) ); |
|
| 331 | + $image = wp_get_attachment_image($post->ID, array(17, 17)); |
|
| 332 | 332 | |
| 333 | 333 | } else { |
| 334 | 334 | |
| 335 | - $image = get_the_post_thumbnail( $post->ID, array(17, 17) ); |
|
| 335 | + $image = get_the_post_thumbnail($post->ID, array(17, 17)); |
|
| 336 | 336 | |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | |
| 340 | - $title = '<div class="thumbnail">' . $image . '</div>' . $title; |
|
| 340 | + $title = '<div class="thumbnail">'.$image.'</div>'.$title; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | } |
@@ -345,8 +345,8 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | // filters |
| 347 | 347 | $title = apply_filters('acf/fields/relationship/result', $title, $post, $field, $post_id); |
| 348 | - $title = apply_filters('acf/fields/relationship/result/name=' . $field['_name'], $title, $post, $field, $post_id); |
|
| 349 | - $title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $post_id); |
|
| 348 | + $title = apply_filters('acf/fields/relationship/result/name='.$field['_name'], $title, $post, $field, $post_id); |
|
| 349 | + $title = apply_filters('acf/fields/relationship/result/key='.$field['key'], $title, $post, $field, $post_id); |
|
| 350 | 350 | |
| 351 | 351 | |
| 352 | 352 | // return |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | * @date 23/01/13 |
| 368 | 368 | */ |
| 369 | 369 | |
| 370 | - function render_field( $field ) { |
|
| 370 | + function render_field($field) { |
|
| 371 | 371 | |
| 372 | 372 | // vars |
| 373 | 373 | $values = array(); |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | |
| 386 | 386 | // Lang |
| 387 | - if( defined('ICL_LANGUAGE_CODE') ) { |
|
| 387 | + if (defined('ICL_LANGUAGE_CODE')) { |
|
| 388 | 388 | |
| 389 | 389 | $atts['data-lang'] = ICL_LANGUAGE_CODE; |
| 390 | 390 | |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | |
| 394 | 394 | // data types |
| 395 | - $field['post_type'] = acf_get_array( $field['post_type'] ); |
|
| 396 | - $field['taxonomy'] = acf_get_array( $field['taxonomy'] ); |
|
| 395 | + $field['post_type'] = acf_get_array($field['post_type']); |
|
| 396 | + $field['taxonomy'] = acf_get_array($field['taxonomy']); |
|
| 397 | 397 | |
| 398 | 398 | |
| 399 | 399 | // width for select filters |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | 'taxonomy' => 0 |
| 404 | 404 | ); |
| 405 | 405 | |
| 406 | - if( !empty($field['filters']) ) { |
|
| 406 | + if ( ! empty($field['filters'])) { |
|
| 407 | 407 | |
| 408 | 408 | $width = array( |
| 409 | 409 | 'search' => 50, |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | 'taxonomy' => 25 |
| 412 | 412 | ); |
| 413 | 413 | |
| 414 | - foreach( array_keys($width) as $k ) { |
|
| 414 | + foreach (array_keys($width) as $k) { |
|
| 415 | 415 | |
| 416 | - if( ! in_array($k, $field['filters']) ) { |
|
| 416 | + if ( ! in_array($k, $field['filters'])) { |
|
| 417 | 417 | |
| 418 | - $width[ $k ] = 0; |
|
| 418 | + $width[$k] = 0; |
|
| 419 | 419 | |
| 420 | 420 | } |
| 421 | 421 | |
@@ -423,33 +423,33 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | |
| 425 | 425 | // search |
| 426 | - if( $width['search'] == 0 ) { |
|
| 426 | + if ($width['search'] == 0) { |
|
| 427 | 427 | |
| 428 | - $width['post_type'] = ( $width['post_type'] == 0 ) ? 0 : 50; |
|
| 429 | - $width['taxonomy'] = ( $width['taxonomy'] == 0 ) ? 0 : 50; |
|
| 428 | + $width['post_type'] = ($width['post_type'] == 0) ? 0 : 50; |
|
| 429 | + $width['taxonomy'] = ($width['taxonomy'] == 0) ? 0 : 50; |
|
| 430 | 430 | |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | // post_type |
| 434 | - if( $width['post_type'] == 0 ) { |
|
| 434 | + if ($width['post_type'] == 0) { |
|
| 435 | 435 | |
| 436 | - $width['taxonomy'] = ( $width['taxonomy'] == 0 ) ? 0 : 50; |
|
| 436 | + $width['taxonomy'] = ($width['taxonomy'] == 0) ? 0 : 50; |
|
| 437 | 437 | |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | |
| 441 | 441 | // taxonomy |
| 442 | - if( $width['taxonomy'] == 0 ) { |
|
| 442 | + if ($width['taxonomy'] == 0) { |
|
| 443 | 443 | |
| 444 | - $width['post_type'] = ( $width['post_type'] == 0 ) ? 0 : 50; |
|
| 444 | + $width['post_type'] = ($width['post_type'] == 0) ? 0 : 50; |
|
| 445 | 445 | |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | |
| 449 | 449 | // search |
| 450 | - if( $width['post_type'] == 0 && $width['taxonomy'] == 0 ) { |
|
| 450 | + if ($width['post_type'] == 0 && $width['taxonomy'] == 0) { |
|
| 451 | 451 | |
| 452 | - $width['search'] = ( $width['search'] == 0 ) ? 0 : 100; |
|
| 452 | + $width['search'] = ($width['search'] == 0) ? 0 : 100; |
|
| 453 | 453 | |
| 454 | 454 | } |
| 455 | 455 | } |
@@ -458,9 +458,9 @@ discard block |
||
| 458 | 458 | // post type filter |
| 459 | 459 | $post_types = array(); |
| 460 | 460 | |
| 461 | - if( $width['post_type'] ) { |
|
| 461 | + if ($width['post_type']) { |
|
| 462 | 462 | |
| 463 | - if( !empty($field['post_type']) ) { |
|
| 463 | + if ( ! empty($field['post_type'])) { |
|
| 464 | 464 | |
| 465 | 465 | $post_types = $field['post_type']; |
| 466 | 466 | |
@@ -480,36 +480,36 @@ discard block |
||
| 480 | 480 | $taxonomies = array(); |
| 481 | 481 | $term_groups = array(); |
| 482 | 482 | |
| 483 | - if( $width['taxonomy'] ) { |
|
| 483 | + if ($width['taxonomy']) { |
|
| 484 | 484 | |
| 485 | 485 | // taxonomies |
| 486 | - if( !empty($field['taxonomy']) ) { |
|
| 486 | + if ( ! empty($field['taxonomy'])) { |
|
| 487 | 487 | |
| 488 | 488 | // get the field's terms |
| 489 | - $term_groups = acf_get_array( $field['taxonomy'] ); |
|
| 490 | - $term_groups = acf_decode_taxonomy_terms( $term_groups ); |
|
| 489 | + $term_groups = acf_get_array($field['taxonomy']); |
|
| 490 | + $term_groups = acf_decode_taxonomy_terms($term_groups); |
|
| 491 | 491 | |
| 492 | 492 | |
| 493 | 493 | // update taxonomies |
| 494 | 494 | $taxonomies = array_keys($term_groups); |
| 495 | 495 | |
| 496 | - } elseif( !empty($field['post_type']) ) { |
|
| 496 | + } elseif ( ! empty($field['post_type'])) { |
|
| 497 | 497 | |
| 498 | 498 | // loop over post types and find connected taxonomies |
| 499 | - foreach( $field['post_type'] as $post_type ) { |
|
| 499 | + foreach ($field['post_type'] as $post_type) { |
|
| 500 | 500 | |
| 501 | - $post_taxonomies = get_object_taxonomies( $post_type ); |
|
| 501 | + $post_taxonomies = get_object_taxonomies($post_type); |
|
| 502 | 502 | |
| 503 | 503 | // bail early if no taxonomies |
| 504 | - if( empty($post_taxonomies) ) { |
|
| 504 | + if (empty($post_taxonomies)) { |
|
| 505 | 505 | |
| 506 | 506 | continue; |
| 507 | 507 | |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - foreach( $post_taxonomies as $post_taxonomy ) { |
|
| 510 | + foreach ($post_taxonomies as $post_taxonomy) { |
|
| 511 | 511 | |
| 512 | - if( !in_array($post_taxonomy, $taxonomies) ) { |
|
| 512 | + if ( ! in_array($post_taxonomy, $taxonomies)) { |
|
| 513 | 513 | |
| 514 | 514 | $taxonomies[] = $post_taxonomy; |
| 515 | 515 | |
@@ -527,19 +527,19 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | |
| 529 | 529 | // terms |
| 530 | - $term_groups = acf_get_taxonomy_terms( $taxonomies ); |
|
| 530 | + $term_groups = acf_get_taxonomy_terms($taxonomies); |
|
| 531 | 531 | |
| 532 | 532 | |
| 533 | 533 | // update $term_groups with specific terms |
| 534 | - if( !empty($field['taxonomy']) ) { |
|
| 534 | + if ( ! empty($field['taxonomy'])) { |
|
| 535 | 535 | |
| 536 | - foreach( array_keys($term_groups) as $taxonomy ) { |
|
| 536 | + foreach (array_keys($term_groups) as $taxonomy) { |
|
| 537 | 537 | |
| 538 | - foreach( array_keys($term_groups[ $taxonomy ]) as $term ) { |
|
| 538 | + foreach (array_keys($term_groups[$taxonomy]) as $term) { |
|
| 539 | 539 | |
| 540 | - if( ! in_array($term, $field['taxonomy']) ) { |
|
| 540 | + if ( ! in_array($term, $field['taxonomy'])) { |
|
| 541 | 541 | |
| 542 | - unset($term_groups[ $taxonomy ][ $term ]); |
|
| 542 | + unset($term_groups[$taxonomy][$term]); |
|
| 543 | 543 | |
| 544 | 544 | } |
| 545 | 545 | |
@@ -559,25 +559,25 @@ discard block |
||
| 559 | 559 | <input type="hidden" name="<?php echo $field['name']; ?>" value="" /> |
| 560 | 560 | </div> |
| 561 | 561 | |
| 562 | - <?php if( $width['search'] || $width['post_type'] || $width['taxonomy'] ): ?> |
|
| 562 | + <?php if ($width['search'] || $width['post_type'] || $width['taxonomy']): ?> |
|
| 563 | 563 | <div class="filters"> |
| 564 | 564 | |
| 565 | 565 | <ul class="acf-hl"> |
| 566 | 566 | |
| 567 | - <?php if( $width['search'] ): ?> |
|
| 567 | + <?php if ($width['search']): ?> |
|
| 568 | 568 | <li style="width:<?php echo $width['search']; ?>%;"> |
| 569 | 569 | <div class="inner"> |
| 570 | - <input class="filter" data-filter="s" placeholder="<?php _e("Search...",'acf'); ?>" type="text" /> |
|
| 570 | + <input class="filter" data-filter="s" placeholder="<?php _e("Search...", 'acf'); ?>" type="text" /> |
|
| 571 | 571 | </div> |
| 572 | 572 | </li> |
| 573 | 573 | <?php endif; ?> |
| 574 | 574 | |
| 575 | - <?php if( $width['post_type'] ): ?> |
|
| 575 | + <?php if ($width['post_type']): ?> |
|
| 576 | 576 | <li style="width:<?php echo $width['post_type']; ?>%;"> |
| 577 | 577 | <div class="inner"> |
| 578 | 578 | <select class="filter" data-filter="post_type"> |
| 579 | - <option value=""><?php _e('Select post type','acf'); ?></option> |
|
| 580 | - <?php foreach( $post_types as $k => $v ): ?> |
|
| 579 | + <option value=""><?php _e('Select post type', 'acf'); ?></option> |
|
| 580 | + <?php foreach ($post_types as $k => $v): ?> |
|
| 581 | 581 | <option value="<?php echo $k; ?>"><?php echo $v; ?></option> |
| 582 | 582 | <?php endforeach; ?> |
| 583 | 583 | </select> |
@@ -585,14 +585,14 @@ discard block |
||
| 585 | 585 | </li> |
| 586 | 586 | <?php endif; ?> |
| 587 | 587 | |
| 588 | - <?php if( $width['taxonomy'] ): ?> |
|
| 588 | + <?php if ($width['taxonomy']): ?> |
|
| 589 | 589 | <li style="width:<?php echo $width['taxonomy']; ?>%;"> |
| 590 | 590 | <div class="inner"> |
| 591 | 591 | <select class="filter" data-filter="taxonomy"> |
| 592 | - <option value=""><?php _e('Select taxonomy','acf'); ?></option> |
|
| 593 | - <?php foreach( $term_groups as $k_opt => $v_opt ): ?> |
|
| 592 | + <option value=""><?php _e('Select taxonomy', 'acf'); ?></option> |
|
| 593 | + <?php foreach ($term_groups as $k_opt => $v_opt): ?> |
|
| 594 | 594 | <optgroup label="<?php echo $k_opt; ?>"> |
| 595 | - <?php foreach( $v_opt as $k => $v ): ?> |
|
| 595 | + <?php foreach ($v_opt as $k => $v): ?> |
|
| 596 | 596 | <option value="<?php echo $k; ?>"><?php echo $v; ?></option> |
| 597 | 597 | <?php endforeach; ?> |
| 598 | 598 | </optgroup> |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | |
| 619 | 619 | <ul class="acf-bl list"> |
| 620 | 620 | |
| 621 | - <?php if( !empty($field['value']) ): |
|
| 621 | + <?php if ( ! empty($field['value'])): |
|
| 622 | 622 | |
| 623 | 623 | // get posts |
| 624 | 624 | $posts = acf_get_posts(array( |
@@ -628,18 +628,18 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | |
| 630 | 630 | // set choices |
| 631 | - if( !empty($posts) ): |
|
| 631 | + if ( ! empty($posts)): |
|
| 632 | 632 | |
| 633 | - foreach( array_keys($posts) as $i ): |
|
| 633 | + foreach (array_keys($posts) as $i): |
|
| 634 | 634 | |
| 635 | 635 | // vars |
| 636 | - $post = acf_extract_var( $posts, $i ); |
|
| 636 | + $post = acf_extract_var($posts, $i); |
|
| 637 | 637 | |
| 638 | 638 | |
| 639 | 639 | ?><li> |
| 640 | 640 | <input type="hidden" name="<?php echo $field['name']; ?>[]" value="<?php echo $post->ID; ?>" /> |
| 641 | 641 | <span data-id="<?php echo $post->ID; ?>" class="acf-rel-item"> |
| 642 | - <?php echo $this->get_post_title( $post, $field ); ?> |
|
| 642 | + <?php echo $this->get_post_title($post, $field); ?> |
|
| 643 | 643 | <a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a> |
| 644 | 644 | </span> |
| 645 | 645 | </li><?php |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | * @param $field - an array holding all the field's data |
| 678 | 678 | */ |
| 679 | 679 | |
| 680 | - function render_field_settings( $field ) { |
|
| 680 | + function render_field_settings($field) { |
|
| 681 | 681 | |
| 682 | 682 | // vars |
| 683 | 683 | $field['min'] = empty($field['min']) ? '' : $field['min']; |
@@ -685,8 +685,8 @@ discard block |
||
| 685 | 685 | |
| 686 | 686 | |
| 687 | 687 | // post_type |
| 688 | - acf_render_field_setting( $field, array( |
|
| 689 | - 'label' => __('Filter by Post Type','acf'), |
|
| 688 | + acf_render_field_setting($field, array( |
|
| 689 | + 'label' => __('Filter by Post Type', 'acf'), |
|
| 690 | 690 | 'instructions' => '', |
| 691 | 691 | 'type' => 'select', |
| 692 | 692 | 'name' => 'post_type', |
@@ -694,13 +694,13 @@ discard block |
||
| 694 | 694 | 'multiple' => 1, |
| 695 | 695 | 'ui' => 1, |
| 696 | 696 | 'allow_null' => 1, |
| 697 | - 'placeholder' => __("All post types",'acf'), |
|
| 697 | + 'placeholder' => __("All post types", 'acf'), |
|
| 698 | 698 | )); |
| 699 | 699 | |
| 700 | 700 | |
| 701 | 701 | // taxonomy |
| 702 | - acf_render_field_setting( $field, array( |
|
| 703 | - 'label' => __('Filter by Taxonomy','acf'), |
|
| 702 | + acf_render_field_setting($field, array( |
|
| 703 | + 'label' => __('Filter by Taxonomy', 'acf'), |
|
| 704 | 704 | 'instructions' => '', |
| 705 | 705 | 'type' => 'select', |
| 706 | 706 | 'name' => 'taxonomy', |
@@ -708,39 +708,39 @@ discard block |
||
| 708 | 708 | 'multiple' => 1, |
| 709 | 709 | 'ui' => 1, |
| 710 | 710 | 'allow_null' => 1, |
| 711 | - 'placeholder' => __("All taxonomies",'acf'), |
|
| 711 | + 'placeholder' => __("All taxonomies", 'acf'), |
|
| 712 | 712 | )); |
| 713 | 713 | |
| 714 | 714 | |
| 715 | 715 | // filters |
| 716 | - acf_render_field_setting( $field, array( |
|
| 717 | - 'label' => __('Filters','acf'), |
|
| 716 | + acf_render_field_setting($field, array( |
|
| 717 | + 'label' => __('Filters', 'acf'), |
|
| 718 | 718 | 'instructions' => '', |
| 719 | 719 | 'type' => 'checkbox', |
| 720 | 720 | 'name' => 'filters', |
| 721 | 721 | 'choices' => array( |
| 722 | - 'search' => __("Search",'acf'), |
|
| 723 | - 'post_type' => __("Post Type",'acf'), |
|
| 724 | - 'taxonomy' => __("Taxonomy",'acf'), |
|
| 722 | + 'search' => __("Search", 'acf'), |
|
| 723 | + 'post_type' => __("Post Type", 'acf'), |
|
| 724 | + 'taxonomy' => __("Taxonomy", 'acf'), |
|
| 725 | 725 | ), |
| 726 | 726 | )); |
| 727 | 727 | |
| 728 | 728 | |
| 729 | 729 | // filters |
| 730 | - acf_render_field_setting( $field, array( |
|
| 731 | - 'label' => __('Elements','acf'), |
|
| 732 | - 'instructions' => __('Selected elements will be displayed in each result','acf'), |
|
| 730 | + acf_render_field_setting($field, array( |
|
| 731 | + 'label' => __('Elements', 'acf'), |
|
| 732 | + 'instructions' => __('Selected elements will be displayed in each result', 'acf'), |
|
| 733 | 733 | 'type' => 'checkbox', |
| 734 | 734 | 'name' => 'elements', |
| 735 | 735 | 'choices' => array( |
| 736 | - 'featured_image' => __("Featured Image",'acf'), |
|
| 736 | + 'featured_image' => __("Featured Image", 'acf'), |
|
| 737 | 737 | ), |
| 738 | 738 | )); |
| 739 | 739 | |
| 740 | 740 | |
| 741 | 741 | // min |
| 742 | - acf_render_field_setting( $field, array( |
|
| 743 | - 'label' => __('Minimum posts','acf'), |
|
| 742 | + acf_render_field_setting($field, array( |
|
| 743 | + 'label' => __('Minimum posts', 'acf'), |
|
| 744 | 744 | 'instructions' => '', |
| 745 | 745 | 'type' => 'number', |
| 746 | 746 | 'name' => 'min', |
@@ -748,8 +748,8 @@ discard block |
||
| 748 | 748 | |
| 749 | 749 | |
| 750 | 750 | // max |
| 751 | - acf_render_field_setting( $field, array( |
|
| 752 | - 'label' => __('Maximum posts','acf'), |
|
| 751 | + acf_render_field_setting($field, array( |
|
| 752 | + 'label' => __('Maximum posts', 'acf'), |
|
| 753 | 753 | 'instructions' => '', |
| 754 | 754 | 'type' => 'number', |
| 755 | 755 | 'name' => 'max', |
@@ -759,14 +759,14 @@ discard block |
||
| 759 | 759 | |
| 760 | 760 | |
| 761 | 761 | // return_format |
| 762 | - acf_render_field_setting( $field, array( |
|
| 763 | - 'label' => __('Return Format','acf'), |
|
| 762 | + acf_render_field_setting($field, array( |
|
| 763 | + 'label' => __('Return Format', 'acf'), |
|
| 764 | 764 | 'instructions' => '', |
| 765 | 765 | 'type' => 'radio', |
| 766 | 766 | 'name' => 'return_format', |
| 767 | 767 | 'choices' => array( |
| 768 | - 'object' => __("Post Object",'acf'), |
|
| 769 | - 'id' => __("Post ID",'acf'), |
|
| 768 | + 'object' => __("Post Object", 'acf'), |
|
| 769 | + 'id' => __("Post ID", 'acf'), |
|
| 770 | 770 | ), |
| 771 | 771 | 'layout' => 'horizontal', |
| 772 | 772 | )); |
@@ -791,10 +791,10 @@ discard block |
||
| 791 | 791 | * @return $value (mixed) the modified value |
| 792 | 792 | */ |
| 793 | 793 | |
| 794 | - function format_value( $value, $post_id, $field ) { |
|
| 794 | + function format_value($value, $post_id, $field) { |
|
| 795 | 795 | |
| 796 | 796 | // bail early if no value |
| 797 | - if( empty($value) ) { |
|
| 797 | + if (empty($value)) { |
|
| 798 | 798 | |
| 799 | 799 | return $value; |
| 800 | 800 | |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | |
| 803 | 803 | |
| 804 | 804 | // force value to array |
| 805 | - $value = acf_get_array( $value ); |
|
| 805 | + $value = acf_get_array($value); |
|
| 806 | 806 | |
| 807 | 807 | |
| 808 | 808 | // convert to int |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | |
| 811 | 811 | |
| 812 | 812 | // load posts if needed |
| 813 | - if( $field['return_format'] == 'object' ) { |
|
| 813 | + if ($field['return_format'] == 'object') { |
|
| 814 | 814 | |
| 815 | 815 | // get posts |
| 816 | 816 | $value = acf_get_posts(array( |
@@ -840,10 +840,10 @@ discard block |
||
| 840 | 840 | * @return $post_id (int) |
| 841 | 841 | */ |
| 842 | 842 | |
| 843 | - function validate_value( $valid, $value, $field, $input ){ |
|
| 843 | + function validate_value($valid, $value, $field, $input) { |
|
| 844 | 844 | |
| 845 | 845 | // default |
| 846 | - if( empty($value) || !is_array($value) ) { |
|
| 846 | + if (empty($value) || ! is_array($value)) { |
|
| 847 | 847 | |
| 848 | 848 | $value = array(); |
| 849 | 849 | |
@@ -851,10 +851,10 @@ discard block |
||
| 851 | 851 | |
| 852 | 852 | |
| 853 | 853 | // min |
| 854 | - if( count($value) < $field['min'] ) { |
|
| 854 | + if (count($value) < $field['min']) { |
|
| 855 | 855 | |
| 856 | - $valid = _n( '%s requires at least %s selection', '%s requires at least %s selections', $field['min'], 'acf' ); |
|
| 857 | - $valid = sprintf( $valid, $field['label'], $field['min'] ); |
|
| 856 | + $valid = _n('%s requires at least %s selection', '%s requires at least %s selections', $field['min'], 'acf'); |
|
| 857 | + $valid = sprintf($valid, $field['label'], $field['min']); |
|
| 858 | 858 | |
| 859 | 859 | } |
| 860 | 860 | |
@@ -881,10 +881,10 @@ discard block |
||
| 881 | 881 | * @return $value - the modified value |
| 882 | 882 | */ |
| 883 | 883 | |
| 884 | - function update_value( $value, $post_id, $field ) { |
|
| 884 | + function update_value($value, $post_id, $field) { |
|
| 885 | 885 | |
| 886 | 886 | // validate |
| 887 | - if( empty($value) ) { |
|
| 887 | + if (empty($value)) { |
|
| 888 | 888 | |
| 889 | 889 | return $value; |
| 890 | 890 | |
@@ -892,16 +892,16 @@ discard block |
||
| 892 | 892 | |
| 893 | 893 | |
| 894 | 894 | // force value to array |
| 895 | - $value = acf_get_array( $value ); |
|
| 895 | + $value = acf_get_array($value); |
|
| 896 | 896 | |
| 897 | 897 | |
| 898 | 898 | // array |
| 899 | - foreach( $value as $k => $v ){ |
|
| 899 | + foreach ($value as $k => $v) { |
|
| 900 | 900 | |
| 901 | 901 | // object? |
| 902 | - if( is_object($v) && isset($v->ID) ) { |
|
| 902 | + if (is_object($v) && isset($v->ID)) { |
|
| 903 | 903 | |
| 904 | - $value[ $k ] = $v->ID; |
|
| 904 | + $value[$k] = $v->ID; |
|
| 905 | 905 | |
| 906 | 906 | } |
| 907 | 907 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // do not delete! |
| 53 | - parent::__construct(); |
|
| 53 | + parent::__construct(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_select') ) : |
|
| 14 | +if ( ! class_exists('acf_field_select')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_select extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'select'; |
| 36 | - $this->label = __("Select",'acf'); |
|
| 36 | + $this->label = __("Select", 'acf'); |
|
| 37 | 37 | $this->category = 'choice'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'multiple' => 0, |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | // ajax |
| 52 | - add_action('wp_ajax_acf/fields/select/query', array($this, 'ajax_query')); |
|
| 53 | - add_action('wp_ajax_nopriv_acf/fields/select/query', array($this, 'ajax_query')); |
|
| 52 | + add_action('wp_ajax_acf/fields/select/query', array($this, 'ajax_query')); |
|
| 53 | + add_action('wp_ajax_nopriv_acf/fields/select/query', array($this, 'ajax_query')); |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | // do not delete! |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | function ajax_query() { |
| 76 | 76 | |
| 77 | 77 | // options |
| 78 | - $options = acf_parse_args( $_POST, array( |
|
| 78 | + $options = acf_parse_args($_POST, array( |
|
| 79 | 79 | 'post_id' => 0, |
| 80 | 80 | 's' => '', |
| 81 | 81 | 'field_key' => '', |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | // load field |
| 87 | - $field = acf_get_field( $options['field_key'] ); |
|
| 87 | + $field = acf_get_field($options['field_key']); |
|
| 88 | 88 | |
| 89 | - if( !$field ) { |
|
| 89 | + if ( ! $field) { |
|
| 90 | 90 | |
| 91 | 91 | die(); |
| 92 | 92 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | // search |
| 102 | - if( $options['s'] !== '' ) { |
|
| 102 | + if ($options['s'] !== '') { |
|
| 103 | 103 | |
| 104 | 104 | // search may be integer |
| 105 | 105 | $s = strval($options['s']); |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | |
| 114 | 114 | // loop through choices |
| 115 | - if( !empty($field['choices']) ) { |
|
| 115 | + if ( ! empty($field['choices'])) { |
|
| 116 | 116 | |
| 117 | - foreach( $field['choices'] as $k => $v ) { |
|
| 117 | + foreach ($field['choices'] as $k => $v) { |
|
| 118 | 118 | |
| 119 | 119 | // if searching, but doesn't exist |
| 120 | - if( $s !== false && stripos($v, $s) === false ) { |
|
| 120 | + if ($s !== false && stripos($v, $s) === false) { |
|
| 121 | 121 | |
| 122 | 122 | continue; |
| 123 | 123 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | // append |
| 128 | 128 | $r[] = array( |
| 129 | 129 | 'id' => $k, |
| 130 | - 'text' => strval( $v ) |
|
| 130 | + 'text' => strval($v) |
|
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | 133 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | // return JSON |
| 139 | - echo json_encode( $r ); |
|
| 139 | + echo json_encode($r); |
|
| 140 | 140 | die(); |
| 141 | 141 | |
| 142 | 142 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @date 23/01/13 |
| 155 | 155 | */ |
| 156 | 156 | |
| 157 | - function render_field( $field ) { |
|
| 157 | + function render_field($field) { |
|
| 158 | 158 | |
| 159 | 159 | // convert |
| 160 | 160 | $field['value'] = acf_get_array($field['value'], false); |
@@ -162,15 +162,15 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | // placeholder |
| 165 | - if( empty($field['placeholder']) ) { |
|
| 165 | + if (empty($field['placeholder'])) { |
|
| 166 | 166 | |
| 167 | - $field['placeholder'] = __("Select",'acf'); |
|
| 167 | + $field['placeholder'] = __("Select", 'acf'); |
|
| 168 | 168 | |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | // add empty value (allows '' to be selected) |
| 173 | - if( !count($field['value']) ) { |
|
| 173 | + if ( ! count($field['value'])) { |
|
| 174 | 174 | |
| 175 | 175 | $field['value'][''] = ''; |
| 176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | // null |
| 181 | - if( $field['allow_null'] && !$field['multiple'] ) { |
|
| 181 | + if ($field['allow_null'] && ! $field['multiple']) { |
|
| 182 | 182 | |
| 183 | - $prepend = array('' => '- ' . $field['placeholder'] . ' -'); |
|
| 183 | + $prepend = array('' => '- '.$field['placeholder'].' -'); |
|
| 184 | 184 | $field['choices'] = $prepend + $field['choices']; |
| 185 | 185 | |
| 186 | 186 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | // multiple |
| 203 | - if( $field['multiple'] ) { |
|
| 203 | + if ($field['multiple']) { |
|
| 204 | 204 | |
| 205 | 205 | $atts['multiple'] = 'multiple'; |
| 206 | 206 | $atts['size'] = 5; |
@@ -210,19 +210,19 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | |
| 212 | 212 | // special atts |
| 213 | - foreach( array( 'readonly', 'disabled' ) as $k ) { |
|
| 213 | + foreach (array('readonly', 'disabled') as $k) { |
|
| 214 | 214 | |
| 215 | - if( !empty($field[ $k ]) ) $atts[ $k ] = $k; |
|
| 215 | + if ( ! empty($field[$k])) $atts[$k] = $k; |
|
| 216 | 216 | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | // hidden input |
| 221 | - if( $field['ui'] ) { |
|
| 221 | + if ($field['ui']) { |
|
| 222 | 222 | |
| 223 | 223 | $v = $field['value']; |
| 224 | 224 | |
| 225 | - if( $field['multiple'] ) { |
|
| 225 | + if ($field['multiple']) { |
|
| 226 | 226 | |
| 227 | 227 | $v = implode('||', $v); |
| 228 | 228 | |
@@ -233,15 +233,15 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | acf_hidden_input(array( |
| 236 | - 'id' => $field['id'] . '-input', |
|
| 236 | + 'id' => $field['id'].'-input', |
|
| 237 | 237 | 'name' => $field['name'], |
| 238 | 238 | 'value' => $v |
| 239 | 239 | )); |
| 240 | 240 | |
| 241 | - } elseif( $field['multiple'] ) { |
|
| 241 | + } elseif ($field['multiple']) { |
|
| 242 | 242 | |
| 243 | 243 | acf_hidden_input(array( |
| 244 | - 'id' => $field['id'] . '-input', |
|
| 244 | + 'id' => $field['id'].'-input', |
|
| 245 | 245 | 'name' => $field['name'] |
| 246 | 246 | )); |
| 247 | 247 | |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | |
| 252 | 252 | // open |
| 253 | - echo '<select ' . acf_esc_attr($atts) . '>'; |
|
| 253 | + echo '<select '.acf_esc_attr($atts).'>'; |
|
| 254 | 254 | |
| 255 | 255 | |
| 256 | 256 | // walk |
| 257 | - $this->walk( $field['choices'], $field['value'] ); |
|
| 257 | + $this->walk($field['choices'], $field['value']); |
|
| 258 | 258 | |
| 259 | 259 | |
| 260 | 260 | // close |
@@ -276,24 +276,24 @@ discard block |
||
| 276 | 276 | * @return $post_id (int) |
| 277 | 277 | */ |
| 278 | 278 | |
| 279 | - function walk( $choices, $values ) { |
|
| 279 | + function walk($choices, $values) { |
|
| 280 | 280 | |
| 281 | 281 | // bail ealry if no choices |
| 282 | - if( empty($choices) ) return; |
|
| 282 | + if (empty($choices)) return; |
|
| 283 | 283 | |
| 284 | 284 | |
| 285 | 285 | // loop |
| 286 | - foreach( $choices as $k => $v ) { |
|
| 286 | + foreach ($choices as $k => $v) { |
|
| 287 | 287 | |
| 288 | 288 | // optgroup |
| 289 | - if( is_array($v) ){ |
|
| 289 | + if (is_array($v)) { |
|
| 290 | 290 | |
| 291 | 291 | // optgroup |
| 292 | - echo '<optgroup label="' . esc_attr($k) . '">'; |
|
| 292 | + echo '<optgroup label="'.esc_attr($k).'">'; |
|
| 293 | 293 | |
| 294 | 294 | |
| 295 | 295 | // walk |
| 296 | - $this->walk( $v, $values ); |
|
| 296 | + $this->walk($v, $values); |
|
| 297 | 297 | |
| 298 | 298 | |
| 299 | 299 | // close optgroup |
@@ -309,11 +309,11 @@ discard block |
||
| 309 | 309 | // vars |
| 310 | 310 | $search = html_entity_decode($k); |
| 311 | 311 | $pos = array_search($search, $values); |
| 312 | - $atts = array( 'value' => $k ); |
|
| 312 | + $atts = array('value' => $k); |
|
| 313 | 313 | |
| 314 | 314 | |
| 315 | 315 | // validate selected |
| 316 | - if( $pos !== false ) { |
|
| 316 | + if ($pos !== false) { |
|
| 317 | 317 | |
| 318 | 318 | $atts['selected'] = 'selected'; |
| 319 | 319 | $atts['data-i'] = $pos; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | |
| 324 | 324 | // option |
| 325 | - echo '<option ' . acf_esc_attr($atts) . '>' . $v . '</option>'; |
|
| 325 | + echo '<option '.acf_esc_attr($atts).'>'.$v.'</option>'; |
|
| 326 | 326 | |
| 327 | 327 | } |
| 328 | 328 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @param $field - an array holding all the field's data |
| 343 | 343 | */ |
| 344 | 344 | |
| 345 | - function render_field_settings( $field ) { |
|
| 345 | + function render_field_settings($field) { |
|
| 346 | 346 | |
| 347 | 347 | // encode choices (convert from array) |
| 348 | 348 | $field['choices'] = acf_encode_choices($field['choices']); |
@@ -350,74 +350,74 @@ discard block |
||
| 350 | 350 | |
| 351 | 351 | |
| 352 | 352 | // choices |
| 353 | - acf_render_field_setting( $field, array( |
|
| 354 | - 'label' => __('Choices','acf'), |
|
| 355 | - 'instructions' => __('Enter each choice on a new line.','acf') . '<br /><br />' . __('For more control, you may specify both a value and label like this:','acf'). '<br /><br />' . __('red : Red','acf'), |
|
| 353 | + acf_render_field_setting($field, array( |
|
| 354 | + 'label' => __('Choices', 'acf'), |
|
| 355 | + 'instructions' => __('Enter each choice on a new line.', 'acf').'<br /><br />'.__('For more control, you may specify both a value and label like this:', 'acf').'<br /><br />'.__('red : Red', 'acf'), |
|
| 356 | 356 | 'type' => 'textarea', |
| 357 | 357 | 'name' => 'choices', |
| 358 | 358 | )); |
| 359 | 359 | |
| 360 | 360 | |
| 361 | 361 | // default_value |
| 362 | - acf_render_field_setting( $field, array( |
|
| 363 | - 'label' => __('Default Value','acf'), |
|
| 364 | - 'instructions' => __('Enter each default value on a new line','acf'), |
|
| 362 | + acf_render_field_setting($field, array( |
|
| 363 | + 'label' => __('Default Value', 'acf'), |
|
| 364 | + 'instructions' => __('Enter each default value on a new line', 'acf'), |
|
| 365 | 365 | 'type' => 'textarea', |
| 366 | 366 | 'name' => 'default_value', |
| 367 | 367 | )); |
| 368 | 368 | |
| 369 | 369 | |
| 370 | 370 | // allow_null |
| 371 | - acf_render_field_setting( $field, array( |
|
| 372 | - 'label' => __('Allow Null?','acf'), |
|
| 371 | + acf_render_field_setting($field, array( |
|
| 372 | + 'label' => __('Allow Null?', 'acf'), |
|
| 373 | 373 | 'instructions' => '', |
| 374 | 374 | 'type' => 'radio', |
| 375 | 375 | 'name' => 'allow_null', |
| 376 | 376 | 'choices' => array( |
| 377 | - 1 => __("Yes",'acf'), |
|
| 378 | - 0 => __("No",'acf'), |
|
| 377 | + 1 => __("Yes", 'acf'), |
|
| 378 | + 0 => __("No", 'acf'), |
|
| 379 | 379 | ), |
| 380 | 380 | 'layout' => 'horizontal', |
| 381 | 381 | )); |
| 382 | 382 | |
| 383 | 383 | |
| 384 | 384 | // multiple |
| 385 | - acf_render_field_setting( $field, array( |
|
| 386 | - 'label' => __('Select multiple values?','acf'), |
|
| 385 | + acf_render_field_setting($field, array( |
|
| 386 | + 'label' => __('Select multiple values?', 'acf'), |
|
| 387 | 387 | 'instructions' => '', |
| 388 | 388 | 'type' => 'radio', |
| 389 | 389 | 'name' => 'multiple', |
| 390 | 390 | 'choices' => array( |
| 391 | - 1 => __("Yes",'acf'), |
|
| 392 | - 0 => __("No",'acf'), |
|
| 391 | + 1 => __("Yes", 'acf'), |
|
| 392 | + 0 => __("No", 'acf'), |
|
| 393 | 393 | ), |
| 394 | 394 | 'layout' => 'horizontal', |
| 395 | 395 | )); |
| 396 | 396 | |
| 397 | 397 | |
| 398 | 398 | // ui |
| 399 | - acf_render_field_setting( $field, array( |
|
| 400 | - 'label' => __('Stylised UI','acf'), |
|
| 399 | + acf_render_field_setting($field, array( |
|
| 400 | + 'label' => __('Stylised UI', 'acf'), |
|
| 401 | 401 | 'instructions' => '', |
| 402 | 402 | 'type' => 'radio', |
| 403 | 403 | 'name' => 'ui', |
| 404 | 404 | 'choices' => array( |
| 405 | - 1 => __("Yes",'acf'), |
|
| 406 | - 0 => __("No",'acf'), |
|
| 405 | + 1 => __("Yes", 'acf'), |
|
| 406 | + 0 => __("No", 'acf'), |
|
| 407 | 407 | ), |
| 408 | 408 | 'layout' => 'horizontal', |
| 409 | 409 | )); |
| 410 | 410 | |
| 411 | 411 | |
| 412 | 412 | // ajax |
| 413 | - acf_render_field_setting( $field, array( |
|
| 414 | - 'label' => __('Use AJAX to lazy load choices?','acf'), |
|
| 413 | + acf_render_field_setting($field, array( |
|
| 414 | + 'label' => __('Use AJAX to lazy load choices?', 'acf'), |
|
| 415 | 415 | 'instructions' => '', |
| 416 | 416 | 'type' => 'radio', |
| 417 | 417 | 'name' => 'ajax', |
| 418 | 418 | 'choices' => array( |
| 419 | - 1 => __("Yes",'acf'), |
|
| 420 | - 0 => __("No",'acf'), |
|
| 419 | + 1 => __("Yes", 'acf'), |
|
| 420 | + 0 => __("No", 'acf'), |
|
| 421 | 421 | ), |
| 422 | 422 | 'layout' => 'horizontal', |
| 423 | 423 | )); |
@@ -440,10 +440,10 @@ discard block |
||
| 440 | 440 | * @return $value |
| 441 | 441 | */ |
| 442 | 442 | |
| 443 | - function load_value( $value, $post_id, $field ) { |
|
| 443 | + function load_value($value, $post_id, $field) { |
|
| 444 | 444 | |
| 445 | 445 | // ACF4 null |
| 446 | - if( $value === 'null' ) return false; |
|
| 446 | + if ($value === 'null') return false; |
|
| 447 | 447 | |
| 448 | 448 | |
| 449 | 449 | // return |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | * @return $field - the modified field |
| 467 | 467 | */ |
| 468 | 468 | |
| 469 | - function update_field( $field ) { |
|
| 469 | + function update_field($field) { |
|
| 470 | 470 | |
| 471 | 471 | // decode choices (convert to array) |
| 472 | 472 | $field['choices'] = acf_decode_choices($field['choices']); |
@@ -494,10 +494,10 @@ discard block |
||
| 494 | 494 | * @return $value - the modified value |
| 495 | 495 | */ |
| 496 | 496 | |
| 497 | - function update_value( $value, $post_id, $field ) { |
|
| 497 | + function update_value($value, $post_id, $field) { |
|
| 498 | 498 | |
| 499 | 499 | // validate |
| 500 | - if( empty($value) ) { |
|
| 500 | + if (empty($value)) { |
|
| 501 | 501 | |
| 502 | 502 | return $value; |
| 503 | 503 | |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | |
| 507 | 507 | // array |
| 508 | - if( is_array($value) ) { |
|
| 508 | + if (is_array($value)) { |
|
| 509 | 509 | |
| 510 | 510 | // save value as strings, so we can clearly search for them in SQL LIKE statements |
| 511 | 511 | $value = array_map('strval', $value); |
@@ -561,15 +561,15 @@ discard block |
||
| 561 | 561 | */ |
| 562 | 562 | |
| 563 | 563 | // scripts |
| 564 | - wp_enqueue_script('select2', acf_get_dir("assets/inc/select2/select2{$min}.js"), array('jquery'), $version, true ); |
|
| 564 | + wp_enqueue_script('select2', acf_get_dir("assets/inc/select2/select2{$min}.js"), array('jquery'), $version, true); |
|
| 565 | 565 | |
| 566 | 566 | |
| 567 | 567 | // styles |
| 568 | - wp_enqueue_style('select2', acf_get_dir('assets/inc/select2/select2.css'), '', $version ); |
|
| 568 | + wp_enqueue_style('select2', acf_get_dir('assets/inc/select2/select2.css'), '', $version); |
|
| 569 | 569 | |
| 570 | 570 | |
| 571 | 571 | // bail early if no language |
| 572 | - if( !$lang ) return; |
|
| 572 | + if ( ! $lang) return; |
|
| 573 | 573 | |
| 574 | 574 | |
| 575 | 575 | // vars |
@@ -579,11 +579,11 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | |
| 581 | 581 | // attempt 1 |
| 582 | - if( file_exists(acf_get_path("assets/inc/select2/select2_locale_{$lang_code}.js")) ) { |
|
| 582 | + if (file_exists(acf_get_path("assets/inc/select2/select2_locale_{$lang_code}.js"))) { |
|
| 583 | 583 | |
| 584 | 584 | $src = acf_get_dir("assets/inc/select2/select2_locale_{$lang_code}.js"); |
| 585 | 585 | |
| 586 | - } elseif( file_exists(acf_get_path("assets/inc/select2/select2_locale_{$lang}.js")) ) { |
|
| 586 | + } elseif (file_exists(acf_get_path("assets/inc/select2/select2_locale_{$lang}.js"))) { |
|
| 587 | 587 | |
| 588 | 588 | $src = acf_get_dir("assets/inc/select2/select2_locale_{$lang}.js"); |
| 589 | 589 | |
@@ -591,11 +591,11 @@ discard block |
||
| 591 | 591 | |
| 592 | 592 | |
| 593 | 593 | // bail early if no language |
| 594 | - if( !$src ) return; |
|
| 594 | + if ( ! $src) return; |
|
| 595 | 595 | |
| 596 | 596 | |
| 597 | 597 | // scripts |
| 598 | - wp_enqueue_script('select2-l10n', $src, '', $version, true ); |
|
| 598 | + wp_enqueue_script('select2-l10n', $src, '', $version, true); |
|
| 599 | 599 | |
| 600 | 600 | } |
| 601 | 601 | |
@@ -212,7 +212,9 @@ discard block |
||
| 212 | 212 | // special atts |
| 213 | 213 | foreach( array( 'readonly', 'disabled' ) as $k ) { |
| 214 | 214 | |
| 215 | - if( !empty($field[ $k ]) ) $atts[ $k ] = $k; |
|
| 215 | + if( !empty($field[ $k ]) ) { |
|
| 216 | + $atts[ $k ] = $k; |
|
| 217 | + } |
|
| 216 | 218 | |
| 217 | 219 | } |
| 218 | 220 | |
@@ -279,7 +281,9 @@ discard block |
||
| 279 | 281 | function walk( $choices, $values ) { |
| 280 | 282 | |
| 281 | 283 | // bail ealry if no choices |
| 282 | - if( empty($choices) ) return; |
|
| 284 | + if( empty($choices) ) { |
|
| 285 | + return; |
|
| 286 | + } |
|
| 283 | 287 | |
| 284 | 288 | |
| 285 | 289 | // loop |
@@ -443,7 +447,9 @@ discard block |
||
| 443 | 447 | function load_value( $value, $post_id, $field ) { |
| 444 | 448 | |
| 445 | 449 | // ACF4 null |
| 446 | - if( $value === 'null' ) return false; |
|
| 450 | + if( $value === 'null' ) { |
|
| 451 | + return false; |
|
| 452 | + } |
|
| 447 | 453 | |
| 448 | 454 | |
| 449 | 455 | // return |
@@ -569,7 +575,9 @@ discard block |
||
| 569 | 575 | |
| 570 | 576 | |
| 571 | 577 | // bail early if no language |
| 572 | - if( !$lang ) return; |
|
| 578 | + if( !$lang ) { |
|
| 579 | + return; |
|
| 580 | + } |
|
| 573 | 581 | |
| 574 | 582 | |
| 575 | 583 | // vars |
@@ -591,7 +599,9 @@ discard block |
||
| 591 | 599 | |
| 592 | 600 | |
| 593 | 601 | // bail early if no language |
| 594 | - if( !$src ) return; |
|
| 602 | + if( !$src ) { |
|
| 603 | + return; |
|
| 604 | + } |
|
| 595 | 605 | |
| 596 | 606 | |
| 597 | 607 | // scripts |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // do not delete! |
| 53 | - parent::__construct(); |
|
| 53 | + parent::__construct(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_tab') ) : |
|
| 14 | +if ( ! class_exists('acf_field_tab')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_tab extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'tab'; |
| 36 | - $this->label = __("Tab",'acf'); |
|
| 36 | + $this->label = __("Tab", 'acf'); |
|
| 37 | 37 | $this->category = 'layout'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'value' => false, // prevents acf_render_fields() from attempting to load value |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @date 23/01/13 |
| 91 | 91 | */ |
| 92 | 92 | |
| 93 | - function render_field( $field ) { |
|
| 93 | + function render_field($field) { |
|
| 94 | 94 | |
| 95 | 95 | // vars |
| 96 | 96 | $atts = array( |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | 102 | ?> |
| 103 | - <div <?php acf_esc_attr_e( $atts ); ?>><?php echo $field['label']; ?></div> |
|
| 103 | + <div <?php acf_esc_attr_e($atts); ?>><?php echo $field['label']; ?></div> |
|
| 104 | 104 | <?php |
| 105 | 105 | |
| 106 | 106 | |
@@ -121,17 +121,17 @@ discard block |
||
| 121 | 121 | * @date 23/01/13 |
| 122 | 122 | */ |
| 123 | 123 | |
| 124 | - function render_field_settings( $field ) { |
|
| 124 | + function render_field_settings($field) { |
|
| 125 | 125 | |
| 126 | 126 | // message |
| 127 | 127 | $message = ''; |
| 128 | - $message .= '<span class="acf-error-message"><p>' . __("The tab field will display incorrectly when added to a Table style repeater field or flexible content field layout", 'acf') . '</p></span>'; |
|
| 129 | - $message .= '<p>' . __( 'Use "Tab Fields" to better organize your edit screen by grouping fields together.', 'acf') . '</p>'; |
|
| 130 | - $message .= '<p>' . __( 'All fields following this "tab field" (or until another "tab field" is defined) will be grouped together using this field\'s label as the tab heading.','acf') . '</p>'; |
|
| 128 | + $message .= '<span class="acf-error-message"><p>'.__("The tab field will display incorrectly when added to a Table style repeater field or flexible content field layout", 'acf').'</p></span>'; |
|
| 129 | + $message .= '<p>'.__('Use "Tab Fields" to better organize your edit screen by grouping fields together.', 'acf').'</p>'; |
|
| 130 | + $message .= '<p>'.__('All fields following this "tab field" (or until another "tab field" is defined) will be grouped together using this field\'s label as the tab heading.', 'acf').'</p>'; |
|
| 131 | 131 | |
| 132 | 132 | // default_value |
| 133 | - acf_render_field_setting( $field, array( |
|
| 134 | - 'label' => __('Instructions','acf'), |
|
| 133 | + acf_render_field_setting($field, array( |
|
| 134 | + 'label' => __('Instructions', 'acf'), |
|
| 135 | 135 | 'instructions' => '', |
| 136 | 136 | 'type' => 'message', |
| 137 | 137 | 'message' => $message, |
@@ -140,26 +140,26 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | // preview_size |
| 143 | - acf_render_field_setting( $field, array( |
|
| 144 | - 'label' => __('Placement','acf'), |
|
| 143 | + acf_render_field_setting($field, array( |
|
| 144 | + 'label' => __('Placement', 'acf'), |
|
| 145 | 145 | 'type' => 'select', |
| 146 | 146 | 'name' => 'placement', |
| 147 | 147 | 'choices' => array( |
| 148 | - 'top' => __("Top aligned",'acf'), |
|
| 149 | - 'left' => __("Left Aligned",'acf'), |
|
| 148 | + 'top' => __("Top aligned", 'acf'), |
|
| 149 | + 'left' => __("Left Aligned", 'acf'), |
|
| 150 | 150 | ) |
| 151 | 151 | )); |
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | // endpoint |
| 155 | - acf_render_field_setting( $field, array( |
|
| 156 | - 'label' => __('End-point','acf'), |
|
| 157 | - 'instructions' => __('Use this field as an end-point and start a new group of tabs','acf'), |
|
| 155 | + acf_render_field_setting($field, array( |
|
| 156 | + 'label' => __('End-point', 'acf'), |
|
| 157 | + 'instructions' => __('Use this field as an end-point and start a new group of tabs', 'acf'), |
|
| 158 | 158 | 'type' => 'radio', |
| 159 | 159 | 'name' => 'endpoint', |
| 160 | 160 | 'choices' => array( |
| 161 | - 1 => __("Yes",'acf'), |
|
| 162 | - 0 => __("No",'acf'), |
|
| 161 | + 1 => __("Yes", 'acf'), |
|
| 162 | + 0 => __("No", 'acf'), |
|
| 163 | 163 | ), |
| 164 | 164 | 'layout' => 'horizontal', |
| 165 | 165 | )); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // do not delete! |
| 53 | - parent::__construct(); |
|
| 53 | + parent::__construct(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_taxonomy') ) : |
|
| 14 | +if ( ! class_exists('acf_field_taxonomy')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_taxonomy extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'taxonomy'; |
| 36 | - $this->label = __("Taxonomy",'acf'); |
|
| 36 | + $this->label = __("Taxonomy", 'acf'); |
|
| 37 | 37 | $this->category = 'relational'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'taxonomy' => 'category', |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | // extra |
| 52 | - add_action('wp_ajax_acf/fields/taxonomy/query', array($this, 'ajax_query')); |
|
| 53 | - add_action('wp_ajax_nopriv_acf/fields/taxonomy/query', array($this, 'ajax_query')); |
|
| 54 | - add_action('wp_ajax_acf/fields/taxonomy/add_term', array($this, 'ajax_add_term')); |
|
| 52 | + add_action('wp_ajax_acf/fields/taxonomy/query', array($this, 'ajax_query')); |
|
| 53 | + add_action('wp_ajax_nopriv_acf/fields/taxonomy/query', array($this, 'ajax_query')); |
|
| 54 | + add_action('wp_ajax_acf/fields/taxonomy/add_term', array($this, 'ajax_add_term')); |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | // do not delete! |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @return (array) |
| 74 | 74 | */ |
| 75 | 75 | |
| 76 | - function get_choices( $options = array() ) { |
|
| 76 | + function get_choices($options = array()) { |
|
| 77 | 77 | |
| 78 | 78 | // defaults |
| 79 | 79 | $options = acf_parse_args($options, array( |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | // load field |
| 88 | - $field = acf_get_field( $options['field_key'] ); |
|
| 88 | + $field = acf_get_field($options['field_key']); |
|
| 89 | 89 | |
| 90 | - if( !$field ) { |
|
| 90 | + if ( ! $field) { |
|
| 91 | 91 | |
| 92 | 92 | return false; |
| 93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | // vars |
| 98 | 98 | $r = array(); |
| 99 | 99 | $args = array(); |
| 100 | - $is_hierarchical = is_taxonomy_hierarchical( $field['taxonomy'] ); |
|
| 100 | + $is_hierarchical = is_taxonomy_hierarchical($field['taxonomy']); |
|
| 101 | 101 | $is_pagination = ($options['paged'] > 0); |
| 102 | 102 | $limit = 20; |
| 103 | 103 | $offset = 20 * ($options['paged'] - 1); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | // pagination |
| 111 | 111 | // - don't bother for hierarchial terms, we will need to load all terms anyway |
| 112 | - if( !$is_hierarchical && $is_pagination ) { |
|
| 112 | + if ( ! $is_hierarchical && $is_pagination) { |
|
| 113 | 113 | |
| 114 | 114 | $args['offset'] = $offset; |
| 115 | 115 | $args['number'] = $limit; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | |
| 120 | 120 | // search |
| 121 | - if( $options['s'] ) { |
|
| 121 | + if ($options['s']) { |
|
| 122 | 122 | |
| 123 | 123 | $args['search'] = $options['s']; |
| 124 | 124 | |
@@ -127,32 +127,32 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | // filters |
| 129 | 129 | $args = apply_filters('acf/fields/taxonomy/query', $args, $field, $options['post_id']); |
| 130 | - $args = apply_filters('acf/fields/taxonomy/query/name=' . $field['name'], $args, $field, $options['post_id'] ); |
|
| 131 | - $args = apply_filters('acf/fields/taxonomy/query/key=' . $field['key'], $args, $field, $options['post_id'] ); |
|
| 130 | + $args = apply_filters('acf/fields/taxonomy/query/name='.$field['name'], $args, $field, $options['post_id']); |
|
| 131 | + $args = apply_filters('acf/fields/taxonomy/query/key='.$field['key'], $args, $field, $options['post_id']); |
|
| 132 | 132 | |
| 133 | 133 | |
| 134 | 134 | // get terms |
| 135 | - $terms = get_terms( $field['taxonomy'], $args ); |
|
| 135 | + $terms = get_terms($field['taxonomy'], $args); |
|
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | // sort into hierachial order! |
| 139 | - if( $is_hierarchical ) { |
|
| 139 | + if ($is_hierarchical) { |
|
| 140 | 140 | |
| 141 | 141 | // get parent |
| 142 | - $parent = acf_maybe_get( $args, 'parent', 0 ); |
|
| 143 | - $parent = acf_maybe_get( $args, 'child_of', $parent ); |
|
| 142 | + $parent = acf_maybe_get($args, 'parent', 0); |
|
| 143 | + $parent = acf_maybe_get($args, 'child_of', $parent); |
|
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | // this will fail if a search has taken place because parents wont exist |
| 147 | - if( empty($args['search']) ) { |
|
| 147 | + if (empty($args['search'])) { |
|
| 148 | 148 | |
| 149 | - $terms = _get_term_children( $parent, $terms, $field['taxonomy'] ); |
|
| 149 | + $terms = _get_term_children($parent, $terms, $field['taxonomy']); |
|
| 150 | 150 | |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | // fake pagination |
| 155 | - if( $is_pagination ) { |
|
| 155 | + if ($is_pagination) { |
|
| 156 | 156 | |
| 157 | 157 | $terms = array_slice($terms, $offset, $limit); |
| 158 | 158 | |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | /// append to r |
| 165 | - foreach( $terms as $term ) { |
|
| 165 | + foreach ($terms as $term) { |
|
| 166 | 166 | |
| 167 | 167 | // add to json |
| 168 | 168 | $r[] = array( |
| 169 | 169 | 'id' => $term->term_id, |
| 170 | - 'text' => $this->get_term_title( $term, $field, $options['post_id'] ) |
|
| 170 | + 'text' => $this->get_term_title($term, $field, $options['post_id']) |
|
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | 173 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | function ajax_query() { |
| 196 | 196 | |
| 197 | 197 | // validate |
| 198 | - if( !acf_verify_ajax() ) { |
|
| 198 | + if ( ! acf_verify_ajax()) { |
|
| 199 | 199 | |
| 200 | 200 | die(); |
| 201 | 201 | |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | |
| 205 | 205 | // get choices |
| 206 | - $choices = $this->get_choices( $_POST ); |
|
| 206 | + $choices = $this->get_choices($_POST); |
|
| 207 | 207 | |
| 208 | 208 | |
| 209 | 209 | // validate |
| 210 | - if( !$choices ) { |
|
| 210 | + if ( ! $choices) { |
|
| 211 | 211 | |
| 212 | 212 | die(); |
| 213 | 213 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | |
| 217 | 217 | // return JSON |
| 218 | - echo json_encode( $choices ); |
|
| 218 | + echo json_encode($choices); |
|
| 219 | 219 | die(); |
| 220 | 220 | |
| 221 | 221 | } |
@@ -236,14 +236,14 @@ discard block |
||
| 236 | 236 | * @return (string) |
| 237 | 237 | */ |
| 238 | 238 | |
| 239 | - function get_term_title( $term, $field, $post_id = 0 ) { |
|
| 239 | + function get_term_title($term, $field, $post_id = 0) { |
|
| 240 | 240 | |
| 241 | 241 | // get post_id |
| 242 | - if( !$post_id ) { |
|
| 242 | + if ( ! $post_id) { |
|
| 243 | 243 | |
| 244 | 244 | $form_data = acf_get_setting('form_data'); |
| 245 | 245 | |
| 246 | - if( !empty($form_data['post_id']) ) { |
|
| 246 | + if ( ! empty($form_data['post_id'])) { |
|
| 247 | 247 | |
| 248 | 248 | $post_id = $form_data['post_id']; |
| 249 | 249 | |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | // ancestors |
| 263 | - $ancestors = get_ancestors( $term->term_id, $field['taxonomy'] ); |
|
| 263 | + $ancestors = get_ancestors($term->term_id, $field['taxonomy']); |
|
| 264 | 264 | |
| 265 | - if( !empty($ancestors) ) { |
|
| 265 | + if ( ! empty($ancestors)) { |
|
| 266 | 266 | |
| 267 | 267 | $title .= str_repeat('- ', count($ancestors)); |
| 268 | 268 | |
@@ -275,8 +275,8 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | // filters |
| 277 | 277 | $title = apply_filters('acf/fields/taxonomy/result', $title, $term, $field, $post_id); |
| 278 | - $title = apply_filters('acf/fields/taxonomy/result/name=' . $field['_name'] , $title, $term, $field, $post_id); |
|
| 279 | - $title = apply_filters('acf/fields/taxonomy/result/key=' . $field['key'], $title, $term, $field, $post_id); |
|
| 278 | + $title = apply_filters('acf/fields/taxonomy/result/name='.$field['_name'], $title, $term, $field, $post_id); |
|
| 279 | + $title = apply_filters('acf/fields/taxonomy/result/key='.$field['key'], $title, $term, $field, $post_id); |
|
| 280 | 280 | |
| 281 | 281 | |
| 282 | 282 | // return |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | * @return $value |
| 298 | 298 | */ |
| 299 | 299 | |
| 300 | - function get_terms( $value, $taxonomy = 'category' ) { |
|
| 300 | + function get_terms($value, $taxonomy = 'category') { |
|
| 301 | 301 | |
| 302 | 302 | // load terms in 1 query to save multiple DB calls from following code |
| 303 | - if( count($value) > 1 ) { |
|
| 303 | + if (count($value) > 1) { |
|
| 304 | 304 | |
| 305 | 305 | $terms = get_terms($taxonomy, array( |
| 306 | 306 | 'hide_empty' => false, |
@@ -311,9 +311,9 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | |
| 313 | 313 | // update value to include $post |
| 314 | - foreach( array_keys($value) as $i ) { |
|
| 314 | + foreach (array_keys($value) as $i) { |
|
| 315 | 315 | |
| 316 | - $value[ $i ] = get_term( $value[ $i ], $taxonomy ); |
|
| 316 | + $value[$i] = get_term($value[$i], $taxonomy); |
|
| 317 | 317 | |
| 318 | 318 | } |
| 319 | 319 | |
@@ -343,21 +343,21 @@ discard block |
||
| 343 | 343 | * @return $value - the value to be saved in te database |
| 344 | 344 | */ |
| 345 | 345 | |
| 346 | - function load_value( $value, $post_id, $field ) { |
|
| 346 | + function load_value($value, $post_id, $field) { |
|
| 347 | 347 | |
| 348 | 348 | // get valid terms |
| 349 | 349 | $value = acf_get_valid_terms($value, $field['taxonomy']); |
| 350 | 350 | |
| 351 | 351 | |
| 352 | 352 | // load/save |
| 353 | - if( $field['load_terms'] ) { |
|
| 353 | + if ($field['load_terms']) { |
|
| 354 | 354 | |
| 355 | 355 | // get terms |
| 356 | 356 | $term_ids = wp_get_object_terms($post_id, $field['taxonomy'], array('fields' => 'ids', 'orderby' => 'none')); |
| 357 | 357 | |
| 358 | 358 | |
| 359 | 359 | // error |
| 360 | - if( is_wp_error($term_ids) ) { |
|
| 360 | + if (is_wp_error($term_ids)) { |
|
| 361 | 361 | |
| 362 | 362 | return false; |
| 363 | 363 | |
@@ -392,10 +392,10 @@ discard block |
||
| 392 | 392 | * @return $value - the modified value |
| 393 | 393 | */ |
| 394 | 394 | |
| 395 | - function update_value( $value, $post_id, $field ) { |
|
| 395 | + function update_value($value, $post_id, $field) { |
|
| 396 | 396 | |
| 397 | 397 | // vars |
| 398 | - if( is_array($value) ) { |
|
| 398 | + if (is_array($value)) { |
|
| 399 | 399 | |
| 400 | 400 | $value = array_filter($value); |
| 401 | 401 | |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | |
| 405 | 405 | // save_terms |
| 406 | - if( $field['save_terms'] ) { |
|
| 406 | + if ($field['save_terms']) { |
|
| 407 | 407 | |
| 408 | 408 | // vars |
| 409 | 409 | $taxonomy = $field['taxonomy']; |
| 410 | 410 | |
| 411 | 411 | |
| 412 | 412 | // force value to array |
| 413 | - $term_ids = acf_get_array( $value ); |
|
| 413 | + $term_ids = acf_get_array($value); |
|
| 414 | 414 | |
| 415 | 415 | |
| 416 | 416 | // convert to int |
@@ -418,9 +418,9 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | |
| 420 | 420 | // bypass $this->set_terms if called directly from update_field |
| 421 | - if( !did_action('acf/save_post') ) { |
|
| 421 | + if ( ! did_action('acf/save_post')) { |
|
| 422 | 422 | |
| 423 | - wp_set_object_terms( $post_id, $term_ids, $taxonomy, false ); |
|
| 423 | + wp_set_object_terms($post_id, $term_ids, $taxonomy, false); |
|
| 424 | 424 | |
| 425 | 425 | return $value; |
| 426 | 426 | |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | |
| 429 | 429 | |
| 430 | 430 | // initialize |
| 431 | - if( empty($this->set_terms) ) { |
|
| 431 | + if (empty($this->set_terms)) { |
|
| 432 | 432 | |
| 433 | 433 | // create holder |
| 434 | 434 | $this->set_terms = array(); |
@@ -441,13 +441,13 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | |
| 443 | 443 | // append |
| 444 | - if( empty($this->set_terms[ $taxonomy ]) ) { |
|
| 444 | + if (empty($this->set_terms[$taxonomy])) { |
|
| 445 | 445 | |
| 446 | - $this->set_terms[ $taxonomy ] = array(); |
|
| 446 | + $this->set_terms[$taxonomy] = array(); |
|
| 447 | 447 | |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - $this->set_terms[ $taxonomy ] = array_merge($this->set_terms[ $taxonomy ], $term_ids); |
|
| 450 | + $this->set_terms[$taxonomy] = array_merge($this->set_terms[$taxonomy], $term_ids); |
|
| 451 | 451 | |
| 452 | 452 | } |
| 453 | 453 | |
@@ -471,10 +471,10 @@ discard block |
||
| 471 | 471 | * @return $post_id (int) |
| 472 | 472 | */ |
| 473 | 473 | |
| 474 | - function set_terms( $post_id ) { |
|
| 474 | + function set_terms($post_id) { |
|
| 475 | 475 | |
| 476 | 476 | // bail ealry if no terms |
| 477 | - if( empty($this->set_terms) ) { |
|
| 477 | + if (empty($this->set_terms)) { |
|
| 478 | 478 | |
| 479 | 479 | return; |
| 480 | 480 | |
@@ -482,9 +482,9 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | |
| 484 | 484 | // loop over terms |
| 485 | - foreach( $this->set_terms as $taxonomy => $term_ids ){ |
|
| 485 | + foreach ($this->set_terms as $taxonomy => $term_ids) { |
|
| 486 | 486 | |
| 487 | - wp_set_object_terms( $post_id, $term_ids, $taxonomy, false ); |
|
| 487 | + wp_set_object_terms($post_id, $term_ids, $taxonomy, false); |
|
| 488 | 488 | |
| 489 | 489 | } |
| 490 | 490 | |
@@ -511,10 +511,10 @@ discard block |
||
| 511 | 511 | * @return $value (mixed) the modified value |
| 512 | 512 | */ |
| 513 | 513 | |
| 514 | - function format_value( $value, $post_id, $field ) { |
|
| 514 | + function format_value($value, $post_id, $field) { |
|
| 515 | 515 | |
| 516 | 516 | // bail early if no value |
| 517 | - if( empty($value) ) { |
|
| 517 | + if (empty($value)) { |
|
| 518 | 518 | |
| 519 | 519 | return $value; |
| 520 | 520 | |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | |
| 523 | 523 | |
| 524 | 524 | // force value to array |
| 525 | - $value = acf_get_array( $value ); |
|
| 525 | + $value = acf_get_array($value); |
|
| 526 | 526 | |
| 527 | 527 | |
| 528 | 528 | // convert values to int |
@@ -530,16 +530,16 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | |
| 532 | 532 | // load posts if needed |
| 533 | - if( $field['return_format'] == 'object' ) { |
|
| 533 | + if ($field['return_format'] == 'object') { |
|
| 534 | 534 | |
| 535 | 535 | // get posts |
| 536 | - $value = $this->get_terms( $value, $field["taxonomy"] ); |
|
| 536 | + $value = $this->get_terms($value, $field["taxonomy"]); |
|
| 537 | 537 | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | |
| 541 | 541 | // convert back from array if neccessary |
| 542 | - if( $field['field_type'] == 'select' || $field['field_type'] == 'radio' ) { |
|
| 542 | + if ($field['field_type'] == 'select' || $field['field_type'] == 'radio') { |
|
| 543 | 543 | |
| 544 | 544 | $value = array_shift($value); |
| 545 | 545 | |
@@ -563,10 +563,10 @@ discard block |
||
| 563 | 563 | * @param $field - an array holding all the field's data |
| 564 | 564 | */ |
| 565 | 565 | |
| 566 | - function render_field( $field ) { |
|
| 566 | + function render_field($field) { |
|
| 567 | 567 | |
| 568 | 568 | // force value to array |
| 569 | - $field['value'] = acf_get_array( $field['value'] ); |
|
| 569 | + $field['value'] = acf_get_array($field['value']); |
|
| 570 | 570 | |
| 571 | 571 | |
| 572 | 572 | // convert values to int |
@@ -583,33 +583,33 @@ discard block |
||
| 583 | 583 | |
| 584 | 584 | |
| 585 | 585 | // get taxonomy |
| 586 | - $taxonomy = get_taxonomy( $field['taxonomy'] ); |
|
| 586 | + $taxonomy = get_taxonomy($field['taxonomy']); |
|
| 587 | 587 | |
| 588 | 588 | ?> |
| 589 | 589 | <div <?php acf_esc_attr_e($div); ?>> |
| 590 | - <?php if( $field['add_term'] && current_user_can( $taxonomy->cap->manage_terms) ): ?> |
|
| 590 | + <?php if ($field['add_term'] && current_user_can($taxonomy->cap->manage_terms)): ?> |
|
| 591 | 591 | <a href="#" class="acf-icon -plus acf-js-tooltip small acf-soh-target" data-name="add" title="<?php echo esc_attr($taxonomy->labels->add_new_item); ?>"></a> |
| 592 | 592 | <?php endif; |
| 593 | 593 | |
| 594 | - if( $field['field_type'] == 'select' ) { |
|
| 594 | + if ($field['field_type'] == 'select') { |
|
| 595 | 595 | |
| 596 | 596 | $field['multiple'] = 0; |
| 597 | 597 | |
| 598 | - $this->render_field_select( $field ); |
|
| 598 | + $this->render_field_select($field); |
|
| 599 | 599 | |
| 600 | - } elseif( $field['field_type'] == 'multi_select' ) { |
|
| 600 | + } elseif ($field['field_type'] == 'multi_select') { |
|
| 601 | 601 | |
| 602 | 602 | $field['multiple'] = 1; |
| 603 | 603 | |
| 604 | - $this->render_field_select( $field ); |
|
| 604 | + $this->render_field_select($field); |
|
| 605 | 605 | |
| 606 | - } elseif( $field['field_type'] == 'radio' ) { |
|
| 606 | + } elseif ($field['field_type'] == 'radio') { |
|
| 607 | 607 | |
| 608 | - $this->render_field_checkbox( $field ); |
|
| 608 | + $this->render_field_checkbox($field); |
|
| 609 | 609 | |
| 610 | - } elseif( $field['field_type'] == 'checkbox' ) { |
|
| 610 | + } elseif ($field['field_type'] == 'checkbox') { |
|
| 611 | 611 | |
| 612 | - $this->render_field_checkbox( $field ); |
|
| 612 | + $this->render_field_checkbox($field); |
|
| 613 | 613 | |
| 614 | 614 | } |
| 615 | 615 | |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | * @param $field - an array holding all the field's data |
| 632 | 632 | */ |
| 633 | 633 | |
| 634 | - function render_field_select( $field ) { |
|
| 634 | + function render_field_select($field) { |
|
| 635 | 635 | |
| 636 | 636 | // Change Field into a select |
| 637 | 637 | $field['type'] = 'select'; |
@@ -641,23 +641,23 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | |
| 643 | 643 | // value |
| 644 | - if( !empty($field['value']) ) { |
|
| 644 | + if ( ! empty($field['value'])) { |
|
| 645 | 645 | |
| 646 | 646 | // get terms |
| 647 | - $terms = $this->get_terms( $field['value'], $field['taxonomy'] ); |
|
| 647 | + $terms = $this->get_terms($field['value'], $field['taxonomy']); |
|
| 648 | 648 | |
| 649 | 649 | |
| 650 | 650 | // set choices |
| 651 | - if( !empty($terms) ) { |
|
| 651 | + if ( ! empty($terms)) { |
|
| 652 | 652 | |
| 653 | - foreach( array_keys($terms) as $i ) { |
|
| 653 | + foreach (array_keys($terms) as $i) { |
|
| 654 | 654 | |
| 655 | 655 | // vars |
| 656 | - $term = acf_extract_var( $terms, $i ); |
|
| 656 | + $term = acf_extract_var($terms, $i); |
|
| 657 | 657 | |
| 658 | 658 | |
| 659 | 659 | // append to choices |
| 660 | - $field['choices'][ $term->term_id ] = $this->get_term_title( $term, $field ); |
|
| 660 | + $field['choices'][$term->term_id] = $this->get_term_title($term, $field); |
|
| 661 | 661 | |
| 662 | 662 | } |
| 663 | 663 | |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | |
| 669 | 669 | // render select |
| 670 | - acf_render_field( $field ); |
|
| 670 | + acf_render_field($field); |
|
| 671 | 671 | |
| 672 | 672 | } |
| 673 | 673 | |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | * @param $field - an array holding all the field's data |
| 685 | 685 | */ |
| 686 | 686 | |
| 687 | - function render_field_checkbox( $field ) { |
|
| 687 | + function render_field_checkbox($field) { |
|
| 688 | 688 | |
| 689 | 689 | // hidden input |
| 690 | 690 | acf_hidden_input(array( |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | |
| 695 | 695 | |
| 696 | 696 | // checkbox saves an array |
| 697 | - if( $field['field_type'] == 'checkbox' ) { |
|
| 697 | + if ($field['field_type'] == 'checkbox') { |
|
| 698 | 698 | |
| 699 | 699 | $field['name'] .= '[]'; |
| 700 | 700 | |
@@ -708,23 +708,23 @@ discard block |
||
| 708 | 708 | // vars |
| 709 | 709 | $args = array( |
| 710 | 710 | 'taxonomy' => $field['taxonomy'], |
| 711 | - 'show_option_none' => __('No', 'acf') . ' ' . $taxonomy_obj->labels->name, |
|
| 711 | + 'show_option_none' => __('No', 'acf').' '.$taxonomy_obj->labels->name, |
|
| 712 | 712 | 'hide_empty' => false, |
| 713 | 713 | 'style' => 'none', |
| 714 | - 'walker' => new acf_taxonomy_field_walker( $field ), |
|
| 714 | + 'walker' => new acf_taxonomy_field_walker($field), |
|
| 715 | 715 | ); |
| 716 | 716 | |
| 717 | 717 | |
| 718 | 718 | // filter for 3rd party customization |
| 719 | 719 | $args = apply_filters('acf/fields/taxonomy/wp_list_categories', $args, $field); |
| 720 | - $args = apply_filters('acf/fields/taxonomy/wp_list_categories/name=' . $field['_name'], $args, $field); |
|
| 721 | - $args = apply_filters('acf/fields/taxonomy/wp_list_categories/key=' . $field['key'], $args, $field); |
|
| 720 | + $args = apply_filters('acf/fields/taxonomy/wp_list_categories/name='.$field['_name'], $args, $field); |
|
| 721 | + $args = apply_filters('acf/fields/taxonomy/wp_list_categories/key='.$field['key'], $args, $field); |
|
| 722 | 722 | |
| 723 | 723 | ?><div class="categorychecklist-holder"> |
| 724 | 724 | |
| 725 | 725 | <ul class="acf-checkbox-list acf-bl"> |
| 726 | 726 | |
| 727 | - <?php if( $field['field_type'] == 'radio' && $field['allow_null'] ): ?> |
|
| 727 | + <?php if ($field['field_type'] == 'radio' && $field['allow_null']): ?> |
|
| 728 | 728 | <li> |
| 729 | 729 | <label class="selectit"> |
| 730 | 730 | <input type="radio" name="<?php echo $field['name']; ?>" value="" /> <?php _e("None", 'acf'); ?> |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | </li> |
| 733 | 733 | <?php endif; ?> |
| 734 | 734 | |
| 735 | - <?php wp_list_categories( $args ); ?> |
|
| 735 | + <?php wp_list_categories($args); ?> |
|
| 736 | 736 | |
| 737 | 737 | </ul> |
| 738 | 738 | |
@@ -754,12 +754,12 @@ discard block |
||
| 754 | 754 | * @param $field - an array holding all the field's data |
| 755 | 755 | */ |
| 756 | 756 | |
| 757 | - function render_field_settings( $field ) { |
|
| 757 | + function render_field_settings($field) { |
|
| 758 | 758 | |
| 759 | 759 | // default_value |
| 760 | - acf_render_field_setting( $field, array( |
|
| 761 | - 'label' => __('Taxonomy','acf'), |
|
| 762 | - 'instructions' => __('Select the taxonomy to be displayed','acf'), |
|
| 760 | + acf_render_field_setting($field, array( |
|
| 761 | + 'label' => __('Taxonomy', 'acf'), |
|
| 762 | + 'instructions' => __('Select the taxonomy to be displayed', 'acf'), |
|
| 763 | 763 | 'type' => 'select', |
| 764 | 764 | 'name' => 'taxonomy', |
| 765 | 765 | 'choices' => acf_get_taxonomies(), |
@@ -767,18 +767,18 @@ discard block |
||
| 767 | 767 | |
| 768 | 768 | |
| 769 | 769 | // field_type |
| 770 | - acf_render_field_setting( $field, array( |
|
| 771 | - 'label' => __('Appearance','acf'), |
|
| 772 | - 'instructions' => __('Select the appearance of this field','acf'), |
|
| 770 | + acf_render_field_setting($field, array( |
|
| 771 | + 'label' => __('Appearance', 'acf'), |
|
| 772 | + 'instructions' => __('Select the appearance of this field', 'acf'), |
|
| 773 | 773 | 'type' => 'select', |
| 774 | 774 | 'name' => 'field_type', |
| 775 | 775 | 'optgroup' => true, |
| 776 | 776 | 'choices' => array( |
| 777 | - __("Multiple Values",'acf') => array( |
|
| 777 | + __("Multiple Values", 'acf') => array( |
|
| 778 | 778 | 'checkbox' => __('Checkbox', 'acf'), |
| 779 | 779 | 'multi_select' => __('Multi Select', 'acf') |
| 780 | 780 | ), |
| 781 | - __("Single Value",'acf') => array( |
|
| 781 | + __("Single Value", 'acf') => array( |
|
| 782 | 782 | 'radio' => __('Radio Buttons', 'acf'), |
| 783 | 783 | 'select' => __('Select', 'acf') |
| 784 | 784 | ) |
@@ -787,70 +787,70 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | |
| 789 | 789 | // allow_null |
| 790 | - acf_render_field_setting( $field, array( |
|
| 791 | - 'label' => __('Allow Null?','acf'), |
|
| 790 | + acf_render_field_setting($field, array( |
|
| 791 | + 'label' => __('Allow Null?', 'acf'), |
|
| 792 | 792 | 'instructions' => '', |
| 793 | 793 | 'type' => 'radio', |
| 794 | 794 | 'name' => 'allow_null', |
| 795 | 795 | 'choices' => array( |
| 796 | - 1 => __("Yes",'acf'), |
|
| 797 | - 0 => __("No",'acf'), |
|
| 796 | + 1 => __("Yes", 'acf'), |
|
| 797 | + 0 => __("No", 'acf'), |
|
| 798 | 798 | ), |
| 799 | 799 | 'layout' => 'horizontal', |
| 800 | 800 | )); |
| 801 | 801 | |
| 802 | 802 | |
| 803 | 803 | // add_term |
| 804 | - acf_render_field_setting( $field, array( |
|
| 805 | - 'label' => __('Create Terms','acf'), |
|
| 806 | - 'instructions' => __('Allow new terms to be created whilst editing','acf'), |
|
| 804 | + acf_render_field_setting($field, array( |
|
| 805 | + 'label' => __('Create Terms', 'acf'), |
|
| 806 | + 'instructions' => __('Allow new terms to be created whilst editing', 'acf'), |
|
| 807 | 807 | 'type' => 'radio', |
| 808 | 808 | 'name' => 'add_term', |
| 809 | 809 | 'choices' => array( |
| 810 | - 1 => __("Yes",'acf'), |
|
| 811 | - 0 => __("No",'acf'), |
|
| 810 | + 1 => __("Yes", 'acf'), |
|
| 811 | + 0 => __("No", 'acf'), |
|
| 812 | 812 | ), |
| 813 | 813 | 'layout' => 'horizontal', |
| 814 | 814 | )); |
| 815 | 815 | |
| 816 | 816 | |
| 817 | 817 | // save_terms |
| 818 | - acf_render_field_setting( $field, array( |
|
| 819 | - 'label' => __('Save Terms','acf'), |
|
| 820 | - 'instructions' => __('Connect selected terms to the post','acf'), |
|
| 818 | + acf_render_field_setting($field, array( |
|
| 819 | + 'label' => __('Save Terms', 'acf'), |
|
| 820 | + 'instructions' => __('Connect selected terms to the post', 'acf'), |
|
| 821 | 821 | 'type' => 'radio', |
| 822 | 822 | 'name' => 'save_terms', |
| 823 | 823 | 'choices' => array( |
| 824 | - 1 => __("Yes",'acf'), |
|
| 825 | - 0 => __("No",'acf'), |
|
| 824 | + 1 => __("Yes", 'acf'), |
|
| 825 | + 0 => __("No", 'acf'), |
|
| 826 | 826 | ), |
| 827 | 827 | 'layout' => 'horizontal', |
| 828 | 828 | )); |
| 829 | 829 | |
| 830 | 830 | |
| 831 | 831 | // load_terms |
| 832 | - acf_render_field_setting( $field, array( |
|
| 833 | - 'label' => __('Load Terms','acf'), |
|
| 834 | - 'instructions' => __('Load value from posts terms','acf'), |
|
| 832 | + acf_render_field_setting($field, array( |
|
| 833 | + 'label' => __('Load Terms', 'acf'), |
|
| 834 | + 'instructions' => __('Load value from posts terms', 'acf'), |
|
| 835 | 835 | 'type' => 'radio', |
| 836 | 836 | 'name' => 'load_terms', |
| 837 | 837 | 'choices' => array( |
| 838 | - 1 => __("Yes",'acf'), |
|
| 839 | - 0 => __("No",'acf'), |
|
| 838 | + 1 => __("Yes", 'acf'), |
|
| 839 | + 0 => __("No", 'acf'), |
|
| 840 | 840 | ), |
| 841 | 841 | 'layout' => 'horizontal', |
| 842 | 842 | )); |
| 843 | 843 | |
| 844 | 844 | |
| 845 | 845 | // return_format |
| 846 | - acf_render_field_setting( $field, array( |
|
| 847 | - 'label' => __('Return Value','acf'), |
|
| 846 | + acf_render_field_setting($field, array( |
|
| 847 | + 'label' => __('Return Value', 'acf'), |
|
| 848 | 848 | 'instructions' => '', |
| 849 | 849 | 'type' => 'radio', |
| 850 | 850 | 'name' => 'return_format', |
| 851 | 851 | 'choices' => array( |
| 852 | - 'object' => __("Term Object",'acf'), |
|
| 853 | - 'id' => __("Term ID",'acf') |
|
| 852 | + 'object' => __("Term Object", 'acf'), |
|
| 853 | + 'id' => __("Term ID", 'acf') |
|
| 854 | 854 | ), |
| 855 | 855 | 'layout' => 'horizontal', |
| 856 | 856 | )); |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | |
| 884 | 884 | |
| 885 | 885 | // verify nonce |
| 886 | - if( ! wp_verify_nonce($args['nonce'], 'acf_nonce') ) { |
|
| 886 | + if ( ! wp_verify_nonce($args['nonce'], 'acf_nonce')) { |
|
| 887 | 887 | |
| 888 | 888 | die(); |
| 889 | 889 | |
@@ -891,9 +891,9 @@ discard block |
||
| 891 | 891 | |
| 892 | 892 | |
| 893 | 893 | // load field |
| 894 | - $field = acf_get_field( $args['field_key'] ); |
|
| 894 | + $field = acf_get_field($args['field_key']); |
|
| 895 | 895 | |
| 896 | - if( !$field ) { |
|
| 896 | + if ( ! $field) { |
|
| 897 | 897 | |
| 898 | 898 | die(); |
| 899 | 899 | |
@@ -907,22 +907,22 @@ discard block |
||
| 907 | 907 | |
| 908 | 908 | // validate cap |
| 909 | 909 | // note: this situation should never occur due to condition of the add new button |
| 910 | - if( !current_user_can( $taxonomy_obj->cap->manage_terms) ) { |
|
| 910 | + if ( ! current_user_can($taxonomy_obj->cap->manage_terms)) { |
|
| 911 | 911 | |
| 912 | - echo '<p><strong>' . __("Error", 'acf') . '.</strong> ' . sprintf( __('User unable to add new %s', 'acf'), $taxonomy_label ) . '</p>'; |
|
| 912 | + echo '<p><strong>'.__("Error", 'acf').'.</strong> '.sprintf(__('User unable to add new %s', 'acf'), $taxonomy_label).'</p>'; |
|
| 913 | 913 | die; |
| 914 | 914 | |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | |
| 918 | 918 | // save? |
| 919 | - if( $args['term_name'] ) { |
|
| 919 | + if ($args['term_name']) { |
|
| 920 | 920 | |
| 921 | 921 | // exists |
| 922 | - if( term_exists($args['term_name'], $field['taxonomy']) ) { |
|
| 922 | + if (term_exists($args['term_name'], $field['taxonomy'])) { |
|
| 923 | 923 | |
| 924 | 924 | wp_send_json_error(array( |
| 925 | - 'error' => sprintf( __('%s already exists', 'acf'), $taxonomy_label ) |
|
| 925 | + 'error' => sprintf(__('%s already exists', 'acf'), $taxonomy_label) |
|
| 926 | 926 | )); |
| 927 | 927 | |
| 928 | 928 | } |
@@ -931,17 +931,17 @@ discard block |
||
| 931 | 931 | // insert |
| 932 | 932 | $extra = array(); |
| 933 | 933 | |
| 934 | - if( $args['term_parent'] ) { |
|
| 934 | + if ($args['term_parent']) { |
|
| 935 | 935 | |
| 936 | 936 | $extra['parent'] = $args['term_parent']; |
| 937 | 937 | |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - $data = wp_insert_term( $args['term_name'], $field['taxonomy'], $extra ); |
|
| 940 | + $data = wp_insert_term($args['term_name'], $field['taxonomy'], $extra); |
|
| 941 | 941 | |
| 942 | 942 | |
| 943 | 943 | // error? |
| 944 | - if( is_wp_error($data) ) { |
|
| 944 | + if (is_wp_error($data)) { |
|
| 945 | 945 | |
| 946 | 946 | wp_send_json_error(array( |
| 947 | 947 | 'error' => $data->get_error_message() |
@@ -952,9 +952,9 @@ discard block |
||
| 952 | 952 | |
| 953 | 953 | // ancestors |
| 954 | 954 | $prefix = ''; |
| 955 | - $ancestors = get_ancestors( $data['term_id'], $field['taxonomy'] ); |
|
| 955 | + $ancestors = get_ancestors($data['term_id'], $field['taxonomy']); |
|
| 956 | 956 | |
| 957 | - if( !empty($ancestors) ) { |
|
| 957 | + if ( ! empty($ancestors)) { |
|
| 958 | 958 | |
| 959 | 959 | $prefix = str_repeat('- ', count($ancestors)); |
| 960 | 960 | |
@@ -963,10 +963,10 @@ discard block |
||
| 963 | 963 | |
| 964 | 964 | // success |
| 965 | 965 | wp_send_json_success(array( |
| 966 | - 'message' => sprintf( __('%s added', 'acf'), $taxonomy_label ), |
|
| 966 | + 'message' => sprintf(__('%s added', 'acf'), $taxonomy_label), |
|
| 967 | 967 | 'term_id' => $data['term_id'], |
| 968 | 968 | 'term_name' => $args['term_name'], |
| 969 | - 'term_label' => $prefix . $args['term_name'], |
|
| 969 | + 'term_label' => $prefix.$args['term_name'], |
|
| 970 | 970 | 'term_parent' => $args['term_parent'] |
| 971 | 971 | )); |
| 972 | 972 | |
@@ -981,16 +981,16 @@ discard block |
||
| 981 | 981 | )); |
| 982 | 982 | |
| 983 | 983 | |
| 984 | - if( is_taxonomy_hierarchical( $field['taxonomy'] ) ) { |
|
| 984 | + if (is_taxonomy_hierarchical($field['taxonomy'])) { |
|
| 985 | 985 | |
| 986 | 986 | $choices = array(); |
| 987 | - $choices2 = $this->get_choices(array( 'field_key' => $field['key'] )); |
|
| 987 | + $choices2 = $this->get_choices(array('field_key' => $field['key'])); |
|
| 988 | 988 | |
| 989 | - if( $choices2 ) { |
|
| 989 | + if ($choices2) { |
|
| 990 | 990 | |
| 991 | - foreach( $choices2 as $v) { |
|
| 991 | + foreach ($choices2 as $v) { |
|
| 992 | 992 | |
| 993 | - $choices[ $v['id'] ] = $v['text']; |
|
| 993 | + $choices[$v['id']] = $v['text']; |
|
| 994 | 994 | |
| 995 | 995 | } |
| 996 | 996 | |
@@ -1023,49 +1023,49 @@ discard block |
||
| 1023 | 1023 | |
| 1024 | 1024 | endif; |
| 1025 | 1025 | |
| 1026 | -if( ! class_exists('acf_taxonomy_field_walker') ) : |
|
| 1026 | +if ( ! class_exists('acf_taxonomy_field_walker')) : |
|
| 1027 | 1027 | |
| 1028 | 1028 | class acf_taxonomy_field_walker extends Walker { |
| 1029 | 1029 | |
| 1030 | 1030 | var $field = null, |
| 1031 | 1031 | $tree_type = 'category', |
| 1032 | - $db_fields = array ( 'parent' => 'parent', 'id' => 'term_id' ); |
|
| 1032 | + $db_fields = array('parent' => 'parent', 'id' => 'term_id'); |
|
| 1033 | 1033 | |
| 1034 | - function __construct( $field ) { |
|
| 1034 | + function __construct($field) { |
|
| 1035 | 1035 | |
| 1036 | 1036 | $this->field = $field; |
| 1037 | 1037 | |
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | - function start_el( &$output, $term, $depth = 0, $args = array(), $current_object_id = 0) { |
|
| 1040 | + function start_el(&$output, $term, $depth = 0, $args = array(), $current_object_id = 0) { |
|
| 1041 | 1041 | |
| 1042 | 1042 | // vars |
| 1043 | - $selected = in_array( $term->term_id, $this->field['value'] ); |
|
| 1043 | + $selected = in_array($term->term_id, $this->field['value']); |
|
| 1044 | 1044 | |
| 1045 | 1045 | |
| 1046 | 1046 | // append |
| 1047 | - $output .= '<li data-id="' . $term->term_id . '"><label><input type="' . $this->field['field_type'] . '" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checked"' : '') . ' /> <span>' . $term->name . '</span></label>'; |
|
| 1047 | + $output .= '<li data-id="'.$term->term_id.'"><label><input type="'.$this->field['field_type'].'" name="'.$this->field['name'].'" value="'.$term->term_id.'" '.($selected ? 'checked="checked"' : '').' /> <span>'.$term->name.'</span></label>'; |
|
| 1048 | 1048 | |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | - function end_el( &$output, $term, $depth = 0, $args = array() ) { |
|
| 1051 | + function end_el(&$output, $term, $depth = 0, $args = array()) { |
|
| 1052 | 1052 | |
| 1053 | 1053 | // append |
| 1054 | - $output .= '</li>' . "\n"; |
|
| 1054 | + $output .= '</li>'."\n"; |
|
| 1055 | 1055 | |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | - function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
| 1058 | + function start_lvl(&$output, $depth = 0, $args = array()) { |
|
| 1059 | 1059 | |
| 1060 | 1060 | // append |
| 1061 | - $output .= '<ul class="children acf-bl">' . "\n"; |
|
| 1061 | + $output .= '<ul class="children acf-bl">'."\n"; |
|
| 1062 | 1062 | |
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | - function end_lvl( &$output, $depth = 0, $args = array() ) { |
|
| 1065 | + function end_lvl(&$output, $depth = 0, $args = array()) { |
|
| 1066 | 1066 | |
| 1067 | 1067 | // append |
| 1068 | - $output .= '</ul>' . "\n"; |
|
| 1068 | + $output .= '</ul>'."\n"; |
|
| 1069 | 1069 | |
| 1070 | 1070 | } |
| 1071 | 1071 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // do not delete! |
| 53 | - parent::__construct(); |
|
| 53 | + parent::__construct(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |