@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | * @param mixed $form_id |
26 | 26 | * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms |
27 | 27 | */ |
28 | - public static function get_form( $form_id ) { |
|
29 | - if ( empty( $form_id ) ) { |
|
28 | + public static function get_form($form_id) { |
|
29 | + if (empty($form_id)) { |
|
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | 33 | // Only get_form_meta is cached. ::facepalm:: |
34 | - if ( class_exists( 'RGFormsModel' ) ) { |
|
35 | - return GFFormsModel::get_form_meta( $form_id ); |
|
34 | + if (class_exists('RGFormsModel')) { |
|
35 | + return GFFormsModel::get_form_meta($form_id); |
|
36 | 36 | } |
37 | 37 | |
38 | - if ( class_exists( 'GFAPI' ) ) { |
|
39 | - return GFAPI::get_form( $form_id ); |
|
38 | + if (class_exists('GFAPI')) { |
|
39 | + return GFAPI::get_form($form_id); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return false; |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities |
57 | 57 | */ |
58 | - public static function has_cap( $caps = '', $object_id = null, $user_id = null ) { |
|
59 | - return GravityView_Roles_Capabilities::has_cap( $caps, $object_id, $user_id ); |
|
58 | + public static function has_cap($caps = '', $object_id = null, $user_id = null) { |
|
59 | + return GravityView_Roles_Capabilities::has_cap($caps, $object_id, $user_id); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | * @param array|GF_Fields $field Gravity Forms field or array |
68 | 68 | * @return array Array version of $field |
69 | 69 | */ |
70 | - public static function get_field_array( $field ) { |
|
70 | + public static function get_field_array($field) { |
|
71 | 71 | |
72 | - if ( class_exists( 'GF_Fields' ) ) { |
|
72 | + if (class_exists('GF_Fields')) { |
|
73 | 73 | |
74 | - $field_object = GF_Fields::create( $field ); |
|
74 | + $field_object = GF_Fields::create($field); |
|
75 | 75 | |
76 | 76 | // Convert the field object in 1.9 to an array for backward compatibility |
77 | - $field_array = get_object_vars( $field_object ); |
|
77 | + $field_array = get_object_vars($field_object); |
|
78 | 78 | |
79 | 79 | } else { |
80 | 80 | $field_array = $field; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return array Array of Views as `WP_Post`. Empty array if none found. |
95 | 95 | */ |
96 | - public static function get_all_views( $args = array() ) { |
|
96 | + public static function get_all_views($args = array()) { |
|
97 | 97 | |
98 | 98 | $default_params = array( |
99 | 99 | 'post_type' => 'gravityview', |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | 'post_status' => 'publish', |
102 | 102 | ); |
103 | 103 | |
104 | - $params = wp_parse_args( $args, $default_params ); |
|
104 | + $params = wp_parse_args($args, $default_params); |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @filter `gravityview/get_all_views/params` Modify the parameters sent to get all views. |
108 | 108 | * @param[in,out] array $params Array of parameters to pass to `get_posts()` |
109 | 109 | */ |
110 | - $views_params = apply_filters( 'gravityview/get_all_views/params', $params ); |
|
110 | + $views_params = apply_filters('gravityview/get_all_views/params', $params); |
|
111 | 111 | |
112 | - $views = get_posts( $views_params ); |
|
112 | + $views = get_posts($views_params); |
|
113 | 113 | |
114 | 114 | return $views; |
115 | 115 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | * @param int|string $entry_slug Entry slug |
121 | 121 | * @return array Gravity Forms form array |
122 | 122 | */ |
123 | - public static function get_form_from_entry_id( $entry_slug ) { |
|
123 | + public static function get_form_from_entry_id($entry_slug) { |
|
124 | 124 | |
125 | - $entry = self::get_entry( $entry_slug, true ); |
|
125 | + $entry = self::get_entry($entry_slug, true); |
|
126 | 126 | |
127 | - $form = self::get_form( $entry['form_id'] ); |
|
127 | + $form = self::get_form($entry['form_id']); |
|
128 | 128 | |
129 | 129 | return $form; |
130 | 130 | } |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @return bool|GF_Field[] |
140 | 140 | */ |
141 | - public static function has_product_field( $form = array() ) { |
|
141 | + public static function has_product_field($form = array()) { |
|
142 | 142 | |
143 | - $product_fields = apply_filters( 'gform_product_field_types', array( 'option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price' ) ); |
|
143 | + $product_fields = apply_filters('gform_product_field_types', array('option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price')); |
|
144 | 144 | |
145 | - $fields = GFAPI::get_fields_by_type( $form, $product_fields ); |
|
145 | + $fields = GFAPI::get_fields_by_type($form, $product_fields); |
|
146 | 146 | |
147 | - return empty( $fields ) ? false : $fields; |
|
147 | + return empty($fields) ? false : $fields; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param string $slug The entry slug, as returned by GravityView_API::get_entry_slug() |
155 | 155 | * @return int|null The entry ID, if exists; `NULL` if not |
156 | 156 | */ |
157 | - public static function get_entry_id_from_slug( $slug ) { |
|
157 | + public static function get_entry_id_from_slug($slug) { |
|
158 | 158 | global $wpdb; |
159 | 159 | |
160 | 160 | $search_criteria = array( |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | 'page_size' => 1, |
174 | 174 | ); |
175 | 175 | |
176 | - $results = GFAPI::get_entries( 0, $search_criteria, null, $paging ); |
|
176 | + $results = GFAPI::get_entries(0, $search_criteria, null, $paging); |
|
177 | 177 | |
178 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
178 | + $result = (!empty($results) && !empty($results[0]['id'])) ? $results[0]['id'] : null; |
|
179 | 179 | |
180 | 180 | return $result; |
181 | 181 | } |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public static function get_forms() { |
192 | 192 | $forms = array(); |
193 | - if ( class_exists( 'GFAPI' ) ) { |
|
193 | + if (class_exists('GFAPI')) { |
|
194 | 194 | $gf_forms = GFAPI::get_forms(); |
195 | - foreach ( $gf_forms as $form ) { |
|
195 | + foreach ($gf_forms as $form) { |
|
196 | 196 | $forms[] = array( |
197 | 197 | 'id' => $form['id'], |
198 | 198 | 'title' => $form['title'], |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | * @param string|array $form_id (default: '') or $form object |
210 | 210 | * @return array |
211 | 211 | */ |
212 | - public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
|
212 | + public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) { |
|
213 | 213 | |
214 | - if ( ! is_array( $form ) ) { |
|
215 | - $form = self::get_form( $form ); |
|
214 | + if (!is_array($form)) { |
|
215 | + $form = self::get_form($form); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | $fields = array(); |
@@ -222,56 +222,56 @@ discard block |
||
222 | 222 | $has_poll_fields = false; |
223 | 223 | |
224 | 224 | // If GF_Field exists, we're using GF 1.9+, where add_default_properties has been deprecated. |
225 | - if ( false === class_exists( 'GF_Field' ) && $add_default_properties ) { |
|
226 | - $form = RGFormsModel::add_default_properties( $form ); |
|
225 | + if (false === class_exists('GF_Field') && $add_default_properties) { |
|
226 | + $form = RGFormsModel::add_default_properties($form); |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( $form ) { |
|
230 | - foreach ( $form['fields'] as $field ) { |
|
231 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
232 | - $fields[ $field['id'] ] = array( |
|
233 | - 'label' => rgar( $field, 'label' ), |
|
229 | + if ($form) { |
|
230 | + foreach ($form['fields'] as $field) { |
|
231 | + if ($include_parent_field || empty($field['inputs'])) { |
|
232 | + $fields[$field['id']] = array( |
|
233 | + 'label' => rgar($field, 'label'), |
|
234 | 234 | 'parent' => null, |
235 | - 'type' => rgar( $field, 'type' ), |
|
236 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
237 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
235 | + 'type' => rgar($field, 'type'), |
|
236 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
237 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
238 | 238 | ); |
239 | 239 | } |
240 | 240 | |
241 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
242 | - foreach ( $field['inputs'] as $input ) { |
|
241 | + if ($add_default_properties && !empty($field['inputs'])) { |
|
242 | + foreach ($field['inputs'] as $input) { |
|
243 | 243 | /** |
244 | 244 | * @hack |
245 | 245 | * In case of email/email confirmation, the input for email has the same id as the parent field |
246 | 246 | */ |
247 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
247 | + if ('email' == rgar($field, 'type') && false === strpos($input['id'], '.')) { |
|
248 | 248 | continue; |
249 | 249 | } |
250 | - $fields[ (string)$input['id'] ] = array( |
|
251 | - 'label' => rgar( $input, 'label' ), |
|
252 | - 'customLabel' => rgar( $input, 'customLabel' ), |
|
250 | + $fields[(string)$input['id']] = array( |
|
251 | + 'label' => rgar($input, 'label'), |
|
252 | + 'customLabel' => rgar($input, 'customLabel'), |
|
253 | 253 | 'parent' => $field, |
254 | - 'type' => rgar( $field, 'type' ), |
|
255 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
256 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
254 | + 'type' => rgar($field, 'type'), |
|
255 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
256 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
257 | 257 | ); |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | 261 | /** @since 1.14 */ |
262 | - if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) { |
|
262 | + if ('list' === $field['type'] && !empty($field['enableColumns'])) { |
|
263 | 263 | |
264 | - foreach ( (array)$field['choices'] as $key => $input ) { |
|
264 | + foreach ((array)$field['choices'] as $key => $input) { |
|
265 | 265 | |
266 | - $input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key} |
|
266 | + $input_id = sprintf('%d.%d', $field['id'], $key); // {field_id}.{column_key} |
|
267 | 267 | |
268 | - $fields[ $input_id ] = array( |
|
269 | - 'label' => rgar( $input, 'text' ), |
|
268 | + $fields[$input_id] = array( |
|
269 | + 'label' => rgar($input, 'text'), |
|
270 | 270 | 'customLabel' => '', |
271 | 271 | 'parent' => $field, |
272 | - 'type' => rgar( $field, 'type' ), |
|
273 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
274 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
272 | + 'type' => rgar($field, 'type'), |
|
273 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
274 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
275 | 275 | ); |
276 | 276 | } |
277 | 277 | } |
@@ -279,27 +279,27 @@ discard block |
||
279 | 279 | /** |
280 | 280 | * @since 1.8 |
281 | 281 | */ |
282 | - if( 'quiz' === $field['type'] ) { |
|
282 | + if ('quiz' === $field['type']) { |
|
283 | 283 | $has_quiz_fields = true; |
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
287 | 287 | * @since 1.8 |
288 | 288 | */ |
289 | - if( 'poll' === $field['type'] ) { |
|
289 | + if ('poll' === $field['type']) { |
|
290 | 290 | $has_poll_fields = true; |
291 | 291 | } |
292 | 292 | |
293 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
293 | + if (GFCommon::is_product_field($field['type'])) { |
|
294 | 294 | $has_product_fields = true; |
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
298 | 298 | * @hack Version 1.9 |
299 | 299 | */ |
300 | - $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field; |
|
300 | + $field_for_is_post_field = class_exists('GF_Fields') ? (object)$field : (array)$field; |
|
301 | 301 | |
302 | - if ( GFCommon::is_post_field( $field_for_is_post_field ) ) { |
|
302 | + if (GFCommon::is_post_field($field_for_is_post_field)) { |
|
303 | 303 | $has_post_fields = true; |
304 | 304 | } |
305 | 305 | } |
@@ -308,47 +308,47 @@ discard block |
||
308 | 308 | /** |
309 | 309 | * @since 1.7 |
310 | 310 | */ |
311 | - if ( $has_post_fields ) { |
|
311 | + if ($has_post_fields) { |
|
312 | 312 | $fields['post_id'] = array( |
313 | - 'label' => __( 'Post ID', 'gravityview' ), |
|
313 | + 'label' => __('Post ID', 'gravityview'), |
|
314 | 314 | 'type' => 'post_id', |
315 | 315 | ); |
316 | 316 | } |
317 | 317 | |
318 | - if ( $has_product_fields ) { |
|
318 | + if ($has_product_fields) { |
|
319 | 319 | |
320 | 320 | $fields['payment_status'] = array( |
321 | - 'label' => __( 'Payment Status', 'gravityview' ), |
|
321 | + 'label' => __('Payment Status', 'gravityview'), |
|
322 | 322 | 'type' => 'payment_status', |
323 | 323 | ); |
324 | 324 | |
325 | 325 | $fields['payment_date'] = array( |
326 | - 'label' => __( 'Payment Date', 'gravityview' ), |
|
326 | + 'label' => __('Payment Date', 'gravityview'), |
|
327 | 327 | 'type' => 'payment_date', |
328 | 328 | ); |
329 | 329 | |
330 | 330 | $fields['payment_amount'] = array( |
331 | - 'label' => __( 'Payment Amount', 'gravityview' ), |
|
331 | + 'label' => __('Payment Amount', 'gravityview'), |
|
332 | 332 | 'type' => 'payment_amount', |
333 | 333 | ); |
334 | 334 | |
335 | 335 | $fields['payment_method'] = array( |
336 | - 'label' => __( 'Payment Method', 'gravityview' ), |
|
336 | + 'label' => __('Payment Method', 'gravityview'), |
|
337 | 337 | 'type' => 'payment_method', |
338 | 338 | ); |
339 | 339 | |
340 | 340 | $fields['is_fulfilled'] = array( |
341 | - 'label' => __( 'Is Fulfilled', 'gravityview' ), |
|
341 | + 'label' => __('Is Fulfilled', 'gravityview'), |
|
342 | 342 | 'type' => 'is_fulfilled', |
343 | 343 | ); |
344 | 344 | |
345 | 345 | $fields['transaction_id'] = array( |
346 | - 'label' => __( 'Transaction ID', 'gravityview' ), |
|
346 | + 'label' => __('Transaction ID', 'gravityview'), |
|
347 | 347 | 'type' => 'transaction_id', |
348 | 348 | ); |
349 | 349 | |
350 | 350 | $fields['transaction_type'] = array( |
351 | - 'label' => __( 'Transaction Type', 'gravityview' ), |
|
351 | + 'label' => __('Transaction Type', 'gravityview'), |
|
352 | 352 | 'type' => 'transaction_type', |
353 | 353 | ); |
354 | 354 | |
@@ -357,27 +357,27 @@ discard block |
||
357 | 357 | /** |
358 | 358 | * @since 1.8 |
359 | 359 | */ |
360 | - if( $has_quiz_fields ) { |
|
360 | + if ($has_quiz_fields) { |
|
361 | 361 | |
362 | - $fields['gquiz_score'] = array( |
|
363 | - 'label' => __( 'Quiz Score Total', 'gravityview' ), |
|
362 | + $fields['gquiz_score'] = array( |
|
363 | + 'label' => __('Quiz Score Total', 'gravityview'), |
|
364 | 364 | 'type' => 'quiz_score', |
365 | - 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
|
365 | + 'desc' => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'), |
|
366 | 366 | ); |
367 | 367 | $fields['gquiz_percent'] = array( |
368 | - 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
|
368 | + 'label' => __('Quiz Percentage Grade', 'gravityview'), |
|
369 | 369 | 'type' => 'quiz_percent', |
370 | - 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
|
370 | + 'desc' => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'), |
|
371 | 371 | ); |
372 | - $fields['gquiz_grade'] = array( |
|
373 | - 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
|
372 | + $fields['gquiz_grade'] = array( |
|
373 | + 'label' => __('Quiz Letter Grade', 'gravityview'), |
|
374 | 374 | 'type' => 'quiz_grade', |
375 | - 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
|
375 | + 'desc' => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'), |
|
376 | 376 | ); |
377 | 377 | $fields['gquiz_is_pass'] = array( |
378 | - 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
|
378 | + 'label' => __('Quiz Pass/Fail', 'gravityview'), |
|
379 | 379 | 'type' => 'quiz_is_pass', |
380 | - 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
|
380 | + 'desc' => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'), |
|
381 | 381 | ); |
382 | 382 | } |
383 | 383 | |
@@ -390,15 +390,15 @@ discard block |
||
390 | 390 | * @param string $form_id (default: '') |
391 | 391 | * @return array |
392 | 392 | */ |
393 | - public static function get_entry_meta( $form_id, $only_default_column = true ) { |
|
393 | + public static function get_entry_meta($form_id, $only_default_column = true) { |
|
394 | 394 | |
395 | - $extra_fields = GFFormsModel::get_entry_meta( $form_id ); |
|
395 | + $extra_fields = GFFormsModel::get_entry_meta($form_id); |
|
396 | 396 | |
397 | 397 | $fields = array(); |
398 | 398 | |
399 | - foreach ( $extra_fields as $key => $field ){ |
|
400 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
401 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
399 | + foreach ($extra_fields as $key => $field) { |
|
400 | + if (!empty($only_default_column) && !empty($field['is_default_column'])) { |
|
401 | + $fields[$key] = array('label' => $field['label'], 'type' => 'entry_meta'); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
@@ -414,13 +414,13 @@ discard block |
||
414 | 414 | * @since 1.1.6 |
415 | 415 | * @return array|void Array of entry IDs. Void if Gravity Forms isn't active. |
416 | 416 | */ |
417 | - public static function get_entry_ids( $form_id, $search_criteria = array() ) { |
|
417 | + public static function get_entry_ids($form_id, $search_criteria = array()) { |
|
418 | 418 | |
419 | - if ( ! class_exists( 'GFFormsModel' ) ) { |
|
419 | + if (!class_exists('GFFormsModel')) { |
|
420 | 420 | return; |
421 | 421 | } |
422 | 422 | |
423 | - return GFFormsModel::search_lead_ids( $form_id, $search_criteria ); |
|
423 | + return GFFormsModel::search_lead_ids($form_id, $search_criteria); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -432,33 +432,33 @@ discard block |
||
432 | 432 | * @param array $form_ids array Gravity Forms form IDs |
433 | 433 | * @return array |
434 | 434 | */ |
435 | - public static function calculate_get_entries_criteria( $passed_criteria = array(), $form_ids = array() ) { |
|
435 | + public static function calculate_get_entries_criteria($passed_criteria = array(), $form_ids = array()) { |
|
436 | 436 | |
437 | 437 | $search_criteria_defaults = array( |
438 | 438 | 'search_criteria' => null, |
439 | 439 | 'sorting' => null, |
440 | 440 | 'paging' => null, |
441 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
441 | + 'cache' => (isset($passed_criteria['cache']) ? $passed_criteria['cache'] : true), |
|
442 | 442 | ); |
443 | 443 | |
444 | - $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
|
444 | + $criteria = wp_parse_args($passed_criteria, $search_criteria_defaults); |
|
445 | 445 | |
446 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
447 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
446 | + if (!empty($criteria['search_criteria']['field_filters'])) { |
|
447 | + foreach ($criteria['search_criteria']['field_filters'] as &$filter) { |
|
448 | 448 | |
449 | - if ( ! is_array( $filter ) ) { |
|
449 | + if (!is_array($filter)) { |
|
450 | 450 | continue; |
451 | 451 | } |
452 | 452 | |
453 | 453 | // By default, we want searches to be wildcard for each field. |
454 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
454 | + $filter['operator'] = empty($filter['operator']) ? 'contains' : $filter['operator']; |
|
455 | 455 | |
456 | 456 | /** |
457 | 457 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
458 | 458 | * @param string $operator Existing search operator |
459 | 459 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
460 | 460 | */ |
461 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
461 | + $filter['operator'] = apply_filters('gravityview_search_operator', $filter['operator'], $filter); |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
@@ -466,32 +466,32 @@ discard block |
||
466 | 466 | * Prepare date formats to be in Gravity Forms DB format; |
467 | 467 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
468 | 468 | */ |
469 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
469 | + foreach (array('start_date', 'end_date') as $key) { |
|
470 | 470 | |
471 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
471 | + if (!empty($criteria['search_criteria'][$key])) { |
|
472 | 472 | |
473 | 473 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
474 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
474 | + $date = date_create($criteria['search_criteria'][$key]); |
|
475 | 475 | |
476 | - if ( $date ) { |
|
476 | + if ($date) { |
|
477 | 477 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
478 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
478 | + $criteria['search_criteria'][$key] = $date->format('Y-m-d H:i:s'); |
|
479 | 479 | } else { |
480 | 480 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
481 | - unset( $criteria['search_criteria'][ $key ] ); |
|
481 | + unset($criteria['search_criteria'][$key]); |
|
482 | 482 | |
483 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
483 | + do_action('gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][$key]); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
488 | 488 | |
489 | 489 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
490 | - if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
490 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry()) { |
|
491 | 491 | $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
492 | - } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
|
493 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
|
494 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
492 | + } elseif ('delete' === RGForms::get('action')) { |
|
493 | + $criteria['context_view_id'] = isset($_GET['view_id']) ? $_GET['view_id'] : null; |
|
494 | + } elseif (!isset($criteria['context_view_id'])) { |
|
495 | 495 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
496 | 496 | $criteria['context_view_id'] = null; |
497 | 497 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param array $form_ids Forms to search |
503 | 503 | * @param int $view_id ID of the view being used to search |
504 | 504 | */ |
505 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
505 | + $criteria = apply_filters('gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id']); |
|
506 | 506 | |
507 | 507 | return (array)$criteria; |
508 | 508 | |
@@ -520,35 +520,35 @@ discard block |
||
520 | 520 | * @param mixed &$total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate the total count. (default: null) |
521 | 521 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
522 | 522 | */ |
523 | - public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
|
523 | + public static function get_entries($form_ids = null, $passed_criteria = null, &$total = null) { |
|
524 | 524 | |
525 | 525 | // Filter the criteria before query (includes Adv Filter) |
526 | - $criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids ); |
|
526 | + $criteria = self::calculate_get_entries_criteria($passed_criteria, $form_ids); |
|
527 | 527 | |
528 | - do_action( 'gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria ); |
|
528 | + do_action('gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria); |
|
529 | 529 | |
530 | 530 | // Return value |
531 | 531 | $return = null; |
532 | 532 | |
533 | 533 | /** Reduce # of database calls */ |
534 | - add_filter( 'gform_is_encrypted_field', '__return_false' ); |
|
534 | + add_filter('gform_is_encrypted_field', '__return_false'); |
|
535 | 535 | |
536 | - if ( ! empty( $criteria['cache'] ) ) { |
|
536 | + if (!empty($criteria['cache'])) { |
|
537 | 537 | |
538 | - $Cache = new GravityView_Cache( $form_ids, $criteria ); |
|
538 | + $Cache = new GravityView_Cache($form_ids, $criteria); |
|
539 | 539 | |
540 | - if ( $entries = $Cache->get() ) { |
|
540 | + if ($entries = $Cache->get()) { |
|
541 | 541 | |
542 | 542 | // Still update the total count when using cached results |
543 | - if ( ! is_null( $total ) ) { |
|
544 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
543 | + if (!is_null($total)) { |
|
544 | + $total = GFAPI::count_entries($form_ids, $criteria['search_criteria']); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | $return = $entries; |
548 | 548 | } |
549 | 549 | } |
550 | 550 | |
551 | - if ( is_null( $return ) && class_exists( 'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) { |
|
551 | + if (is_null($return) && class_exists('GFAPI') && (is_numeric($form_ids) || is_array($form_ids))) { |
|
552 | 552 | |
553 | 553 | /** |
554 | 554 | * @filter `gravityview_pre_get_entries` Define entries to be used before GFAPI::get_entries() is called |
@@ -558,24 +558,24 @@ discard block |
||
558 | 558 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
559 | 559 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
560 | 560 | */ |
561 | - $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
|
561 | + $entries = apply_filters('gravityview_before_get_entries', null, $criteria, $passed_criteria, $total); |
|
562 | 562 | |
563 | 563 | // No entries returned from gravityview_before_get_entries |
564 | - if( is_null( $entries ) ) { |
|
564 | + if (is_null($entries)) { |
|
565 | 565 | |
566 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
566 | + $entries = GFAPI::get_entries($form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total); |
|
567 | 567 | |
568 | - if ( is_wp_error( $entries ) ) { |
|
569 | - do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
|
568 | + if (is_wp_error($entries)) { |
|
569 | + do_action('gravityview_log_error', $entries->get_error_message(), $entries); |
|
570 | 570 | |
571 | 571 | return false; |
572 | 572 | } |
573 | 573 | } |
574 | 574 | |
575 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
575 | + if (!empty($criteria['cache']) && isset($Cache)) { |
|
576 | 576 | |
577 | 577 | // Cache results |
578 | - $Cache->set( $entries, 'entries' ); |
|
578 | + $Cache->set($entries, 'entries'); |
|
579 | 579 | |
580 | 580 | } |
581 | 581 | |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | } |
584 | 584 | |
585 | 585 | /** Remove filter added above */ |
586 | - remove_filter( 'gform_is_encrypted_field', '__return_false' ); |
|
586 | + remove_filter('gform_is_encrypted_field', '__return_false'); |
|
587 | 587 | |
588 | 588 | /** |
589 | 589 | * @filter `gravityview_entries` Modify the array of entries returned to GravityView after it has been fetched from the cache or from `GFAPI::get_entries()`. |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
593 | 593 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
594 | 594 | */ |
595 | - $return = apply_filters( 'gravityview_entries', $return, $criteria, $passed_criteria, $total ); |
|
595 | + $return = apply_filters('gravityview_entries', $return, $criteria, $passed_criteria, $total); |
|
596 | 596 | |
597 | 597 | return $return; |
598 | 598 | } |
@@ -609,15 +609,15 @@ discard block |
||
609 | 609 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14} |
610 | 610 | * @return array|boolean |
611 | 611 | */ |
612 | - public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) { |
|
612 | + public static function get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) { |
|
613 | 613 | |
614 | - if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) { |
|
614 | + if (class_exists('GFAPI') && !empty($entry_slug)) { |
|
615 | 615 | |
616 | 616 | /** |
617 | 617 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
618 | 618 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
619 | 619 | */ |
620 | - $custom_slug = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
620 | + $custom_slug = apply_filters('gravityview_custom_entry_slug', false); |
|
621 | 621 | |
622 | 622 | /** |
623 | 623 | * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID). |
@@ -625,38 +625,38 @@ discard block |
||
625 | 625 | * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`) |
626 | 626 | * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method. |
627 | 627 | */ |
628 | - $custom_slug_id_access = $force_allow_ids || apply_filters( 'gravityview_custom_entry_slug_allow_id', false ); |
|
628 | + $custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false); |
|
629 | 629 | |
630 | 630 | /** |
631 | 631 | * If we're using custom entry slugs, we do a meta value search |
632 | 632 | * instead of doing a straightup ID search. |
633 | 633 | */ |
634 | - if ( $custom_slug ) { |
|
634 | + if ($custom_slug) { |
|
635 | 635 | |
636 | - $entry_id = self::get_entry_id_from_slug( $entry_slug ); |
|
636 | + $entry_id = self::get_entry_id_from_slug($entry_slug); |
|
637 | 637 | |
638 | 638 | } |
639 | 639 | |
640 | 640 | // If custom slug is off, search using the entry ID |
641 | 641 | // ID allow ID access is on, also use entry ID as a backup |
642 | - if ( empty( $custom_slug ) || ! empty( $custom_slug_id_access ) ) { |
|
642 | + if (empty($custom_slug) || !empty($custom_slug_id_access)) { |
|
643 | 643 | // Search for IDs matching $entry_slug |
644 | 644 | $entry_id = $entry_slug; |
645 | 645 | } |
646 | 646 | |
647 | - if ( empty( $entry_id ) ) { |
|
647 | + if (empty($entry_id)) { |
|
648 | 648 | return false; |
649 | 649 | } |
650 | 650 | |
651 | 651 | // fetch the entry |
652 | - $entry = GFAPI::get_entry( $entry_id ); |
|
652 | + $entry = GFAPI::get_entry($entry_id); |
|
653 | 653 | |
654 | - if( $check_entry_display ) { |
|
654 | + if ($check_entry_display) { |
|
655 | 655 | // Is the entry allowed |
656 | - $entry = self::check_entry_display( $entry ); |
|
656 | + $entry = self::check_entry_display($entry); |
|
657 | 657 | } |
658 | 658 | |
659 | - return is_wp_error( $entry ) ? false : $entry; |
|
659 | + return is_wp_error($entry) ? false : $entry; |
|
660 | 660 | |
661 | 661 | } |
662 | 662 | |
@@ -680,51 +680,51 @@ discard block |
||
680 | 680 | * |
681 | 681 | * @return bool True: matches, false: not matches |
682 | 682 | */ |
683 | - public static function matches_operation( $val1, $val2, $operation ) { |
|
683 | + public static function matches_operation($val1, $val2, $operation) { |
|
684 | 684 | |
685 | 685 | $value = false; |
686 | 686 | |
687 | - if( 'context' === $val1 ) { |
|
687 | + if ('context' === $val1) { |
|
688 | 688 | |
689 | - $matching_contexts = array( $val2 ); |
|
689 | + $matching_contexts = array($val2); |
|
690 | 690 | |
691 | 691 | // We allow for non-standard contexts. |
692 | - switch( $val2 ) { |
|
692 | + switch ($val2) { |
|
693 | 693 | // Check for either single or edit |
694 | 694 | case 'singular': |
695 | - $matching_contexts = array( 'single', 'edit' ); |
|
695 | + $matching_contexts = array('single', 'edit'); |
|
696 | 696 | break; |
697 | 697 | // Use multiple as alias for directory for consistency |
698 | 698 | case 'multiple': |
699 | - $matching_contexts = array( 'directory' ); |
|
699 | + $matching_contexts = array('directory'); |
|
700 | 700 | break; |
701 | 701 | } |
702 | 702 | |
703 | - $val1 = in_array( gravityview_get_context(), $matching_contexts ) ? $val2 : false; |
|
703 | + $val1 = in_array(gravityview_get_context(), $matching_contexts) ? $val2 : false; |
|
704 | 704 | } |
705 | 705 | |
706 | - switch ( $operation ) { |
|
706 | + switch ($operation) { |
|
707 | 707 | case 'equals': |
708 | - $value = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
708 | + $value = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
709 | 709 | break; |
710 | 710 | case 'greater_than_or_is': |
711 | 711 | case 'greater_than_or_equals': |
712 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
713 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'greater_than' ); |
|
714 | - $value = ( $is || $gt ); |
|
712 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
713 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'greater_than'); |
|
714 | + $value = ($is || $gt); |
|
715 | 715 | break; |
716 | 716 | case 'less_than_or_is': |
717 | 717 | case 'less_than_or_equals': |
718 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
719 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'less_than' ); |
|
720 | - $value = ( $is || $gt ); |
|
718 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
719 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'less_than'); |
|
720 | + $value = ($is || $gt); |
|
721 | 721 | break; |
722 | 722 | case 'not_contains': |
723 | - $contains = GFFormsModel::matches_operation( $val1, $val2, 'contains' ); |
|
724 | - $value = ! $contains; |
|
723 | + $contains = GFFormsModel::matches_operation($val1, $val2, 'contains'); |
|
724 | + $value = !$contains; |
|
725 | 725 | break; |
726 | 726 | default: |
727 | - $value = GFFormsModel::matches_operation( $val1, $val2, $operation ); |
|
727 | + $value = GFFormsModel::matches_operation($val1, $val2, $operation); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | return $value; |
@@ -742,41 +742,41 @@ discard block |
||
742 | 742 | * @param array $entry Gravity Forms Entry object |
743 | 743 | * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter) |
744 | 744 | */ |
745 | - public static function check_entry_display( $entry ) { |
|
745 | + public static function check_entry_display($entry) { |
|
746 | 746 | |
747 | - if ( ! $entry || is_wp_error( $entry ) ) { |
|
748 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry ); |
|
747 | + if (!$entry || is_wp_error($entry)) { |
|
748 | + do_action('gravityview_log_debug', __METHOD__.' Entry was not found.', $entry); |
|
749 | 749 | return false; |
750 | 750 | } |
751 | 751 | |
752 | - if ( empty( $entry['form_id'] ) ) { |
|
753 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
|
752 | + if (empty($entry['form_id'])) { |
|
753 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry); |
|
754 | 754 | return false; |
755 | 755 | } |
756 | 756 | |
757 | 757 | $criteria = self::calculate_get_entries_criteria(); |
758 | 758 | |
759 | 759 | // Make sure the current View is connected to the same form as the Entry |
760 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
761 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
762 | - $context_form_id = gravityview_get_form_id( $context_view_id ); |
|
763 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
764 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
760 | + if (!empty($criteria['context_view_id'])) { |
|
761 | + $context_view_id = intval($criteria['context_view_id']); |
|
762 | + $context_form_id = gravityview_get_form_id($context_view_id); |
|
763 | + if (intval($context_form_id) !== intval($entry['form_id'])) { |
|
764 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id']), $criteria['context_view_id']); |
|
765 | 765 | return false; |
766 | 766 | } |
767 | 767 | } |
768 | 768 | |
769 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
770 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
|
769 | + if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) { |
|
770 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria); |
|
771 | 771 | return $entry; |
772 | 772 | } |
773 | 773 | |
774 | 774 | $search_criteria = $criteria['search_criteria']; |
775 | - unset( $criteria ); |
|
775 | + unset($criteria); |
|
776 | 776 | |
777 | 777 | // check entry status |
778 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
779 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
778 | + if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) { |
|
779 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria); |
|
780 | 780 | return false; |
781 | 781 | } |
782 | 782 | |
@@ -784,53 +784,53 @@ discard block |
||
784 | 784 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
785 | 785 | |
786 | 786 | // field_filters |
787 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
788 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
|
787 | + if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) { |
|
788 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria); |
|
789 | 789 | return $entry; |
790 | 790 | } |
791 | 791 | |
792 | 792 | $filters = $search_criteria['field_filters']; |
793 | - unset( $search_criteria ); |
|
793 | + unset($search_criteria); |
|
794 | 794 | |
795 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
796 | - unset( $filters['mode'] ); |
|
795 | + $mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all'; |
|
796 | + unset($filters['mode']); |
|
797 | 797 | |
798 | - $form = self::get_form( $entry['form_id'] ); |
|
798 | + $form = self::get_form($entry['form_id']); |
|
799 | 799 | |
800 | - foreach ( $filters as $filter ) { |
|
800 | + foreach ($filters as $filter) { |
|
801 | 801 | |
802 | - if ( ! isset( $filter['key'] ) ) { |
|
802 | + if (!isset($filter['key'])) { |
|
803 | 803 | continue; |
804 | 804 | } |
805 | 805 | |
806 | 806 | $k = $filter['key']; |
807 | 807 | |
808 | - if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
|
809 | - $field_value = $entry[ $k ]; |
|
808 | + if (in_array($k, array('created_by', 'payment_status'))) { |
|
809 | + $field_value = $entry[$k]; |
|
810 | 810 | $field = null; |
811 | 811 | } else { |
812 | - $field = self::get_field( $form, $k ); |
|
813 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
812 | + $field = self::get_field($form, $k); |
|
813 | + $field_value = GFFormsModel::get_lead_field_value($entry, $field); |
|
814 | 814 | } |
815 | 815 | |
816 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
817 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
816 | + $operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is'; |
|
817 | + $is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field); |
|
818 | 818 | |
819 | 819 | // verify if we are already free to go! |
820 | - if ( ! $is_value_match && 'all' === $mode ) { |
|
821 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter ); |
|
820 | + if (!$is_value_match && 'all' === $mode) { |
|
821 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter); |
|
822 | 822 | return false; |
823 | - } elseif ( $is_value_match && 'any' === $mode ) { |
|
823 | + } elseif ($is_value_match && 'any' === $mode) { |
|
824 | 824 | return $entry; |
825 | 825 | } |
826 | 826 | } |
827 | 827 | |
828 | 828 | // at this point, if in ALL mode, then entry is approved - all conditions were met. |
829 | 829 | // Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved |
830 | - if ( 'all' === $mode ) { |
|
830 | + if ('all' === $mode) { |
|
831 | 831 | return $entry; |
832 | 832 | } else { |
833 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
833 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters); |
|
834 | 834 | return false; |
835 | 835 | } |
836 | 836 | |
@@ -845,14 +845,14 @@ discard block |
||
845 | 845 | * @param string $field_id |
846 | 846 | * @return string |
847 | 847 | */ |
848 | - public static function get_field_label( $form = array(), $field_id = '' ) { |
|
848 | + public static function get_field_label($form = array(), $field_id = '') { |
|
849 | 849 | |
850 | - if ( empty( $form ) || empty( $field_id ) ) { |
|
850 | + if (empty($form) || empty($field_id)) { |
|
851 | 851 | return ''; |
852 | 852 | } |
853 | 853 | |
854 | - $field = self::get_field( $form, $field_id ); |
|
855 | - return isset( $field['label'] ) ? $field['label'] : ''; |
|
854 | + $field = self::get_field($form, $field_id); |
|
855 | + return isset($field['label']) ? $field['label'] : ''; |
|
856 | 856 | |
857 | 857 | } |
858 | 858 | |
@@ -869,9 +869,9 @@ discard block |
||
869 | 869 | * @param string|int $field_id |
870 | 870 | * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist |
871 | 871 | */ |
872 | - public static function get_field( $form, $field_id ) { |
|
873 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
874 | - return GFFormsModel::get_field( $form, $field_id ); |
|
872 | + public static function get_field($form, $field_id) { |
|
873 | + if (class_exists('GFFormsModel')) { |
|
874 | + return GFFormsModel::get_field($form, $field_id); |
|
875 | 875 | } else { |
876 | 876 | return null; |
877 | 877 | } |
@@ -887,16 +887,16 @@ discard block |
||
887 | 887 | * @param WP_Post $post WordPress post object |
888 | 888 | * @return boolean True: yep, GravityView; No: not! |
889 | 889 | */ |
890 | - public static function has_gravityview_shortcode( $post = null ) { |
|
891 | - if ( ! is_a( $post, 'WP_Post' ) ) { |
|
890 | + public static function has_gravityview_shortcode($post = null) { |
|
891 | + if (!is_a($post, 'WP_Post')) { |
|
892 | 892 | return false; |
893 | 893 | } |
894 | 894 | |
895 | - if ( 'gravityview' === get_post_type( $post ) ) { |
|
895 | + if ('gravityview' === get_post_type($post)) { |
|
896 | 896 | return true; |
897 | 897 | } |
898 | 898 | |
899 | - return self::has_shortcode_r( $post->post_content, 'gravityview' ) ? true : false; |
|
899 | + return self::has_shortcode_r($post->post_content, 'gravityview') ? true : false; |
|
900 | 900 | |
901 | 901 | } |
902 | 902 | |
@@ -907,27 +907,27 @@ discard block |
||
907 | 907 | * @param string $content Content to check whether there's a shortcode |
908 | 908 | * @param string $tag Current shortcode tag |
909 | 909 | */ |
910 | - public static function has_shortcode_r( $content, $tag = 'gravityview' ) { |
|
911 | - if ( false === strpos( $content, '[' ) ) { |
|
910 | + public static function has_shortcode_r($content, $tag = 'gravityview') { |
|
911 | + if (false === strpos($content, '[')) { |
|
912 | 912 | return false; |
913 | 913 | } |
914 | 914 | |
915 | - if ( shortcode_exists( $tag ) ) { |
|
915 | + if (shortcode_exists($tag)) { |
|
916 | 916 | |
917 | 917 | $shortcodes = array(); |
918 | 918 | |
919 | - preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
|
920 | - if ( empty( $matches ) ){ |
|
919 | + preg_match_all('/'.get_shortcode_regex().'/s', $content, $matches, PREG_SET_ORDER); |
|
920 | + if (empty($matches)) { |
|
921 | 921 | return false; |
922 | 922 | } |
923 | 923 | |
924 | - foreach ( $matches as $shortcode ) { |
|
925 | - if ( $tag === $shortcode[2] ) { |
|
924 | + foreach ($matches as $shortcode) { |
|
925 | + if ($tag === $shortcode[2]) { |
|
926 | 926 | |
927 | 927 | // Changed this to $shortcode instead of true so we get the parsed atts. |
928 | 928 | $shortcodes[] = $shortcode; |
929 | 929 | |
930 | - } else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
930 | + } else if (isset($shortcode[5]) && $result = self::has_shortcode_r($shortcode[5], $tag)) { |
|
931 | 931 | $shortcodes = $result; |
932 | 932 | } |
933 | 933 | } |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | * |
952 | 952 | * @return array Array with view details, as returned by get_posts() |
953 | 953 | */ |
954 | - public static function get_connected_views( $form_id, $args = array() ) { |
|
954 | + public static function get_connected_views($form_id, $args = array()) { |
|
955 | 955 | |
956 | 956 | $defaults = array( |
957 | 957 | 'post_type' => 'gravityview', |
@@ -960,9 +960,9 @@ discard block |
||
960 | 960 | 'meta_value' => (int)$form_id, |
961 | 961 | ); |
962 | 962 | |
963 | - $args = wp_parse_args( $args, $defaults ); |
|
963 | + $args = wp_parse_args($args, $defaults); |
|
964 | 964 | |
965 | - $views = get_posts( $args ); |
|
965 | + $views = get_posts($args); |
|
966 | 966 | |
967 | 967 | return $views; |
968 | 968 | } |
@@ -974,8 +974,8 @@ discard block |
||
974 | 974 | * |
975 | 975 | * @return string ID of the connected Form, if exists. Empty string if not. |
976 | 976 | */ |
977 | - public static function get_meta_form_id( $view_id ) { |
|
978 | - return get_post_meta( $view_id, '_gravityview_form_id', true ); |
|
977 | + public static function get_meta_form_id($view_id) { |
|
978 | + return get_post_meta($view_id, '_gravityview_form_id', true); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | /** |
@@ -987,8 +987,8 @@ discard block |
||
987 | 987 | * |
988 | 988 | * @return string GravityView_Template::template_id value. Empty string if not. |
989 | 989 | */ |
990 | - public static function get_meta_template_id( $view_id ) { |
|
991 | - return get_post_meta( $view_id, '_gravityview_directory_template', true ); |
|
990 | + public static function get_meta_template_id($view_id) { |
|
991 | + return get_post_meta($view_id, '_gravityview_directory_template', true); |
|
992 | 992 | } |
993 | 993 | |
994 | 994 | |
@@ -999,15 +999,15 @@ discard block |
||
999 | 999 | * @param int $post_id View ID |
1000 | 1000 | * @return array Associative array of settings with plugin defaults used if not set by the View |
1001 | 1001 | */ |
1002 | - public static function get_template_settings( $post_id ) { |
|
1002 | + public static function get_template_settings($post_id) { |
|
1003 | 1003 | |
1004 | - $settings = get_post_meta( $post_id, '_gravityview_template_settings', true ); |
|
1004 | + $settings = get_post_meta($post_id, '_gravityview_template_settings', true); |
|
1005 | 1005 | |
1006 | - if ( class_exists( 'GravityView_View_Data' ) ) { |
|
1006 | + if (class_exists('GravityView_View_Data')) { |
|
1007 | 1007 | |
1008 | 1008 | $defaults = GravityView_View_Data::get_default_args(); |
1009 | 1009 | |
1010 | - return wp_parse_args( (array)$settings, $defaults ); |
|
1010 | + return wp_parse_args((array)$settings, $defaults); |
|
1011 | 1011 | |
1012 | 1012 | } |
1013 | 1013 | |
@@ -1024,12 +1024,12 @@ discard block |
||
1024 | 1024 | * @param string $key Key for the setting |
1025 | 1025 | * @return mixed|null Setting value, or NULL if not set. |
1026 | 1026 | */ |
1027 | - public static function get_template_setting( $post_id, $key ) { |
|
1027 | + public static function get_template_setting($post_id, $key) { |
|
1028 | 1028 | |
1029 | - $settings = self::get_template_settings( $post_id ); |
|
1029 | + $settings = self::get_template_settings($post_id); |
|
1030 | 1030 | |
1031 | - if ( isset( $settings[ $key ] ) ) { |
|
1032 | - return $settings[ $key ]; |
|
1031 | + if (isset($settings[$key])) { |
|
1032 | + return $settings[$key]; |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | return null; |
@@ -1065,8 +1065,8 @@ discard block |
||
1065 | 1065 | * @param int $post_id View ID |
1066 | 1066 | * @return array Multi-array of fields with first level being the field zones. See code comment. |
1067 | 1067 | */ |
1068 | - public static function get_directory_fields( $post_id ) { |
|
1069 | - return get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
|
1068 | + public static function get_directory_fields($post_id) { |
|
1069 | + return get_post_meta($post_id, '_gravityview_directory_fields', true); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | |
@@ -1077,25 +1077,25 @@ discard block |
||
1077 | 1077 | * @param int $formid Form ID |
1078 | 1078 | * @return string html |
1079 | 1079 | */ |
1080 | - public static function get_sortable_fields( $formid, $current = '' ) { |
|
1081 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1080 | + public static function get_sortable_fields($formid, $current = '') { |
|
1081 | + $output = '<option value="" '.selected('', $current, false).'>'.esc_html__('Default', 'gravityview').'</option>'; |
|
1082 | 1082 | |
1083 | - if ( empty( $formid ) ) { |
|
1083 | + if (empty($formid)) { |
|
1084 | 1084 | return $output; |
1085 | 1085 | } |
1086 | 1086 | |
1087 | - $fields = self::get_sortable_fields_array( $formid ); |
|
1087 | + $fields = self::get_sortable_fields_array($formid); |
|
1088 | 1088 | |
1089 | - if ( ! empty( $fields ) ) { |
|
1089 | + if (!empty($fields)) { |
|
1090 | 1090 | |
1091 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
|
1091 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('list', 'textarea'), null); |
|
1092 | 1092 | |
1093 | - foreach ( $fields as $id => $field ) { |
|
1094 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1093 | + foreach ($fields as $id => $field) { |
|
1094 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
1095 | 1095 | continue; |
1096 | 1096 | } |
1097 | 1097 | |
1098 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1098 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'>'.esc_attr($field['label']).'</option>'; |
|
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | |
@@ -1113,27 +1113,27 @@ discard block |
||
1113 | 1113 | * |
1114 | 1114 | * @return array |
1115 | 1115 | */ |
1116 | - public static function get_sortable_fields_array( $formid, $blacklist = array( 'list', 'textarea' ) ) { |
|
1116 | + public static function get_sortable_fields_array($formid, $blacklist = array('list', 'textarea')) { |
|
1117 | 1117 | |
1118 | 1118 | // Get fields with sub-inputs and no parent |
1119 | - $fields = self::get_form_fields( $formid, true, false ); |
|
1119 | + $fields = self::get_form_fields($formid, true, false); |
|
1120 | 1120 | |
1121 | 1121 | $date_created = array( |
1122 | 1122 | 'date_created' => array( |
1123 | 1123 | 'type' => 'date_created', |
1124 | - 'label' => __( 'Date Created', 'gravityview' ), |
|
1124 | + 'label' => __('Date Created', 'gravityview'), |
|
1125 | 1125 | ), |
1126 | 1126 | ); |
1127 | 1127 | |
1128 | 1128 | $fields = $date_created + $fields; |
1129 | 1129 | |
1130 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
|
1130 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', $blacklist, NULL); |
|
1131 | 1131 | |
1132 | 1132 | // TODO: Convert to using array_filter |
1133 | - foreach( $fields as $id => $field ) { |
|
1133 | + foreach ($fields as $id => $field) { |
|
1134 | 1134 | |
1135 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1136 | - unset( $fields[ $id ] ); |
|
1135 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
1136 | + unset($fields[$id]); |
|
1137 | 1137 | } |
1138 | 1138 | } |
1139 | 1139 | |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | * @param array $fields Sub-set of GF form fields that are sortable |
1144 | 1144 | * @param int $formid The Gravity Forms form ID that the fields are from |
1145 | 1145 | */ |
1146 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1146 | + $fields = apply_filters('gravityview/common/sortable_fields', $fields, $formid); |
|
1147 | 1147 | |
1148 | 1148 | return $fields; |
1149 | 1149 | } |
@@ -1154,15 +1154,15 @@ discard block |
||
1154 | 1154 | * @param mixed $field_id Field ID or Field array |
1155 | 1155 | * @return string field type |
1156 | 1156 | */ |
1157 | - public static function get_field_type( $form = null, $field_id = '' ) { |
|
1157 | + public static function get_field_type($form = null, $field_id = '') { |
|
1158 | 1158 | |
1159 | - if ( ! empty( $field_id ) && ! is_array( $field_id ) ) { |
|
1160 | - $field = self::get_field( $form, $field_id ); |
|
1159 | + if (!empty($field_id) && !is_array($field_id)) { |
|
1160 | + $field = self::get_field($form, $field_id); |
|
1161 | 1161 | } else { |
1162 | 1162 | $field = $field_id; |
1163 | 1163 | } |
1164 | 1164 | |
1165 | - return class_exists( 'RGFormsModel' ) ? RGFormsModel::get_input_type( $field ) : ''; |
|
1165 | + return class_exists('RGFormsModel') ? RGFormsModel::get_input_type($field) : ''; |
|
1166 | 1166 | |
1167 | 1167 | } |
1168 | 1168 | |
@@ -1173,22 +1173,22 @@ discard block |
||
1173 | 1173 | * @param int|array $field field key or field array |
1174 | 1174 | * @return boolean |
1175 | 1175 | */ |
1176 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1176 | + public static function is_field_numeric($form = null, $field = '') { |
|
1177 | 1177 | |
1178 | 1178 | /** |
1179 | 1179 | * @filter `gravityview/common/numeric_types` What types of fields are numeric? |
1180 | 1180 | * @since 1.5.2 |
1181 | 1181 | * @param array $numeric_types Fields that are numeric. Default: `[ number, time ]` |
1182 | 1182 | */ |
1183 | - $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
|
1183 | + $numeric_types = apply_filters('gravityview/common/numeric_types', array('number', 'time')); |
|
1184 | 1184 | |
1185 | - if ( ! is_array( $form ) && ! is_array( $field ) ) { |
|
1186 | - $form = self::get_form( $form ); |
|
1185 | + if (!is_array($form) && !is_array($field)) { |
|
1186 | + $form = self::get_form($form); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | - $type = self::get_field_type( $form, $field ); |
|
1189 | + $type = self::get_field_type($form, $field); |
|
1190 | 1190 | |
1191 | - return in_array( $type, $numeric_types ); |
|
1191 | + return in_array($type, $numeric_types); |
|
1192 | 1192 | |
1193 | 1193 | } |
1194 | 1194 | |
@@ -1206,19 +1206,19 @@ discard block |
||
1206 | 1206 | * |
1207 | 1207 | * @return string Content, encrypted |
1208 | 1208 | */ |
1209 | - public static function js_encrypt( $content, $message = '' ) { |
|
1209 | + public static function js_encrypt($content, $message = '') { |
|
1210 | 1210 | |
1211 | 1211 | $output = $content; |
1212 | 1212 | |
1213 | - if ( ! class_exists( 'StandalonePHPEnkoder' ) ) { |
|
1214 | - include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' ); |
|
1213 | + if (!class_exists('StandalonePHPEnkoder')) { |
|
1214 | + include_once(GRAVITYVIEW_DIR.'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php'); |
|
1215 | 1215 | } |
1216 | 1216 | |
1217 | - if ( class_exists( 'StandalonePHPEnkoder' ) ) { |
|
1217 | + if (class_exists('StandalonePHPEnkoder')) { |
|
1218 | 1218 | |
1219 | 1219 | $enkoder = new StandalonePHPEnkoder; |
1220 | 1220 | |
1221 | - $message = empty( $message ) ? __( 'Email hidden; Javascript is required.', 'gravityview' ) : $message; |
|
1221 | + $message = empty($message) ? __('Email hidden; Javascript is required.', 'gravityview') : $message; |
|
1222 | 1222 | |
1223 | 1223 | /** |
1224 | 1224 | * @filter `gravityview/phpenkoder/msg` Modify the message shown when Javascript is disabled and an encrypted email field is displayed |
@@ -1226,9 +1226,9 @@ discard block |
||
1226 | 1226 | * @param string $message Existing message |
1227 | 1227 | * @param string $content Content to encrypt |
1228 | 1228 | */ |
1229 | - $enkoder->enkode_msg = apply_filters( 'gravityview/phpenkoder/msg', $message, $content ); |
|
1229 | + $enkoder->enkode_msg = apply_filters('gravityview/phpenkoder/msg', $message, $content); |
|
1230 | 1230 | |
1231 | - $output = $enkoder->enkode( $content ); |
|
1231 | + $output = $enkoder->enkode($content); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | return $output; |
@@ -1245,25 +1245,25 @@ discard block |
||
1245 | 1245 | * |
1246 | 1246 | * @author rubo77 at https://gist.github.com/rubo77/6821632 |
1247 | 1247 | **/ |
1248 | - public static function gv_parse_str( $string, &$result ) { |
|
1249 | - if ( empty( $string ) ) { |
|
1248 | + public static function gv_parse_str($string, &$result) { |
|
1249 | + if (empty($string)) { |
|
1250 | 1250 | return false; |
1251 | 1251 | } |
1252 | 1252 | |
1253 | 1253 | $result = array(); |
1254 | 1254 | |
1255 | 1255 | // find the pairs "name=value" |
1256 | - $pairs = explode( '&', $string ); |
|
1256 | + $pairs = explode('&', $string); |
|
1257 | 1257 | |
1258 | - foreach ( $pairs as $pair ) { |
|
1258 | + foreach ($pairs as $pair) { |
|
1259 | 1259 | // use the original parse_str() on each element |
1260 | - parse_str( $pair, $params ); |
|
1260 | + parse_str($pair, $params); |
|
1261 | 1261 | |
1262 | - $k = key( $params ); |
|
1263 | - if ( ! isset( $result[ $k ] ) ) { |
|
1262 | + $k = key($params); |
|
1263 | + if (!isset($result[$k])) { |
|
1264 | 1264 | $result += $params; |
1265 | - } elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) { |
|
1266 | - $result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] ); |
|
1265 | + } elseif (array_key_exists($k, $params) && is_array($params[$k])) { |
|
1266 | + $result[$k] = self::array_merge_recursive_distinct($result[$k], $params[$k]); |
|
1267 | 1267 | } |
1268 | 1268 | } |
1269 | 1269 | return true; |
@@ -1285,7 +1285,7 @@ discard block |
||
1285 | 1285 | * |
1286 | 1286 | * @return string HTML output of anchor link. If empty $href, returns NULL |
1287 | 1287 | */ |
1288 | - public static function get_link_html( $href = '', $anchor_text = '', $atts = array() ) { |
|
1288 | + public static function get_link_html($href = '', $anchor_text = '', $atts = array()) { |
|
1289 | 1289 | |
1290 | 1290 | // Supported attributes for anchor tags. HREF left out intentionally. |
1291 | 1291 | $allowed_atts = array( |
@@ -1321,31 +1321,31 @@ discard block |
||
1321 | 1321 | * @filter `gravityview/get_link/allowed_atts` Modify the attributes that are allowed to be used in generating links |
1322 | 1322 | * @param array $allowed_atts Array of attributes allowed |
1323 | 1323 | */ |
1324 | - $allowed_atts = apply_filters( 'gravityview/get_link/allowed_atts', $allowed_atts ); |
|
1324 | + $allowed_atts = apply_filters('gravityview/get_link/allowed_atts', $allowed_atts); |
|
1325 | 1325 | |
1326 | 1326 | // Make sure the attributes are formatted as array |
1327 | - $passed_atts = wp_parse_args( $atts ); |
|
1327 | + $passed_atts = wp_parse_args($atts); |
|
1328 | 1328 | |
1329 | 1329 | // Make sure the allowed attributes are only the ones in the $allowed_atts list |
1330 | - $final_atts = shortcode_atts( $allowed_atts, $passed_atts ); |
|
1330 | + $final_atts = shortcode_atts($allowed_atts, $passed_atts); |
|
1331 | 1331 | |
1332 | 1332 | // Remove attributes with empty values |
1333 | - $final_atts = array_filter( $final_atts ); |
|
1333 | + $final_atts = array_filter($final_atts); |
|
1334 | 1334 | |
1335 | 1335 | // If the href wasn't passed as an attribute, use the value passed to the function |
1336 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1336 | + if (empty($final_atts['href']) && !empty($href)) { |
|
1337 | 1337 | $final_atts['href'] = $href; |
1338 | 1338 | } |
1339 | 1339 | |
1340 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1340 | + $final_atts['href'] = esc_url_raw($href); |
|
1341 | 1341 | |
1342 | 1342 | // For each attribute, generate the code |
1343 | 1343 | $output = ''; |
1344 | - foreach ( $final_atts as $attr => $value ) { |
|
1345 | - $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
|
1344 | + foreach ($final_atts as $attr => $value) { |
|
1345 | + $output .= sprintf(' %s="%s"', $attr, esc_attr($value)); |
|
1346 | 1346 | } |
1347 | 1347 | |
1348 | - $output = '<a'. $output .'>'. $anchor_text .'</a>'; |
|
1348 | + $output = '<a'.$output.'>'.$anchor_text.'</a>'; |
|
1349 | 1349 | |
1350 | 1350 | return $output; |
1351 | 1351 | } |
@@ -1364,14 +1364,14 @@ discard block |
||
1364 | 1364 | * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk> |
1365 | 1365 | * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com> |
1366 | 1366 | */ |
1367 | - public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
|
1367 | + public static function array_merge_recursive_distinct(array &$array1, array &$array2) { |
|
1368 | 1368 | $merged = $array1; |
1369 | 1369 | |
1370 | - foreach ( $array2 as $key => &$value ) { |
|
1371 | - if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
|
1372 | - $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
|
1370 | + foreach ($array2 as $key => &$value) { |
|
1371 | + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { |
|
1372 | + $merged[$key] = self::array_merge_recursive_distinct($merged[$key], $value); |
|
1373 | 1373 | } else { |
1374 | - $merged[ $key ] = $value; |
|
1374 | + $merged[$key] = $value; |
|
1375 | 1375 | } |
1376 | 1376 | } |
1377 | 1377 | |
@@ -1385,26 +1385,26 @@ discard block |
||
1385 | 1385 | * @param array $args Arguments to modify the user query. See get_users() {@since 1.14} |
1386 | 1386 | * @return array Array of WP_User objects. |
1387 | 1387 | */ |
1388 | - public static function get_users( $context = 'change_entry_creator', $args = array() ) { |
|
1388 | + public static function get_users($context = 'change_entry_creator', $args = array()) { |
|
1389 | 1389 | |
1390 | 1390 | $default_args = array( |
1391 | 1391 | 'number' => 2000, |
1392 | 1392 | 'orderby' => 'display_name', |
1393 | 1393 | 'order' => 'ASC', |
1394 | - 'fields' => array( 'ID', 'display_name', 'user_login', 'user_nicename' ) |
|
1394 | + 'fields' => array('ID', 'display_name', 'user_login', 'user_nicename') |
|
1395 | 1395 | ); |
1396 | 1396 | |
1397 | 1397 | // Merge in the passed arg |
1398 | - $get_users_settings = wp_parse_args( $args, $default_args ); |
|
1398 | + $get_users_settings = wp_parse_args($args, $default_args); |
|
1399 | 1399 | |
1400 | 1400 | /** |
1401 | 1401 | * @filter `gravityview/get_users/{$context}` There are issues with too many users using [get_users()](http://codex.wordpress.org/Function_Reference/get_users) where it breaks the select. We try to keep it at a reasonable number. \n |
1402 | 1402 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1403 | 1403 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1404 | 1404 | */ |
1405 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1405 | + $get_users_settings = apply_filters('gravityview/get_users/'.$context, apply_filters('gravityview_change_entry_creator_user_parameters', $get_users_settings)); |
|
1406 | 1406 | |
1407 | - return get_users( $get_users_settings ); |
|
1407 | + return get_users($get_users_settings); |
|
1408 | 1408 | } |
1409 | 1409 | |
1410 | 1410 | |
@@ -1416,8 +1416,8 @@ discard block |
||
1416 | 1416 | * |
1417 | 1417 | * @return string |
1418 | 1418 | */ |
1419 | - public static function generate_notice( $notice, $class = '' ) { |
|
1420 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1419 | + public static function generate_notice($notice, $class = '') { |
|
1420 | + return '<div class="gv-notice '.gravityview_sanitize_html_class($class).'">'.$notice.'</div>'; |
|
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | |
@@ -1439,6 +1439,6 @@ discard block |
||
1439 | 1439 | * |
1440 | 1440 | * @return string HTML output of anchor link. If empty $href, returns NULL |
1441 | 1441 | */ |
1442 | -function gravityview_get_link( $href = '', $anchor_text = '', $atts = array() ) { |
|
1443 | - return GVCommon::get_link_html( $href, $anchor_text, $atts ); |
|
1442 | +function gravityview_get_link($href = '', $anchor_text = '', $atts = array()) { |
|
1443 | + return GVCommon::get_link_html($href, $anchor_text, $atts); |
|
1444 | 1444 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @copyright Copyright 2014, Katz Web Services, Inc. |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'WPINC' ) ) { |
|
12 | +if (!defined('WPINC')) { |
|
13 | 13 | die; |
14 | 14 | } |
15 | 15 | |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct() { |
24 | 24 | |
25 | - $this->widget_description = esc_html__( 'Search form for searching entries.', 'gravityview' ); |
|
25 | + $this->widget_description = esc_html__('Search form for searching entries.', 'gravityview'); |
|
26 | 26 | |
27 | 27 | self::$instance = &$this; |
28 | 28 | |
29 | - self::$file = plugin_dir_path( __FILE__ ); |
|
29 | + self::$file = plugin_dir_path(__FILE__); |
|
30 | 30 | |
31 | - $default_values = array( 'header' => 0, 'footer' => 0 ); |
|
31 | + $default_values = array('header' => 0, 'footer' => 0); |
|
32 | 32 | |
33 | 33 | $settings = array( |
34 | 34 | 'search_layout' => array( |
35 | 35 | 'type' => 'radio', |
36 | 36 | 'full_width' => true, |
37 | - 'label' => esc_html__( 'Search Layout', 'gravityview' ), |
|
37 | + 'label' => esc_html__('Search Layout', 'gravityview'), |
|
38 | 38 | 'value' => 'horizontal', |
39 | 39 | 'options' => array( |
40 | - 'horizontal' => esc_html__( 'Horizontal', 'gravityview' ), |
|
41 | - 'vertical' => esc_html__( 'Vertical', 'gravityview' ), |
|
40 | + 'horizontal' => esc_html__('Horizontal', 'gravityview'), |
|
41 | + 'vertical' => esc_html__('Vertical', 'gravityview'), |
|
42 | 42 | ), |
43 | 43 | ), |
44 | 44 | 'search_clear' => array( |
45 | 45 | 'type' => 'checkbox', |
46 | - 'label' => __( 'Show Clear button', 'gravityview' ), |
|
46 | + 'label' => __('Show Clear button', 'gravityview'), |
|
47 | 47 | 'value' => false, |
48 | 48 | ), |
49 | 49 | 'search_fields' => array( |
@@ -55,33 +55,33 @@ discard block |
||
55 | 55 | 'search_mode' => array( |
56 | 56 | 'type' => 'radio', |
57 | 57 | 'full_width' => true, |
58 | - 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
|
58 | + 'label' => esc_html__('Search Mode', 'gravityview'), |
|
59 | 59 | 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
60 | 60 | 'value' => 'any', |
61 | 61 | 'class' => 'hide-if-js', |
62 | 62 | 'options' => array( |
63 | - 'any' => esc_html__( 'Match Any Fields', 'gravityview' ), |
|
64 | - 'all' => esc_html__( 'Match All Fields', 'gravityview' ), |
|
63 | + 'any' => esc_html__('Match Any Fields', 'gravityview'), |
|
64 | + 'all' => esc_html__('Match All Fields', 'gravityview'), |
|
65 | 65 | ), |
66 | 66 | ), |
67 | 67 | ); |
68 | - parent::__construct( esc_html__( 'Search Bar', 'gravityview' ), 'search_bar', $default_values, $settings ); |
|
68 | + parent::__construct(esc_html__('Search Bar', 'gravityview'), 'search_bar', $default_values, $settings); |
|
69 | 69 | |
70 | 70 | // frontend - filter entries |
71 | - add_filter( 'gravityview_fe_search_criteria', array( $this, 'filter_entries' ), 10, 1 ); |
|
71 | + add_filter('gravityview_fe_search_criteria', array($this, 'filter_entries'), 10, 1); |
|
72 | 72 | |
73 | 73 | // frontend - add template path |
74 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
74 | + add_filter('gravityview_template_paths', array($this, 'add_template_path')); |
|
75 | 75 | |
76 | 76 | // Add hidden fields for "Default" permalink structure |
77 | - add_filter( 'gravityview_widget_search_filters', array( $this, 'add_no_permalink_fields' ), 10, 3 ); |
|
77 | + add_filter('gravityview_widget_search_filters', array($this, 'add_no_permalink_fields'), 10, 3); |
|
78 | 78 | |
79 | 79 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
80 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
|
81 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
80 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles'), 1100); |
|
81 | + add_filter('gravityview_noconflict_scripts', array($this, 'register_no_conflict')); |
|
82 | 82 | |
83 | 83 | // ajax - get the searchable fields |
84 | - add_action( 'wp_ajax_gv_searchable_fields', array( 'GravityView_Widget_Search', 'get_searchable_fields' ) ); |
|
84 | + add_action('wp_ajax_gv_searchable_fields', array('GravityView_Widget_Search', 'get_searchable_fields')); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return GravityView_Widget_Search |
90 | 90 | */ |
91 | 91 | public static function getInstance() { |
92 | - if ( empty( self::$instance ) ) { |
|
92 | + if (empty(self::$instance)) { |
|
93 | 93 | self::$instance = new GravityView_Widget_Search; |
94 | 94 | } |
95 | 95 | return self::$instance; |
@@ -100,18 +100,18 @@ discard block |
||
100 | 100 | * Add script to Views edit screen (admin) |
101 | 101 | * @param mixed $hook |
102 | 102 | */ |
103 | - public function add_scripts_and_styles( $hook ) { |
|
103 | + public function add_scripts_and_styles($hook) { |
|
104 | 104 | global $pagenow; |
105 | 105 | |
106 | 106 | // Don't process any scripts below here if it's not a GravityView page or the widgets screen |
107 | - if ( ! gravityview_is_admin_page( $hook ) && ( 'widgets.php' !== $pagenow ) ) { |
|
107 | + if (!gravityview_is_admin_page($hook) && ('widgets.php' !== $pagenow)) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | 110 | |
111 | - $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
112 | - $script_source = empty( $script_min ) ? '/source' : ''; |
|
111 | + $script_min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
112 | + $script_source = empty($script_min) ? '/source' : ''; |
|
113 | 113 | |
114 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version ); |
|
114 | + wp_enqueue_script('gravityview_searchwidget_admin', plugins_url('assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__), array('jquery', 'gravityview_views_scripts'), GravityView_Plugin::version); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | * @var array |
121 | 121 | */ |
122 | 122 | $input_labels = array( |
123 | - 'input_text' => esc_html__( 'Text', 'gravityview' ), |
|
124 | - 'date' => esc_html__( 'Date', 'gravityview' ), |
|
125 | - 'select' => esc_html__( 'Select', 'gravityview' ), |
|
126 | - 'multiselect' => esc_html__( 'Select (multiple values)', 'gravityview' ), |
|
127 | - 'radio' => esc_html__( 'Radio', 'gravityview' ), |
|
128 | - 'checkbox' => esc_html__( 'Checkbox', 'gravityview' ), |
|
129 | - 'single_checkbox' => esc_html__( 'Checkbox', 'gravityview' ), |
|
130 | - 'link' => esc_html__( 'Links', 'gravityview' ), |
|
131 | - 'date_range' => esc_html__( 'Date range', 'gravityview' ), |
|
123 | + 'input_text' => esc_html__('Text', 'gravityview'), |
|
124 | + 'date' => esc_html__('Date', 'gravityview'), |
|
125 | + 'select' => esc_html__('Select', 'gravityview'), |
|
126 | + 'multiselect' => esc_html__('Select (multiple values)', 'gravityview'), |
|
127 | + 'radio' => esc_html__('Radio', 'gravityview'), |
|
128 | + 'checkbox' => esc_html__('Checkbox', 'gravityview'), |
|
129 | + 'single_checkbox' => esc_html__('Checkbox', 'gravityview'), |
|
130 | + 'link' => esc_html__('Links', 'gravityview'), |
|
131 | + 'date_range' => esc_html__('Date range', 'gravityview'), |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | /** |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | * @var array |
138 | 138 | */ |
139 | 139 | $input_types = array( |
140 | - 'text' => array( 'input_text' ), |
|
141 | - 'address' => array( 'input_text' ), |
|
142 | - 'date' => array( 'date', 'date_range' ), |
|
143 | - 'boolean' => array( 'single_checkbox' ), |
|
144 | - 'select' => array( 'select', 'radio', 'link' ), |
|
145 | - 'multi' => array( 'select', 'multiselect', 'radio', 'checkbox', 'link' ), |
|
140 | + 'text' => array('input_text'), |
|
141 | + 'address' => array('input_text'), |
|
142 | + 'date' => array('date', 'date_range'), |
|
143 | + 'boolean' => array('single_checkbox'), |
|
144 | + 'select' => array('select', 'radio', 'link'), |
|
145 | + 'multi' => array('select', 'multiselect', 'radio', 'checkbox', 'link'), |
|
146 | 146 | ); |
147 | 147 | |
148 | - wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
|
149 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
|
150 | - 'label_nofields' => esc_html__( 'No search fields configured yet.', 'gravityview' ), |
|
151 | - 'label_addfield' => esc_html__( 'Add Search Field', 'gravityview' ), |
|
152 | - 'label_label' => esc_html__( 'Label', 'gravityview' ), |
|
153 | - 'label_searchfield' => esc_html__( 'Search Field', 'gravityview' ), |
|
154 | - 'label_inputtype' => esc_html__( 'Input Type', 'gravityview' ), |
|
155 | - 'label_ajaxerror' => esc_html__( 'There was an error loading searchable fields. Save the View or refresh the page to fix this issue.', 'gravityview' ), |
|
156 | - 'input_labels' => json_encode( $input_labels ), |
|
157 | - 'input_types' => json_encode( $input_types ), |
|
158 | - ) ); |
|
148 | + wp_localize_script('gravityview_searchwidget_admin', 'gvSearchVar', array( |
|
149 | + 'nonce' => wp_create_nonce('gravityview_ajaxsearchwidget'), |
|
150 | + 'label_nofields' => esc_html__('No search fields configured yet.', 'gravityview'), |
|
151 | + 'label_addfield' => esc_html__('Add Search Field', 'gravityview'), |
|
152 | + 'label_label' => esc_html__('Label', 'gravityview'), |
|
153 | + 'label_searchfield' => esc_html__('Search Field', 'gravityview'), |
|
154 | + 'label_inputtype' => esc_html__('Input Type', 'gravityview'), |
|
155 | + 'label_ajaxerror' => esc_html__('There was an error loading searchable fields. Save the View or refresh the page to fix this issue.', 'gravityview'), |
|
156 | + 'input_labels' => json_encode($input_labels), |
|
157 | + 'input_types' => json_encode($input_types), |
|
158 | + )); |
|
159 | 159 | |
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * Add admin script to the whitelist |
164 | 164 | */ |
165 | - public function register_no_conflict( $required ) { |
|
165 | + public function register_no_conflict($required) { |
|
166 | 166 | $required[] = 'gravityview_searchwidget_admin'; |
167 | 167 | return $required; |
168 | 168 | } |
@@ -176,31 +176,31 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public static function get_searchable_fields() { |
178 | 178 | |
179 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
180 | - exit( '0' ); |
|
179 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxsearchwidget')) { |
|
180 | + exit('0'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $form = ''; |
184 | 184 | |
185 | 185 | // Fetch the form for the current View |
186 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
186 | + if (!empty($_POST['view_id'])) { |
|
187 | 187 | |
188 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
188 | + $form = gravityview_get_form_id($_POST['view_id']); |
|
189 | 189 | |
190 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
190 | + } elseif (!empty($_POST['formid'])) { |
|
191 | 191 | |
192 | - $form = (int) $_POST['formid']; |
|
192 | + $form = (int)$_POST['formid']; |
|
193 | 193 | |
194 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
194 | + } elseif (!empty($_POST['template_id']) && class_exists('GravityView_Ajax')) { |
|
195 | 195 | |
196 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
196 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | |
200 | 200 | // fetch form id assigned to the view |
201 | - $response = self::render_searchable_fields( $form ); |
|
201 | + $response = self::render_searchable_fields($form); |
|
202 | 202 | |
203 | - exit( $response ); |
|
203 | + exit($response); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | * @param string $current (for future use) |
210 | 210 | * @return string |
211 | 211 | */ |
212 | - public static function render_searchable_fields( $form_id = null, $current = '' ) { |
|
212 | + public static function render_searchable_fields($form_id = null, $current = '') { |
|
213 | 213 | |
214 | - if ( is_null( $form_id ) ) { |
|
214 | + if (is_null($form_id)) { |
|
215 | 215 | return ''; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Get fields with sub-inputs and no parent |
219 | - $fields = gravityview_get_form_fields( $form_id, true, true ); |
|
219 | + $fields = gravityview_get_form_fields($form_id, true, true); |
|
220 | 220 | |
221 | 221 | // start building output |
222 | 222 | |
@@ -224,40 +224,40 @@ discard block |
||
224 | 224 | |
225 | 225 | $custom_fields = array( |
226 | 226 | 'search_all' => array( |
227 | - 'text' => esc_html__( 'Search Everything', 'gravityview' ), |
|
227 | + 'text' => esc_html__('Search Everything', 'gravityview'), |
|
228 | 228 | 'type' => 'text', |
229 | 229 | ), |
230 | 230 | 'entry_date' => array( |
231 | - 'text' => esc_html__( 'Entry Date', 'gravityview' ), |
|
231 | + 'text' => esc_html__('Entry Date', 'gravityview'), |
|
232 | 232 | 'type' => 'date', |
233 | 233 | ), |
234 | 234 | 'entry_id' => array( |
235 | - 'text' => esc_html__( 'Entry ID', 'gravityview' ), |
|
235 | + 'text' => esc_html__('Entry ID', 'gravityview'), |
|
236 | 236 | 'type' => 'text', |
237 | 237 | ), |
238 | 238 | 'created_by' => array( |
239 | - 'text' => esc_html__( 'Entry Creator', 'gravityview' ), |
|
239 | + 'text' => esc_html__('Entry Creator', 'gravityview'), |
|
240 | 240 | 'type' => 'select', |
241 | 241 | ) |
242 | 242 | ); |
243 | 243 | |
244 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
245 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
244 | + foreach ($custom_fields as $custom_field_key => $custom_field) { |
|
245 | + $output .= sprintf('<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected($custom_field_key, $current, false), $custom_field['type'], self::get_field_label(array('field' => $custom_field_key)), $custom_field['text']); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( ! empty( $fields ) ) { |
|
248 | + if (!empty($fields)) { |
|
249 | 249 | |
250 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'fileupload', 'post_image', 'post_id' ), null ); |
|
250 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('fileupload', 'post_image', 'post_id'), null); |
|
251 | 251 | |
252 | - foreach ( $fields as $id => $field ) { |
|
252 | + foreach ($fields as $id => $field) { |
|
253 | 253 | |
254 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
254 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | 257 | |
258 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
258 | + $types = self::get_search_input_types($id, $field['type']); |
|
259 | 259 | |
260 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
260 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'data-inputtypes="'.esc_attr($types).'">'.esc_html($field['label']).'</option>'; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -276,21 +276,21 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return string GV field search input type ('multi', 'boolean', 'select', 'date', 'text') |
278 | 278 | */ |
279 | - public static function get_search_input_types( $id = '', $field_type = null ) { |
|
279 | + public static function get_search_input_types($id = '', $field_type = null) { |
|
280 | 280 | |
281 | 281 | // @todo - This needs to be improved - many fields have . including products and addresses |
282 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
282 | + if (false !== strpos((string)$id, '.') && in_array($field_type, array('checkbox')) || in_array($id, array('is_fulfilled'))) { |
|
283 | 283 | // on/off checkbox |
284 | 284 | $input_type = 'boolean'; |
285 | - } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
|
285 | + } elseif (in_array($field_type, array('checkbox', 'post_category', 'multiselect'))) { |
|
286 | 286 | //multiselect |
287 | 287 | $input_type = 'multi'; |
288 | 288 | |
289 | - } elseif ( in_array( $field_type, array( 'select', 'radio' ) ) ) { |
|
289 | + } elseif (in_array($field_type, array('select', 'radio'))) { |
|
290 | 290 | //single select |
291 | 291 | $input_type = 'select'; |
292 | 292 | |
293 | - } elseif ( in_array( $field_type, array( 'date' ) ) || in_array( $id, array( 'payment_date' ) ) ) { |
|
293 | + } elseif (in_array($field_type, array('date')) || in_array($id, array('payment_date'))) { |
|
294 | 294 | // date |
295 | 295 | $input_type = 'date'; |
296 | 296 | } else { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param string $field_type Gravity Forms field type |
305 | 305 | * @since 1.2 |
306 | 306 | */ |
307 | - $input_type = apply_filters( 'gravityview/extension/search/input_type', $input_type, $field_type ); |
|
307 | + $input_type = apply_filters('gravityview/extension/search/input_type', $input_type, $field_type); |
|
308 | 308 | |
309 | 309 | return $input_type; |
310 | 310 | } |
@@ -315,29 +315,29 @@ discard block |
||
315 | 315 | * @since 1.8 |
316 | 316 | * @return array Search fields, modified if not using permalinks |
317 | 317 | */ |
318 | - public function add_no_permalink_fields( $search_fields, $object, $widget_args = array() ) { |
|
318 | + public function add_no_permalink_fields($search_fields, $object, $widget_args = array()) { |
|
319 | 319 | /** @global WP_Rewrite $wp_rewrite */ |
320 | 320 | global $wp_rewrite; |
321 | 321 | |
322 | 322 | // Support default permalink structure |
323 | - if ( false === $wp_rewrite->using_permalinks() ) { |
|
323 | + if (false === $wp_rewrite->using_permalinks()) { |
|
324 | 324 | |
325 | 325 | // By default, use current post. |
326 | 326 | $post_id = 0; |
327 | 327 | |
328 | 328 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
329 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
330 | - $post_id = absint( $widget_args['post_id'] ); |
|
329 | + if (!empty($widget_args['post_id'])) { |
|
330 | + $post_id = absint($widget_args['post_id']); |
|
331 | 331 | } |
332 | 332 | // We're in the WordPress Widget context, and the base View ID should be used |
333 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
334 | - $post_id = absint( $widget_args['view_id'] ); |
|
333 | + else if (!empty($widget_args['view_id'])) { |
|
334 | + $post_id = absint($widget_args['view_id']); |
|
335 | 335 | } |
336 | 336 | |
337 | - $args = gravityview_get_permalink_query_args( $post_id ); |
|
337 | + $args = gravityview_get_permalink_query_args($post_id); |
|
338 | 338 | |
339 | 339 | // Add hidden fields to the search form |
340 | - foreach ( $args as $key => $value ) { |
|
340 | + foreach ($args as $key => $value) { |
|
341 | 341 | $search_fields[] = array( |
342 | 342 | 'name' => $key, |
343 | 343 | 'input' => 'hidden', |
@@ -357,23 +357,23 @@ discard block |
||
357 | 357 | * @param array $search_criteria |
358 | 358 | * @return array |
359 | 359 | */ |
360 | - public function filter_entries( $search_criteria ) { |
|
360 | + public function filter_entries($search_criteria) { |
|
361 | 361 | |
362 | - do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Requested $_GET: ', get_class( $this ) ), $_GET ); |
|
362 | + do_action('gravityview_log_debug', sprintf('%s[filter_entries] Requested $_GET: ', get_class($this)), $_GET); |
|
363 | 363 | |
364 | - if ( empty( $_GET ) || ! is_array( $_GET ) ) { |
|
364 | + if (empty($_GET) || !is_array($_GET)) { |
|
365 | 365 | return $search_criteria; |
366 | 366 | } |
367 | 367 | |
368 | 368 | // add free search |
369 | - if ( ! empty( $_GET['gv_search'] ) ) { |
|
369 | + if (!empty($_GET['gv_search'])) { |
|
370 | 370 | |
371 | 371 | // Search for a piece |
372 | - $words = explode( ' ', stripslashes_deep( urldecode( $_GET['gv_search'] ) ) ); |
|
372 | + $words = explode(' ', stripslashes_deep(urldecode($_GET['gv_search']))); |
|
373 | 373 | |
374 | - $words = array_filter( $words ); |
|
374 | + $words = array_filter($words); |
|
375 | 375 | |
376 | - foreach ( $words as $word ) { |
|
376 | + foreach ($words as $word) { |
|
377 | 377 | $search_criteria['field_filters'][] = array( |
378 | 378 | 'key' => null, // The field ID to search |
379 | 379 | 'value' => $word, // The value to search |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | } |
384 | 384 | |
385 | 385 | //start date & end date |
386 | - $curr_start = esc_attr( rgget( 'gv_start' ) ); |
|
387 | - $curr_end = esc_attr( rgget( 'gv_end' ) ); |
|
386 | + $curr_start = esc_attr(rgget('gv_start')); |
|
387 | + $curr_end = esc_attr(rgget('gv_end')); |
|
388 | 388 | |
389 | 389 | /** |
390 | 390 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -393,51 +393,51 @@ discard block |
||
393 | 393 | * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
394 | 394 | * @param[in] string $context Where the filter is being called from. `search` in this case. |
395 | 395 | */ |
396 | - $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
397 | - $search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
398 | - $search_criteria['end_date'] = ( $adjust_tz && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
396 | + $adjust_tz = apply_filters('gravityview_date_created_adjust_timezone', true, 'search'); |
|
397 | + $search_criteria['start_date'] = ($adjust_tz && !empty($curr_start)) ? get_gmt_from_date($curr_start) : $curr_start; |
|
398 | + $search_criteria['end_date'] = ($adjust_tz && !empty($curr_end)) ? get_gmt_from_date($curr_end) : $curr_end; |
|
399 | 399 | |
400 | 400 | |
401 | 401 | // search for a specific entry ID |
402 | - if ( ! empty( $_GET[ 'gv_id' ] ) ) { |
|
402 | + if (!empty($_GET['gv_id'])) { |
|
403 | 403 | $search_criteria['field_filters'][] = array( |
404 | 404 | 'key' => 'id', |
405 | - 'value' => absint( $_GET[ 'gv_id' ] ), |
|
405 | + 'value' => absint($_GET['gv_id']), |
|
406 | 406 | 'operator' => '=', |
407 | 407 | ); |
408 | 408 | } |
409 | 409 | |
410 | 410 | // search for a specific Created_by ID |
411 | - if ( ! empty( $_GET[ 'gv_by' ] ) ) { |
|
411 | + if (!empty($_GET['gv_by'])) { |
|
412 | 412 | $search_criteria['field_filters'][] = array( |
413 | 413 | 'key' => 'created_by', |
414 | - 'value' => absint( $_GET['gv_by'] ), |
|
414 | + 'value' => absint($_GET['gv_by']), |
|
415 | 415 | 'operator' => '=', |
416 | 416 | ); |
417 | 417 | } |
418 | 418 | |
419 | 419 | |
420 | 420 | // Get search mode passed in URL |
421 | - $mode = in_array( rgget( 'mode' ), array( 'any', 'all' ) ) ? esc_attr( rgget( 'mode' ) ) : 'any'; |
|
421 | + $mode = in_array(rgget('mode'), array('any', 'all')) ? esc_attr(rgget('mode')) : 'any'; |
|
422 | 422 | |
423 | 423 | // get the other search filters |
424 | - foreach ( $_GET as $key => $value ) { |
|
424 | + foreach ($_GET as $key => $value) { |
|
425 | 425 | |
426 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
426 | + if (0 !== strpos($key, 'filter_') || empty($value) || (is_array($value) && count($value) === 1 && empty($value[0]))) { |
|
427 | 427 | continue; |
428 | 428 | } |
429 | 429 | |
430 | 430 | // could return simple filter or multiple filters |
431 | - $filter = $this->prepare_field_filter( $key, $value ); |
|
431 | + $filter = $this->prepare_field_filter($key, $value); |
|
432 | 432 | |
433 | - if ( isset( $filter[0]['value'] ) ) { |
|
434 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
433 | + if (isset($filter[0]['value'])) { |
|
434 | + $search_criteria['field_filters'] = array_merge($search_criteria['field_filters'], $filter); |
|
435 | 435 | |
436 | 436 | // if date range type, set search mode to ALL |
437 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>', '<' ) ) ) { |
|
437 | + if (!empty($filter[0]['operator']) && in_array($filter[0]['operator'], array('>', '<'))) { |
|
438 | 438 | $mode = 'all'; |
439 | 439 | } |
440 | - } elseif( !empty( $filter ) ) { |
|
440 | + } elseif (!empty($filter)) { |
|
441 | 441 | $search_criteria['field_filters'][] = $filter; |
442 | 442 | } |
443 | 443 | } |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | * @since 1.5.1 |
448 | 448 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
449 | 449 | */ |
450 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
450 | + $search_criteria['field_filters']['mode'] = apply_filters('gravityview/search/mode', $mode); |
|
451 | 451 | |
452 | - do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
|
452 | + do_action('gravityview_log_debug', sprintf('%s[filter_entries] Returned Search Criteria: ', get_class($this)), $search_criteria); |
|
453 | 453 | |
454 | 454 | return $search_criteria; |
455 | 455 | } |
@@ -464,16 +464,16 @@ discard block |
||
464 | 464 | * @param string $value $_GET search value |
465 | 465 | * @return array 1 or 2 deph levels |
466 | 466 | */ |
467 | - public function prepare_field_filter( $key, $value ) { |
|
467 | + public function prepare_field_filter($key, $value) { |
|
468 | 468 | |
469 | 469 | $gravityview_view = GravityView_View::getInstance(); |
470 | 470 | |
471 | 471 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
472 | - $field_id = str_replace( '_', '.', str_replace( 'filter_', '', $key ) ); |
|
472 | + $field_id = str_replace('_', '.', str_replace('filter_', '', $key)); |
|
473 | 473 | |
474 | 474 | // get form field array |
475 | 475 | $form = $gravityview_view->getForm(); |
476 | - $form_field = gravityview_get_field( $form, $field_id ); |
|
476 | + $form_field = gravityview_get_field($form, $field_id); |
|
477 | 477 | |
478 | 478 | // default filter array |
479 | 479 | $filter = array( |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | 'value' => $value, |
482 | 482 | ); |
483 | 483 | |
484 | - switch ( $form_field['type'] ) { |
|
484 | + switch ($form_field['type']) { |
|
485 | 485 | |
486 | 486 | case 'select': |
487 | 487 | case 'radio': |
@@ -490,18 +490,18 @@ discard block |
||
490 | 490 | |
491 | 491 | case 'post_category': |
492 | 492 | |
493 | - if ( ! is_array( $value ) ) { |
|
494 | - $value = array( $value ); |
|
493 | + if (!is_array($value)) { |
|
494 | + $value = array($value); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | // Reset filter variable |
498 | 498 | $filter = array(); |
499 | 499 | |
500 | - foreach ( $value as $val ) { |
|
501 | - $cat = get_term( $val, 'category' ); |
|
500 | + foreach ($value as $val) { |
|
501 | + $cat = get_term($val, 'category'); |
|
502 | 502 | $filter[] = array( |
503 | 503 | 'key' => $field_id, |
504 | - 'value' => esc_attr( $cat->name ) . ':' . $val, |
|
504 | + 'value' => esc_attr($cat->name).':'.$val, |
|
505 | 505 | 'operator' => 'is', |
506 | 506 | ); |
507 | 507 | } |
@@ -510,35 +510,35 @@ discard block |
||
510 | 510 | |
511 | 511 | case 'multiselect': |
512 | 512 | |
513 | - if ( ! is_array( $value ) ) { |
|
513 | + if (!is_array($value)) { |
|
514 | 514 | break; |
515 | 515 | } |
516 | 516 | |
517 | 517 | // Reset filter variable |
518 | 518 | $filter = array(); |
519 | 519 | |
520 | - foreach ( $value as $val ) { |
|
521 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
520 | + foreach ($value as $val) { |
|
521 | + $filter[] = array('key' => $field_id, 'value' => $val); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | break; |
525 | 525 | |
526 | 526 | case 'checkbox': |
527 | 527 | // convert checkbox on/off into the correct search filter |
528 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
529 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
530 | - if ( $input['id'] == $field_id ) { |
|
531 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
528 | + if (false !== strpos($field_id, '.') && !empty($form_field['inputs']) && !empty($form_field['choices'])) { |
|
529 | + foreach ($form_field['inputs'] as $k => $input) { |
|
530 | + if ($input['id'] == $field_id) { |
|
531 | + $filter['value'] = $form_field['choices'][$k]['value']; |
|
532 | 532 | $filter['operator'] = 'is'; |
533 | 533 | break; |
534 | 534 | } |
535 | 535 | } |
536 | - } elseif ( is_array( $value ) ) { |
|
536 | + } elseif (is_array($value)) { |
|
537 | 537 | |
538 | 538 | // Reset filter variable |
539 | 539 | $filter = array(); |
540 | 540 | |
541 | - foreach ( $value as $val ) { |
|
541 | + foreach ($value as $val) { |
|
542 | 542 | $filter[] = array( |
543 | 543 | 'key' => $field_id, |
544 | 544 | 'value' => $val, |
@@ -552,13 +552,13 @@ discard block |
||
552 | 552 | case 'name': |
553 | 553 | case 'address': |
554 | 554 | |
555 | - if ( false === strpos( $field_id, '.' ) ) { |
|
555 | + if (false === strpos($field_id, '.')) { |
|
556 | 556 | |
557 | - $words = explode( ' ', $value ); |
|
557 | + $words = explode(' ', $value); |
|
558 | 558 | |
559 | 559 | $filters = array(); |
560 | - foreach ( $words as $word ) { |
|
561 | - if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
|
560 | + foreach ($words as $word) { |
|
561 | + if (!empty($word) && strlen($word) > 1) { |
|
562 | 562 | // Keep the same key for each filter |
563 | 563 | $filter['value'] = $word; |
564 | 564 | // Add a search for the value |
@@ -573,25 +573,25 @@ discard block |
||
573 | 573 | |
574 | 574 | case 'date': |
575 | 575 | |
576 | - if ( is_array( $value ) ) { |
|
576 | + if (is_array($value)) { |
|
577 | 577 | |
578 | 578 | // Reset filter variable |
579 | 579 | $filter = array(); |
580 | 580 | |
581 | - foreach ( $value as $k => $date ) { |
|
582 | - if ( empty( $date ) ) { |
|
581 | + foreach ($value as $k => $date) { |
|
582 | + if (empty($date)) { |
|
583 | 583 | continue; |
584 | 584 | } |
585 | 585 | $operator = 'start' === $k ? '>' : '<'; |
586 | 586 | |
587 | 587 | $filter[] = array( |
588 | 588 | 'key' => $field_id, |
589 | - 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
|
589 | + 'value' => self::get_formatted_date($date, 'Y-m-d'), |
|
590 | 590 | 'operator' => $operator, |
591 | 591 | ); |
592 | 592 | } |
593 | 593 | } else { |
594 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
594 | + $filter['value'] = self::get_formatted_date($value, 'Y-m-d'); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | break; |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @return string Format of the date in the database |
612 | 612 | */ |
613 | - public static function get_date_field_format( GF_Field_Date $field ) { |
|
613 | + public static function get_date_field_format(GF_Field_Date $field) { |
|
614 | 614 | $format = 'm/d/Y'; |
615 | 615 | $datepicker = array( |
616 | 616 | 'mdy' => 'm/d/Y', |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | 'ymd_dot' => 'Y.m.d', |
623 | 623 | ); |
624 | 624 | |
625 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
626 | - $format = $datepicker[ $field->dateFormat ]; |
|
625 | + if (!empty($field->dateFormat) && isset($datepicker[$field->dateFormat])) { |
|
626 | + $format = $datepicker[$field->dateFormat]; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | return $format; |
@@ -636,13 +636,13 @@ discard block |
||
636 | 636 | * @param string $format Wanted formatted date |
637 | 637 | * @return string |
638 | 638 | */ |
639 | - public static function get_formatted_date( $value = '', $format = 'Y-m-d' ) { |
|
640 | - $date = date_create( $value ); |
|
641 | - if ( empty( $date ) ) { |
|
642 | - do_action( 'gravityview_log_debug', sprintf( '%s[get_formatted_date] Date format not valid: ', get_class( self::$instance ) ), $value ); |
|
639 | + public static function get_formatted_date($value = '', $format = 'Y-m-d') { |
|
640 | + $date = date_create($value); |
|
641 | + if (empty($date)) { |
|
642 | + do_action('gravityview_log_debug', sprintf('%s[get_formatted_date] Date format not valid: ', get_class(self::$instance)), $value); |
|
643 | 643 | return ''; |
644 | 644 | } |
645 | - return $date->format( $format ); |
|
645 | + return $date->format($format); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -650,10 +650,10 @@ discard block |
||
650 | 650 | * Include this extension templates path |
651 | 651 | * @param array $file_paths List of template paths ordered |
652 | 652 | */ |
653 | - public function add_template_path( $file_paths ) { |
|
653 | + public function add_template_path($file_paths) { |
|
654 | 654 | |
655 | 655 | // Index 100 is the default GravityView template path. |
656 | - $file_paths[102] = self::$file . 'templates/'; |
|
656 | + $file_paths[102] = self::$file.'templates/'; |
|
657 | 657 | |
658 | 658 | return $file_paths; |
659 | 659 | } |
@@ -665,50 +665,50 @@ discard block |
||
665 | 665 | * @param type $context |
666 | 666 | * @return type |
667 | 667 | */ |
668 | - public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
668 | + public function render_frontend($widget_args, $content = '', $context = '') { |
|
669 | 669 | /** @var GravityView_View $gravityview_view */ |
670 | 670 | $gravityview_view = GravityView_View::getInstance(); |
671 | 671 | |
672 | - if ( empty( $gravityview_view ) ) { |
|
673 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class( $this ) ) ); |
|
672 | + if (empty($gravityview_view)) { |
|
673 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this))); |
|
674 | 674 | return; |
675 | 675 | } |
676 | 676 | |
677 | 677 | // get configured search fields |
678 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
678 | + $search_fields = !empty($widget_args['search_fields']) ? json_decode($widget_args['search_fields'], true) : ''; |
|
679 | 679 | |
680 | - if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
|
681 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
|
680 | + if (empty($search_fields) || !is_array($search_fields)) { |
|
681 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend] No search fields configured for widget:', get_class($this)), $widget_args); |
|
682 | 682 | return; |
683 | 683 | } |
684 | 684 | |
685 | 685 | $has_date = false; |
686 | 686 | |
687 | 687 | // prepare fields |
688 | - foreach ( $search_fields as $k => $field ) { |
|
688 | + foreach ($search_fields as $k => $field) { |
|
689 | 689 | |
690 | 690 | $updated_field = $field; |
691 | 691 | |
692 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
692 | + if (in_array($field['input'], array('date', 'date_range'))) { |
|
693 | 693 | $has_date = true; |
694 | 694 | } |
695 | 695 | |
696 | - $updated_field = $this->get_search_filter_details( $updated_field ); |
|
696 | + $updated_field = $this->get_search_filter_details($updated_field); |
|
697 | 697 | |
698 | - switch ( $field['field'] ) { |
|
698 | + switch ($field['field']) { |
|
699 | 699 | |
700 | 700 | case 'search_all': |
701 | 701 | $updated_field['key'] = 'search_all'; |
702 | 702 | $updated_field['input'] = 'search_all'; |
703 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) ); |
|
703 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_search'))); |
|
704 | 704 | break; |
705 | 705 | |
706 | 706 | case 'entry_date': |
707 | 707 | $updated_field['key'] = 'entry_date'; |
708 | 708 | $updated_field['input'] = 'entry_date'; |
709 | 709 | $updated_field['value'] = array( |
710 | - 'start' => esc_attr( stripslashes_deep( rgget( 'gv_start' ) ) ), |
|
711 | - 'end' => esc_attr( stripslashes_deep( rgget( 'gv_end' ) ) ), |
|
710 | + 'start' => esc_attr(stripslashes_deep(rgget('gv_start'))), |
|
711 | + 'end' => esc_attr(stripslashes_deep(rgget('gv_end'))), |
|
712 | 712 | ); |
713 | 713 | $has_date = true; |
714 | 714 | break; |
@@ -716,21 +716,21 @@ discard block |
||
716 | 716 | case 'entry_id': |
717 | 717 | $updated_field['key'] = 'entry_id'; |
718 | 718 | $updated_field['input'] = 'entry_id'; |
719 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) ); |
|
719 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_id'))); |
|
720 | 720 | break; |
721 | 721 | |
722 | 722 | case 'created_by': |
723 | 723 | $updated_field['key'] = 'created_by'; |
724 | 724 | $updated_field['name'] = 'gv_by'; |
725 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) ); |
|
725 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_by'))); |
|
726 | 726 | $updated_field['choices'] = self::get_created_by_choices(); |
727 | 727 | break; |
728 | 728 | } |
729 | 729 | |
730 | - $search_fields[ $k ] = $updated_field; |
|
730 | + $search_fields[$k] = $updated_field; |
|
731 | 731 | } |
732 | 732 | |
733 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] Calculated Search Fields: ', get_class( $this ) ), $search_fields ); |
|
733 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend] Calculated Search Fields: ', get_class($this)), $search_fields); |
|
734 | 734 | |
735 | 735 | /** |
736 | 736 | * @filter `gravityview_widget_search_filters` Modify what fields are shown. The order of the fields in the $search_filters array controls the order as displayed in the search bar widget. |
@@ -739,25 +739,25 @@ discard block |
||
739 | 739 | * @param array $widget_args Args passed to this method. {@since 1.8} |
740 | 740 | * @var array |
741 | 741 | */ |
742 | - $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
|
742 | + $gravityview_view->search_fields = apply_filters('gravityview_widget_search_filters', $search_fields, $this, $widget_args); |
|
743 | 743 | |
744 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
744 | + $gravityview_view->search_layout = !empty($widget_args['search_layout']) ? $widget_args['search_layout'] : 'horizontal'; |
|
745 | 745 | |
746 | 746 | /** @since 1.14 */ |
747 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
747 | + $gravityview_view->search_mode = !empty($widget_args['search_mode']) ? $widget_args['search_mode'] : 'any'; |
|
748 | 748 | |
749 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
749 | + $custom_class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : ''; |
|
750 | 750 | |
751 | - $gravityview_view->search_class = self::get_search_class( $custom_class ); |
|
751 | + $gravityview_view->search_class = self::get_search_class($custom_class); |
|
752 | 752 | |
753 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
753 | + $gravityview_view->search_clear = !empty($widget_args['search_clear']) ? $widget_args['search_clear'] : false; |
|
754 | 754 | |
755 | - if ( $has_date ) { |
|
755 | + if ($has_date) { |
|
756 | 756 | // enqueue datepicker stuff only if needed! |
757 | 757 | $this->enqueue_datepicker(); |
758 | 758 | } |
759 | 759 | |
760 | - $gravityview_view->render( 'widget', 'search', false ); |
|
760 | + $gravityview_view->render('widget', 'search', false); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
@@ -767,12 +767,12 @@ discard block |
||
767 | 767 | * |
768 | 768 | * @return string Sanitized CSS class for the search form |
769 | 769 | */ |
770 | - public static function get_search_class( $custom_class = '' ) { |
|
770 | + public static function get_search_class($custom_class = '') { |
|
771 | 771 | $gravityview_view = GravityView_View::getInstance(); |
772 | 772 | |
773 | 773 | $search_class = 'gv-search-'.$gravityview_view->search_layout; |
774 | 774 | |
775 | - if ( ! empty( $custom_class ) ) { |
|
775 | + if (!empty($custom_class)) { |
|
776 | 776 | $search_class .= ' '.$custom_class; |
777 | 777 | } |
778 | 778 | |
@@ -781,12 +781,12 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @param string $search_class The CSS class for the search form |
783 | 783 | */ |
784 | - $search_class = apply_filters( 'gravityview_search_class', $search_class ); |
|
784 | + $search_class = apply_filters('gravityview_search_class', $search_class); |
|
785 | 785 | |
786 | 786 | // Is there an active search being performed? Used by fe-views.js |
787 | 787 | $search_class .= GravityView_frontend::getInstance()->isSearch() ? ' gv-is-search' : ''; |
788 | 788 | |
789 | - return gravityview_sanitize_html_class( $search_class ); |
|
789 | + return gravityview_sanitize_html_class($search_class); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | |
@@ -801,9 +801,9 @@ discard block |
||
801 | 801 | |
802 | 802 | $post_id = $gravityview_view->getPostId() ? $gravityview_view->getPostId() : $gravityview_view->getViewId(); |
803 | 803 | |
804 | - $url = add_query_arg( array(), get_permalink( $post_id ) ); |
|
804 | + $url = add_query_arg(array(), get_permalink($post_id)); |
|
805 | 805 | |
806 | - return esc_url( $url ); |
|
806 | + return esc_url($url); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -812,42 +812,42 @@ discard block |
||
812 | 812 | * @param array $form_field Form field data, as fetched by `gravityview_get_field()` |
813 | 813 | * @return string Label for the search form |
814 | 814 | */ |
815 | - private static function get_field_label( $field, $form_field = array() ) { |
|
815 | + private static function get_field_label($field, $form_field = array()) { |
|
816 | 816 | |
817 | - $label = rgget( 'label', $field ); |
|
817 | + $label = rgget('label', $field); |
|
818 | 818 | |
819 | - if( '' === $label ) { |
|
819 | + if ('' === $label) { |
|
820 | 820 | |
821 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
821 | + $label = isset($form_field['label']) ? $form_field['label'] : ''; |
|
822 | 822 | |
823 | - switch( $field['field'] ) { |
|
823 | + switch ($field['field']) { |
|
824 | 824 | case 'search_all': |
825 | - $label = __( 'Search Entries:', 'gravityview' ); |
|
825 | + $label = __('Search Entries:', 'gravityview'); |
|
826 | 826 | break; |
827 | 827 | case 'entry_date': |
828 | - $label = __( 'Filter by date:', 'gravityview' ); |
|
828 | + $label = __('Filter by date:', 'gravityview'); |
|
829 | 829 | break; |
830 | 830 | case 'entry_id': |
831 | - $label = __( 'Entry ID:', 'gravityview' ); |
|
831 | + $label = __('Entry ID:', 'gravityview'); |
|
832 | 832 | break; |
833 | 833 | case 'created_by': |
834 | - $label = __( 'Submitted by:', 'gravityview' ); |
|
834 | + $label = __('Submitted by:', 'gravityview'); |
|
835 | 835 | break; |
836 | 836 | case 'is_fulfilled': |
837 | - $label = __( 'Is Fulfilled', 'gravityview' ); |
|
837 | + $label = __('Is Fulfilled', 'gravityview'); |
|
838 | 838 | break; |
839 | 839 | default: |
840 | 840 | // If this is a field input, not a field |
841 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
841 | + if (strpos($field['field'], '.') > 0 && !empty($form_field['inputs'])) { |
|
842 | 842 | |
843 | 843 | // Get the label for the field in question, which returns an array |
844 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
844 | + $items = wp_list_filter($form_field['inputs'], array('id' => $field['field'])); |
|
845 | 845 | |
846 | 846 | // Get the item with the `label` key |
847 | - $values = wp_list_pluck( $items, 'label' ); |
|
847 | + $values = wp_list_pluck($items, 'label'); |
|
848 | 848 | |
849 | 849 | // There will only one item in the array, but this is easier |
850 | - foreach ( $values as $value ) { |
|
850 | + foreach ($values as $value) { |
|
851 | 851 | $label = $value; |
852 | 852 | break; |
853 | 853 | } |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | * @param[in,out] string $label Existing label text, sanitized. |
861 | 861 | * @param[in] array $form_field Gravity Forms field array, as returned by `GFFormsModel::get_field()` |
862 | 862 | */ |
863 | - $label = apply_filters( 'gravityview_search_field_label', esc_attr( $label ), $form_field ); |
|
863 | + $label = apply_filters('gravityview_search_field_label', esc_attr($label), $form_field); |
|
864 | 864 | |
865 | 865 | return $label; |
866 | 866 | } |
@@ -871,39 +871,39 @@ discard block |
||
871 | 871 | * @param array $field |
872 | 872 | * @return array |
873 | 873 | */ |
874 | - private function get_search_filter_details( $field ) { |
|
874 | + private function get_search_filter_details($field) { |
|
875 | 875 | |
876 | 876 | $gravityview_view = GravityView_View::getInstance(); |
877 | 877 | |
878 | 878 | $form = $gravityview_view->getForm(); |
879 | 879 | |
880 | 880 | // for advanced field ids (eg, first name / last name ) |
881 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
881 | + $name = 'filter_'.str_replace('.', '_', $field['field']); |
|
882 | 882 | |
883 | 883 | // get searched value from $_GET (string or array) |
884 | - $value = rgget( $name ); |
|
884 | + $value = rgget($name); |
|
885 | 885 | |
886 | 886 | // get form field details |
887 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
887 | + $form_field = gravityview_get_field($form, $field['field']); |
|
888 | 888 | |
889 | 889 | $filter = array( |
890 | 890 | 'key' => $field['field'], |
891 | 891 | 'name' => $name, |
892 | - 'label' => self::get_field_label( $field, $form_field ), |
|
892 | + 'label' => self::get_field_label($field, $form_field), |
|
893 | 893 | 'input' => $field['input'], |
894 | 894 | 'value' => $value, |
895 | 895 | 'type' => $form_field['type'], |
896 | 896 | ); |
897 | 897 | |
898 | 898 | // collect choices |
899 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
899 | + if ('post_category' === $form_field['type'] && !empty($form_field['displayAllCategories']) && empty($form_field['choices'])) { |
|
900 | 900 | $filter['choices'] = gravityview_get_terms_choices(); |
901 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
901 | + } elseif (!empty($form_field['choices'])) { |
|
902 | 902 | $filter['choices'] = $form_field['choices']; |
903 | 903 | } |
904 | 904 | |
905 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
906 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
905 | + if ('date_range' === $field['input'] && empty($value)) { |
|
906 | + $filter['value'] = array('start' => '', 'end' => ''); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | return $filter; |
@@ -923,10 +923,10 @@ discard block |
||
923 | 923 | * filter gravityview/get_users/search_widget |
924 | 924 | * @see \GVCommon::get_users |
925 | 925 | */ |
926 | - $users = GVCommon::get_users( 'search_widget', array( 'fields' => array( 'ID', 'display_name' ) ) ); |
|
926 | + $users = GVCommon::get_users('search_widget', array('fields' => array('ID', 'display_name'))); |
|
927 | 927 | |
928 | 928 | $choices = array(); |
929 | - foreach ( $users as $user ) { |
|
929 | + foreach ($users as $user) { |
|
930 | 930 | $choices[] = array( |
931 | 931 | 'value' => $user->ID, |
932 | 932 | 'text' => $user->display_name, |
@@ -944,11 +944,11 @@ discard block |
||
944 | 944 | public static function the_clear_search_button() { |
945 | 945 | $gravityview_view = GravityView_View::getInstance(); |
946 | 946 | |
947 | - if ( $gravityview_view->search_clear ) { |
|
947 | + if ($gravityview_view->search_clear) { |
|
948 | 948 | |
949 | - $url = strtok( add_query_arg( array() ), '?' ); |
|
949 | + $url = strtok(add_query_arg(array()), '?'); |
|
950 | 950 | |
951 | - echo gravityview_get_link( $url, esc_html__( 'Clear', 'gravityview' ), 'class=button gv-search-clear' ); |
|
951 | + echo gravityview_get_link($url, esc_html__('Clear', 'gravityview'), 'class=button gv-search-clear'); |
|
952 | 952 | |
953 | 953 | } |
954 | 954 | } |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * Require the datepicker script for the frontend GV script |
960 | 960 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
961 | 961 | */ |
962 | - public function add_datepicker_js_dependency( $js_dependencies ) { |
|
962 | + public function add_datepicker_js_dependency($js_dependencies) { |
|
963 | 963 | |
964 | 964 | $js_dependencies[] = 'jquery-ui-datepicker'; |
965 | 965 | |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | * |
975 | 975 | * @return array |
976 | 976 | */ |
977 | - public function add_datepicker_localization( $localizations = array(), $view_data = array() ) { |
|
977 | + public function add_datepicker_localization($localizations = array(), $view_data = array()) { |
|
978 | 978 | global $wp_locale; |
979 | 979 | |
980 | 980 | /** |
@@ -984,26 +984,26 @@ discard block |
||
984 | 984 | * @param array $js_localization The data padded to the Javascript file |
985 | 985 | * @param array $view_data View data array with View settings |
986 | 986 | */ |
987 | - $datepicker_settings = apply_filters( 'gravityview_datepicker_settings', array( |
|
987 | + $datepicker_settings = apply_filters('gravityview_datepicker_settings', array( |
|
988 | 988 | 'yearRange' => '-5:+5', |
989 | 989 | 'changeMonth' => true, |
990 | 990 | 'changeYear' => true, |
991 | - 'closeText' => esc_attr_x( 'Close', 'Close calendar', 'gravityview' ), |
|
992 | - 'prevText' => esc_attr_x( 'Prev', 'Previous month in calendar', 'gravityview' ), |
|
993 | - 'nextText' => esc_attr_x( 'Next', 'Next month in calendar', 'gravityview' ), |
|
994 | - 'currentText' => esc_attr_x( 'Today', 'Today in calendar', 'gravityview' ), |
|
995 | - 'weekHeader' => esc_attr_x( 'Week', 'Week in calendar', 'gravityview' ), |
|
996 | - 'monthStatus' => __( 'Show a different month', 'gravityview' ), |
|
997 | - 'monthNames' => array_values( $wp_locale->month ), |
|
998 | - 'monthNamesShort' => array_values( $wp_locale->month_abbrev ), |
|
999 | - 'dayNames' => array_values( $wp_locale->weekday ), |
|
1000 | - 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), |
|
1001 | - 'dayNamesMin' => array_values( $wp_locale->weekday_initial ), |
|
991 | + 'closeText' => esc_attr_x('Close', 'Close calendar', 'gravityview'), |
|
992 | + 'prevText' => esc_attr_x('Prev', 'Previous month in calendar', 'gravityview'), |
|
993 | + 'nextText' => esc_attr_x('Next', 'Next month in calendar', 'gravityview'), |
|
994 | + 'currentText' => esc_attr_x('Today', 'Today in calendar', 'gravityview'), |
|
995 | + 'weekHeader' => esc_attr_x('Week', 'Week in calendar', 'gravityview'), |
|
996 | + 'monthStatus' => __('Show a different month', 'gravityview'), |
|
997 | + 'monthNames' => array_values($wp_locale->month), |
|
998 | + 'monthNamesShort' => array_values($wp_locale->month_abbrev), |
|
999 | + 'dayNames' => array_values($wp_locale->weekday), |
|
1000 | + 'dayNamesShort' => array_values($wp_locale->weekday_abbrev), |
|
1001 | + 'dayNamesMin' => array_values($wp_locale->weekday_initial), |
|
1002 | 1002 | // get the start of week from WP general setting |
1003 | - 'firstDay' => get_option( 'start_of_week' ), |
|
1003 | + 'firstDay' => get_option('start_of_week'), |
|
1004 | 1004 | // is Right to left language? default is false |
1005 | 1005 | 'isRTL' => is_rtl(), |
1006 | - ), $view_data ); |
|
1006 | + ), $view_data); |
|
1007 | 1007 | |
1008 | 1008 | $localizations['datepicker'] = $datepicker_settings; |
1009 | 1009 | |
@@ -1022,13 +1022,13 @@ discard block |
||
1022 | 1022 | public function enqueue_datepicker() { |
1023 | 1023 | $gravityview_view = GravityView_View::getInstance(); |
1024 | 1024 | |
1025 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1025 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1026 | 1026 | |
1027 | - add_filter( 'gravityview_js_dependencies', array( $this, 'add_datepicker_js_dependency' ) ); |
|
1028 | - add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
|
1027 | + add_filter('gravityview_js_dependencies', array($this, 'add_datepicker_js_dependency')); |
|
1028 | + add_filter('gravityview_js_localization', array($this, 'add_datepicker_localization'), 10, 2); |
|
1029 | 1029 | |
1030 | 1030 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1031 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1031 | + wp_enqueue_style('jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css'); |
|
1032 | 1032 | |
1033 | 1033 | /** |
1034 | 1034 | * @filter `gravityview_search_datepicker_class` |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | * - `ymd_dash` (yyyy-mm-dd) |
1044 | 1044 | * - `ymp_dot` (yyyy.mm.dd) |
1045 | 1045 | */ |
1046 | - $datepicker_class = apply_filters( 'gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy' ); |
|
1046 | + $datepicker_class = apply_filters('gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy'); |
|
1047 | 1047 | |
1048 | 1048 | $gravityview_view->datepicker_class = $datepicker_class; |
1049 | 1049 |