@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Display the search Entry ID input box |
|
4 | - * |
|
5 | - * @see class-search-widget.php |
|
6 | - */ |
|
3 | + * Display the search Entry ID input box |
|
4 | + * |
|
5 | + * @see class-search-widget.php |
|
6 | + */ |
|
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Display the search by entry date input boxes |
|
4 | - * |
|
5 | - * @see class-search-widget.php |
|
6 | - */ |
|
3 | + * Display the search by entry date input boxes |
|
4 | + * |
|
5 | + * @see class-search-widget.php |
|
6 | + */ |
|
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $search_field = $gravityview_view->search_field; |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Display the search all input box |
|
4 | - * |
|
5 | - * @see class-search-widget.php |
|
6 | - */ |
|
3 | + * Display the search all input box |
|
4 | + * |
|
5 | + * @see class-search-widget.php |
|
6 | + */ |
|
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Set of common functions to separate main plugin from Gravity Forms API and other cross-plugin methods |
|
4 | - * |
|
5 | - * @package GravityView |
|
6 | - * @license GPL2+ |
|
7 | - * @author Katz Web Services, Inc. |
|
8 | - * @link http://gravityview.co |
|
9 | - * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | - * |
|
11 | - * @since 1.5.2 |
|
12 | - */ |
|
3 | + * Set of common functions to separate main plugin from Gravity Forms API and other cross-plugin methods |
|
4 | + * |
|
5 | + * @package GravityView |
|
6 | + * @license GPL2+ |
|
7 | + * @author Katz Web Services, Inc. |
|
8 | + * @link http://gravityview.co |
|
9 | + * @copyright Copyright 2014, Katz Web Services, Inc. |
|
10 | + * |
|
11 | + * @since 1.5.2 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | |
241 | 241 | if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
242 | 242 | foreach ( $field['inputs'] as $input ) { |
243 | - /** |
|
244 | - * @hack |
|
245 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
246 | - */ |
|
247 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
248 | - continue; |
|
249 | - } |
|
243 | + /** |
|
244 | + * @hack |
|
245 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
246 | + */ |
|
247 | + if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
248 | + continue; |
|
249 | + } |
|
250 | 250 | $fields[ (string)$input['id'] ] = array( |
251 | 251 | 'label' => rgar( $input, 'label' ), |
252 | 252 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
470 | 470 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
471 | 471 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
472 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
472 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
473 | 473 | $criteria['context_view_id'] = null; |
474 | 474 | } |
475 | 475 | |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | ), |
1169 | 1169 | ); |
1170 | 1170 | |
1171 | - $fields = $date_created + $fields; |
|
1171 | + $fields = $date_created + $fields; |
|
1172 | 1172 | |
1173 | 1173 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1174 | 1174 | |
@@ -1180,13 +1180,13 @@ discard block |
||
1180 | 1180 | } |
1181 | 1181 | } |
1182 | 1182 | |
1183 | - /** |
|
1184 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1185 | - * @since 1.12 |
|
1186 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1187 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1188 | - */ |
|
1189 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1183 | + /** |
|
1184 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1185 | + * @since 1.12 |
|
1186 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1187 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1188 | + */ |
|
1189 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1190 | 1190 | |
1191 | 1191 | return $fields; |
1192 | 1192 | } |
@@ -1464,17 +1464,17 @@ discard block |
||
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | |
1467 | - /** |
|
1468 | - * Display updated/error notice |
|
1469 | - * |
|
1470 | - * @param string $notice text/HTML of notice |
|
1471 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1472 | - * |
|
1473 | - * @return string |
|
1474 | - */ |
|
1475 | - public static function generate_notice( $notice, $class = '' ) { |
|
1476 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1477 | - } |
|
1467 | + /** |
|
1468 | + * Display updated/error notice |
|
1469 | + * |
|
1470 | + * @param string $notice text/HTML of notice |
|
1471 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1472 | + * |
|
1473 | + * @return string |
|
1474 | + */ |
|
1475 | + public static function generate_notice( $notice, $class = '' ) { |
|
1476 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1477 | + } |
|
1478 | 1478 | |
1479 | 1479 | |
1480 | 1480 |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 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 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 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 | } |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | if ( class_exists( 'GFAPI' ) ) { |
194 | 194 | $gf_forms = GFAPI::get_forms(); |
195 | 195 | foreach ( $gf_forms as $form ) { |
196 | - $forms[] = array( |
|
197 | - 'id' => $form['id'], |
|
198 | - 'title' => $form['title'], |
|
196 | + $forms[ ] = array( |
|
197 | + 'id' => $form[ 'id' ], |
|
198 | + 'title' => $form[ 'title' ], |
|
199 | 199 | ); |
200 | 200 | } |
201 | 201 | } |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | if ( $form ) { |
230 | - foreach ( $form['fields'] as $field ) { |
|
231 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
232 | - $fields[ $field['id'] ] = array( |
|
230 | + foreach ( $form[ 'fields' ] as $field ) { |
|
231 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
232 | + $fields[ $field[ 'id' ] ] = array( |
|
233 | 233 | 'label' => rgar( $field, 'label' ), |
234 | 234 | 'parent' => null, |
235 | 235 | 'type' => rgar( $field, 'type' ), |
@@ -238,16 +238,16 @@ discard block |
||
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( |
|
250 | + $fields[ (string)$input[ 'id' ] ] = array( |
|
251 | 251 | 'label' => rgar( $input, 'label' ), |
252 | 252 | 'customLabel' => rgar( $input, 'customLabel' ), |
253 | 253 | 'parent' => $field, |
@@ -259,11 +259,11 @@ discard block |
||
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 | 268 | $fields[ $input_id ] = array( |
269 | 269 | 'label' => rgar( $input, 'text' ), |
@@ -279,25 +279,25 @@ 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 | 302 | if ( GFCommon::is_post_field( $field_for_is_post_field ) ) { |
303 | 303 | $has_post_fields = true; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @since 1.7 |
310 | 310 | */ |
311 | 311 | if ( $has_post_fields ) { |
312 | - $fields['post_id'] = array( |
|
312 | + $fields[ 'post_id' ] = array( |
|
313 | 313 | 'label' => __( 'Post ID', 'gravityview' ), |
314 | 314 | 'type' => 'post_id', |
315 | 315 | ); |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
321 | 321 | |
322 | 322 | foreach ( $payment_fields as $payment_field ) { |
323 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
323 | + if ( isset( $fields[ "{$payment_field->name}" ] ) ) { |
|
324 | 324 | continue; |
325 | 325 | } |
326 | - $fields["{$payment_field->name}"] = array( |
|
326 | + $fields[ "{$payment_field->name}" ] = array( |
|
327 | 327 | 'label' => $payment_field->label, |
328 | 328 | 'desc' => $payment_field->description, |
329 | 329 | 'type' => $payment_field->name, |
@@ -334,24 +334,24 @@ discard block |
||
334 | 334 | /** |
335 | 335 | * @since 1.8 |
336 | 336 | */ |
337 | - if( $has_quiz_fields ) { |
|
337 | + if ( $has_quiz_fields ) { |
|
338 | 338 | |
339 | - $fields['gquiz_score'] = array( |
|
339 | + $fields[ 'gquiz_score' ] = array( |
|
340 | 340 | 'label' => __( 'Quiz Score Total', 'gravityview' ), |
341 | 341 | 'type' => 'quiz_score', |
342 | 342 | 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
343 | 343 | ); |
344 | - $fields['gquiz_percent'] = array( |
|
344 | + $fields[ 'gquiz_percent' ] = array( |
|
345 | 345 | 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
346 | 346 | 'type' => 'quiz_percent', |
347 | 347 | 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
348 | 348 | ); |
349 | - $fields['gquiz_grade'] = array( |
|
349 | + $fields[ 'gquiz_grade' ] = array( |
|
350 | 350 | 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
351 | 351 | 'type' => 'quiz_grade', |
352 | 352 | 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
353 | 353 | ); |
354 | - $fields['gquiz_is_pass'] = array( |
|
354 | + $fields[ 'gquiz_is_pass' ] = array( |
|
355 | 355 | 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
356 | 356 | 'type' => 'quiz_is_pass', |
357 | 357 | 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | |
374 | 374 | $fields = array(); |
375 | 375 | |
376 | - foreach ( $extra_fields as $key => $field ){ |
|
377 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
378 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
376 | + foreach ( $extra_fields as $key => $field ) { |
|
377 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
378 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
@@ -415,32 +415,32 @@ discard block |
||
415 | 415 | 'search_criteria' => null, |
416 | 416 | 'sorting' => null, |
417 | 417 | 'paging' => null, |
418 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
418 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ), |
|
419 | 419 | ); |
420 | 420 | |
421 | 421 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
422 | 422 | |
423 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
424 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
423 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
424 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
425 | 425 | |
426 | 426 | if ( ! is_array( $filter ) ) { |
427 | 427 | continue; |
428 | 428 | } |
429 | 429 | |
430 | 430 | // By default, we want searches to be wildcard for each field. |
431 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
431 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
432 | 432 | |
433 | 433 | /** |
434 | 434 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
435 | 435 | * @param string $operator Existing search operator |
436 | 436 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
437 | 437 | */ |
438 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
438 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | // don't send just the [mode] without any field filter. |
442 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
443 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
442 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
443 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | } |
@@ -451,21 +451,21 @@ discard block |
||
451 | 451 | * Prepare date formats to be in Gravity Forms DB format; |
452 | 452 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
453 | 453 | */ |
454 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
454 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
455 | 455 | |
456 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
456 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
457 | 457 | |
458 | 458 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
459 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
459 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
460 | 460 | |
461 | 461 | if ( $date ) { |
462 | 462 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
463 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
463 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
464 | 464 | } else { |
465 | 465 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
466 | - unset( $criteria['search_criteria'][ $key ] ); |
|
466 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
467 | 467 | |
468 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
468 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
469 | 469 | } |
470 | 470 | } |
471 | 471 | } |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | |
474 | 474 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
475 | 475 | if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
476 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
476 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
477 | 477 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
478 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
|
479 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
478 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? $_GET[ 'view_id' ] : null; |
|
479 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
480 | 480 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
481 | - $criteria['context_view_id'] = null; |
|
481 | + $criteria[ 'context_view_id' ] = null; |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @param array $form_ids Forms to search |
488 | 488 | * @param int $view_id ID of the view being used to search |
489 | 489 | */ |
490 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
490 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
491 | 491 | |
492 | 492 | return (array)$criteria; |
493 | 493 | |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | /** Reduce # of database calls */ |
519 | 519 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
520 | 520 | |
521 | - if ( ! empty( $criteria['cache'] ) ) { |
|
521 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
522 | 522 | |
523 | 523 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
524 | 524 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | |
527 | 527 | // Still update the total count when using cached results |
528 | 528 | if ( ! is_null( $total ) ) { |
529 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
529 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | $return = $entries; |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
547 | 547 | |
548 | 548 | // No entries returned from gravityview_before_get_entries |
549 | - if( is_null( $entries ) ) { |
|
549 | + if ( is_null( $entries ) ) { |
|
550 | 550 | |
551 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
551 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
552 | 552 | |
553 | 553 | if ( is_wp_error( $entries ) ) { |
554 | 554 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
560 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
560 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
561 | 561 | |
562 | 562 | // Cache results |
563 | 563 | $Cache->set( $entries, 'entries' ); |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | */ |
645 | 645 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
646 | 646 | |
647 | - if( $check_entry_display ) { |
|
647 | + if ( $check_entry_display ) { |
|
648 | 648 | // Is the entry allowed |
649 | 649 | $entry = self::check_entry_display( $entry ); |
650 | 650 | } |
@@ -677,12 +677,12 @@ discard block |
||
677 | 677 | |
678 | 678 | $value = false; |
679 | 679 | |
680 | - if( 'context' === $val1 ) { |
|
680 | + if ( 'context' === $val1 ) { |
|
681 | 681 | |
682 | 682 | $matching_contexts = array( $val2 ); |
683 | 683 | |
684 | 684 | // We allow for non-standard contexts. |
685 | - switch( $val2 ) { |
|
685 | + switch ( $val2 ) { |
|
686 | 686 | // Check for either single or edit |
687 | 687 | case 'singular': |
688 | 688 | $matching_contexts = array( 'single', 'edit' ); |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | return false; |
743 | 743 | } |
744 | 744 | |
745 | - if ( empty( $entry['form_id'] ) ) { |
|
745 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
746 | 746 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
747 | 747 | return false; |
748 | 748 | } |
@@ -750,26 +750,26 @@ discard block |
||
750 | 750 | $criteria = self::calculate_get_entries_criteria(); |
751 | 751 | |
752 | 752 | // Make sure the current View is connected to the same form as the Entry |
753 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
754 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
753 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
754 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
755 | 755 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
756 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
757 | - 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'] ); |
|
756 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
757 | + 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' ] ); |
|
758 | 758 | return false; |
759 | 759 | } |
760 | 760 | } |
761 | 761 | |
762 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
762 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
763 | 763 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
764 | 764 | return $entry; |
765 | 765 | } |
766 | 766 | |
767 | - $search_criteria = $criteria['search_criteria']; |
|
767 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
768 | 768 | unset( $criteria ); |
769 | 769 | |
770 | 770 | // check entry status |
771 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
772 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
771 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
772 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
773 | 773 | return false; |
774 | 774 | } |
775 | 775 | |
@@ -777,37 +777,37 @@ discard block |
||
777 | 777 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
778 | 778 | |
779 | 779 | // field_filters |
780 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
780 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
781 | 781 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
782 | 782 | return $entry; |
783 | 783 | } |
784 | 784 | |
785 | - $filters = $search_criteria['field_filters']; |
|
785 | + $filters = $search_criteria[ 'field_filters' ]; |
|
786 | 786 | unset( $search_criteria ); |
787 | 787 | |
788 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
789 | - unset( $filters['mode'] ); |
|
788 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
789 | + unset( $filters[ 'mode' ] ); |
|
790 | 790 | |
791 | - $form = self::get_form( $entry['form_id'] ); |
|
791 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
792 | 792 | |
793 | 793 | foreach ( $filters as $filter ) { |
794 | 794 | |
795 | - if ( ! isset( $filter['key'] ) ) { |
|
795 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
796 | 796 | continue; |
797 | 797 | } |
798 | 798 | |
799 | - $k = $filter['key']; |
|
799 | + $k = $filter[ 'key' ]; |
|
800 | 800 | |
801 | 801 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
802 | 802 | $field_value = $entry[ $k ]; |
803 | 803 | $field = null; |
804 | 804 | } else { |
805 | 805 | $field = self::get_field( $form, $k ); |
806 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
806 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
807 | 807 | } |
808 | 808 | |
809 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
810 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
809 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
810 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
811 | 811 | |
812 | 812 | // verify if we are already free to go! |
813 | 813 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -865,25 +865,25 @@ discard block |
||
865 | 865 | * Gravity Forms code to adjust date to locally-configured Time Zone |
866 | 866 | * @see GFCommon::format_date() for original code |
867 | 867 | */ |
868 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
868 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
869 | 869 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
870 | 870 | |
871 | - $format = rgar( $atts, 'format' ); |
|
872 | - $is_human = ! empty( $atts['human'] ); |
|
873 | - $is_diff = ! empty( $atts['diff'] ); |
|
874 | - $is_raw = ! empty( $atts['raw'] ); |
|
875 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
876 | - $include_time = ! empty( $atts['time'] ); |
|
871 | + $format = rgar( $atts, 'format' ); |
|
872 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
873 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
874 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
875 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
876 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
877 | 877 | |
878 | 878 | // If we're using time diff, we want to have a different default format |
879 | - if( empty( $format ) ) { |
|
879 | + if ( empty( $format ) ) { |
|
880 | 880 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
881 | 881 | } |
882 | 882 | |
883 | 883 | // If raw was specified, don't modify the stored value |
884 | 884 | if ( $is_raw ) { |
885 | 885 | $formatted_date = $date_string; |
886 | - } elseif( $is_timestamp ) { |
|
886 | + } elseif ( $is_timestamp ) { |
|
887 | 887 | $formatted_date = $date_local_timestamp; |
888 | 888 | } elseif ( $is_diff ) { |
889 | 889 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | } |
912 | 912 | |
913 | 913 | $field = self::get_field( $form, $field_id ); |
914 | - return isset( $field['label'] ) ? $field['label'] : ''; |
|
914 | + return isset( $field[ 'label' ] ) ? $field[ 'label' ] : ''; |
|
915 | 915 | |
916 | 916 | } |
917 | 917 | |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist |
930 | 930 | */ |
931 | 931 | public static function get_field( $form, $field_id ) { |
932 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
932 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
933 | 933 | return GFFormsModel::get_field( $form, $field_id ); |
934 | 934 | } else { |
935 | 935 | return null; |
@@ -976,17 +976,17 @@ discard block |
||
976 | 976 | $shortcodes = array(); |
977 | 977 | |
978 | 978 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
979 | - if ( empty( $matches ) ){ |
|
979 | + if ( empty( $matches ) ) { |
|
980 | 980 | return false; |
981 | 981 | } |
982 | 982 | |
983 | 983 | foreach ( $matches as $shortcode ) { |
984 | - if ( $tag === $shortcode[2] ) { |
|
984 | + if ( $tag === $shortcode[ 2 ] ) { |
|
985 | 985 | |
986 | 986 | // Changed this to $shortcode instead of true so we get the parsed atts. |
987 | - $shortcodes[] = $shortcode; |
|
987 | + $shortcodes[ ] = $shortcode; |
|
988 | 988 | |
989 | - } else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
989 | + } else if ( isset( $shortcode[ 5 ] ) && $result = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
990 | 990 | $shortcodes = $result; |
991 | 991 | } |
992 | 992 | } |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | * @return string html |
1138 | 1138 | */ |
1139 | 1139 | public static function get_sortable_fields( $formid, $current = '' ) { |
1140 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1140 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1141 | 1141 | |
1142 | 1142 | if ( empty( $formid ) ) { |
1143 | 1143 | return $output; |
@@ -1150,11 +1150,11 @@ discard block |
||
1150 | 1150 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1151 | 1151 | |
1152 | 1152 | foreach ( $fields as $id => $field ) { |
1153 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1153 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1154 | 1154 | continue; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1157 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1158 | 1158 | } |
1159 | 1159 | } |
1160 | 1160 | |
@@ -1189,9 +1189,9 @@ discard block |
||
1189 | 1189 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1190 | 1190 | |
1191 | 1191 | // TODO: Convert to using array_filter |
1192 | - foreach( $fields as $id => $field ) { |
|
1192 | + foreach ( $fields as $id => $field ) { |
|
1193 | 1193 | |
1194 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1194 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1195 | 1195 | unset( $fields[ $id ] ); |
1196 | 1196 | } |
1197 | 1197 | } |
@@ -1232,14 +1232,14 @@ discard block |
||
1232 | 1232 | * @param int|array $field field key or field array |
1233 | 1233 | * @return boolean |
1234 | 1234 | */ |
1235 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1235 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1236 | 1236 | |
1237 | 1237 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1238 | 1238 | $form = self::get_form( $form ); |
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | // If entry meta, it's a string. Otherwise, numeric |
1242 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1242 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1243 | 1243 | $type = $field; |
1244 | 1244 | } else { |
1245 | 1245 | $type = self::get_field_type( $form, $field ); |
@@ -1253,9 +1253,9 @@ discard block |
||
1253 | 1253 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1254 | 1254 | |
1255 | 1255 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1256 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1257 | - if( true === $gv_field->is_numeric ) { |
|
1258 | - $numeric_types[] = $gv_field->is_numeric; |
|
1256 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1257 | + if ( true === $gv_field->is_numeric ) { |
|
1258 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | |
@@ -1405,11 +1405,11 @@ discard block |
||
1405 | 1405 | $final_atts = array_filter( $final_atts ); |
1406 | 1406 | |
1407 | 1407 | // If the href wasn't passed as an attribute, use the value passed to the function |
1408 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1409 | - $final_atts['href'] = $href; |
|
1408 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1409 | + $final_atts[ 'href' ] = $href; |
|
1410 | 1410 | } |
1411 | 1411 | |
1412 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1412 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1413 | 1413 | |
1414 | 1414 | // Sort the attributes alphabetically, to help testing |
1415 | 1415 | ksort( $final_atts ); |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1421 | 1421 | } |
1422 | 1422 | |
1423 | - if( '' !== $output ) { |
|
1423 | + if ( '' !== $output ) { |
|
1424 | 1424 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1425 | 1425 | } |
1426 | 1426 | |
@@ -1444,7 +1444,7 @@ discard block |
||
1444 | 1444 | public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
1445 | 1445 | $merged = $array1; |
1446 | 1446 | |
1447 | - foreach ( $array2 as $key => &$value ) { |
|
1447 | + foreach ( $array2 as $key => &$value ) { |
|
1448 | 1448 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1449 | 1449 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1450 | 1450 | } else { |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1480 | 1480 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1481 | 1481 | */ |
1482 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1482 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1483 | 1483 | |
1484 | 1484 | return get_users( $get_users_settings ); |
1485 | 1485 | } |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | * @return string |
1495 | 1495 | */ |
1496 | 1496 | public static function generate_notice( $notice, $class = '' ) { |
1497 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1497 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1498 | 1498 | } |
1499 | 1499 | |
1500 | 1500 |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * Add admin script to the no-conflict scripts whitelist |
165 | 165 | * @param array $allowed Scripts allowed in no-conflict mode |
166 | - * @return array Scripts allowed in no-conflict mode, plus the search widget script |
|
166 | + * @return string[] Scripts allowed in no-conflict mode, plus the search widget script |
|
167 | 167 | */ |
168 | 168 | public function register_no_conflict( $allowed ) { |
169 | 169 | $allowed[] = 'gravityview_searchwidget_admin'; |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | /** |
978 | 978 | * Require the datepicker script for the frontend GV script |
979 | 979 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
980 | - * @return array Array required scripts, with `jquery-ui-datepicker` added |
|
980 | + * @return string[] Array required scripts, with `jquery-ui-datepicker` added |
|
981 | 981 | */ |
982 | 982 | public function add_datepicker_js_dependency( $js_dependencies ) { |
983 | 983 | |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | /** |
990 | 990 | * Modify the array passed to wp_localize_script() |
991 | 991 | * |
992 | - * @param array $js_localization The data padded to the Javascript file |
|
992 | + * @param array $localizations The data padded to the Javascript file |
|
993 | 993 | * @param array $view_data View data array with View settings |
994 | 994 | * |
995 | 995 | * @return array |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'type' => 'radio', |
57 | 57 | 'full_width' => true, |
58 | 58 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
59 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
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( |
@@ -78,7 +78,7 @@ discard block |
||
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 | 80 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
81 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
81 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
82 | 82 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
83 | 83 | |
84 | 84 | // ajax - get the searchable fields |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
113 | 113 | $script_source = empty( $script_min ) ? '/source' : ''; |
114 | 114 | |
115 | - 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 | + 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 ); |
|
116 | 116 | |
117 | 117 | |
118 | 118 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
167 | 167 | */ |
168 | 168 | public function register_no_conflict( $allowed ) { |
169 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
169 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
170 | 170 | return $allowed; |
171 | 171 | } |
172 | 172 | |
@@ -179,24 +179,24 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function get_searchable_fields() { |
181 | 181 | |
182 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
182 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
183 | 183 | exit( '0' ); |
184 | 184 | } |
185 | 185 | |
186 | 186 | $form = ''; |
187 | 187 | |
188 | 188 | // Fetch the form for the current View |
189 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
189 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
190 | 190 | |
191 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
191 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
192 | 192 | |
193 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
193 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
194 | 194 | |
195 | - $form = (int) $_POST['formid']; |
|
195 | + $form = (int)$_POST[ 'formid' ]; |
|
196 | 196 | |
197 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
197 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
198 | 198 | |
199 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
199 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
200 | 200 | |
201 | 201 | } |
202 | 202 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | ) |
245 | 245 | ); |
246 | 246 | |
247 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
248 | - $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'] ); |
|
247 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
248 | + $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' ] ); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | if ( ! empty( $fields ) ) { |
@@ -254,13 +254,13 @@ discard block |
||
254 | 254 | |
255 | 255 | foreach ( $fields as $id => $field ) { |
256 | 256 | |
257 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
257 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | |
261 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
261 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
262 | 262 | |
263 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
263 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | public static function get_search_input_types( $id = '', $field_type = null ) { |
283 | 283 | |
284 | 284 | // @todo - This needs to be improved - many fields have . including products and addresses |
285 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
285 | + if ( false !== strpos( (string)$id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
286 | 286 | $input_type = 'boolean'; // on/off checkbox |
287 | 287 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
288 | 288 | $input_type = 'multi'; //multiselect |
@@ -324,19 +324,19 @@ discard block |
||
324 | 324 | $post_id = 0; |
325 | 325 | |
326 | 326 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
327 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
328 | - $post_id = absint( $widget_args['post_id'] ); |
|
327 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
328 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
329 | 329 | } |
330 | 330 | // We're in the WordPress Widget context, and the base View ID should be used |
331 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
332 | - $post_id = absint( $widget_args['view_id'] ); |
|
331 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
332 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | $args = gravityview_get_permalink_query_args( $post_id ); |
336 | 336 | |
337 | 337 | // Add hidden fields to the search form |
338 | 338 | foreach ( $args as $key => $value ) { |
339 | - $search_fields[] = array( |
|
339 | + $search_fields[ ] = array( |
|
340 | 340 | 'name' => $key, |
341 | 341 | 'input' => 'hidden', |
342 | 342 | 'value' => $value, |
@@ -368,15 +368,15 @@ discard block |
||
368 | 368 | $get = array_map( 'urldecode', $get ); |
369 | 369 | |
370 | 370 | // add free search |
371 | - if ( ! empty( $get['gv_search'] ) ) { |
|
371 | + if ( ! empty( $get[ 'gv_search' ] ) ) { |
|
372 | 372 | |
373 | 373 | // Search for a piece |
374 | - $words = explode( ' ', $get['gv_search'] ); |
|
374 | + $words = explode( ' ', $get[ 'gv_search' ] ); |
|
375 | 375 | |
376 | 376 | $words = array_filter( $words ); |
377 | 377 | |
378 | 378 | foreach ( $words as $word ) { |
379 | - $search_criteria['field_filters'][] = array( |
|
379 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
380 | 380 | 'key' => null, // The field ID to search |
381 | 381 | 'value' => $word, // The value to search |
382 | 382 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -401,16 +401,16 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) |
403 | 403 | */ |
404 | - if( !empty( $curr_start ) ) { |
|
405 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
404 | + if ( ! empty( $curr_start ) ) { |
|
405 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
406 | 406 | } |
407 | - if( !empty( $curr_end ) ) { |
|
408 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
407 | + if ( ! empty( $curr_end ) ) { |
|
408 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | // search for a specific entry ID |
412 | 412 | if ( ! empty( $get[ 'gv_id' ] ) ) { |
413 | - $search_criteria['field_filters'][] = array( |
|
413 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
414 | 414 | 'key' => 'id', |
415 | 415 | 'value' => absint( $get[ 'gv_id' ] ), |
416 | 416 | 'operator' => '=', |
@@ -419,9 +419,9 @@ discard block |
||
419 | 419 | |
420 | 420 | // search for a specific Created_by ID |
421 | 421 | if ( ! empty( $get[ 'gv_by' ] ) ) { |
422 | - $search_criteria['field_filters'][] = array( |
|
422 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
423 | 423 | 'key' => 'created_by', |
424 | - 'value' => absint( $get['gv_by'] ), |
|
424 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
425 | 425 | 'operator' => '=', |
426 | 426 | ); |
427 | 427 | } |
@@ -433,22 +433,22 @@ discard block |
||
433 | 433 | // get the other search filters |
434 | 434 | foreach ( $get as $key => $value ) { |
435 | 435 | |
436 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
436 | + if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[ 0 ] ) ) ) { |
|
437 | 437 | continue; |
438 | 438 | } |
439 | 439 | |
440 | 440 | // could return simple filter or multiple filters |
441 | 441 | $filter = $this->prepare_field_filter( $key, $value ); |
442 | 442 | |
443 | - if ( isset( $filter[0]['value'] ) ) { |
|
444 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
443 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
444 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
445 | 445 | |
446 | 446 | // if date range type, set search mode to ALL |
447 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>', '<' ) ) ) { |
|
447 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>', '<' ) ) ) { |
|
448 | 448 | $mode = 'all'; |
449 | 449 | } |
450 | - } elseif( !empty( $filter ) ) { |
|
451 | - $search_criteria['field_filters'][] = $filter; |
|
450 | + } elseif ( ! empty( $filter ) ) { |
|
451 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @since 1.5.1 |
458 | 458 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
459 | 459 | */ |
460 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
460 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
461 | 461 | |
462 | 462 | do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
463 | 463 | |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | 'value' => _wp_specialchars( $value ), // Gravity Forms encodes ampersands but not quotes |
494 | 494 | ); |
495 | 495 | |
496 | - switch ( $form_field['type'] ) { |
|
496 | + switch ( $form_field[ 'type' ] ) { |
|
497 | 497 | |
498 | 498 | case 'select': |
499 | 499 | case 'radio': |
500 | - $filter['operator'] = 'is'; |
|
500 | + $filter[ 'operator' ] = 'is'; |
|
501 | 501 | break; |
502 | 502 | |
503 | 503 | case 'post_category': |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | |
512 | 512 | foreach ( $value as $val ) { |
513 | 513 | $cat = get_term( $val, 'category' ); |
514 | - $filter[] = array( |
|
514 | + $filter[ ] = array( |
|
515 | 515 | 'key' => $field_id, |
516 | 516 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
517 | 517 | 'operator' => 'is', |
@@ -530,18 +530,18 @@ discard block |
||
530 | 530 | $filter = array(); |
531 | 531 | |
532 | 532 | foreach ( $value as $val ) { |
533 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
533 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | break; |
537 | 537 | |
538 | 538 | case 'checkbox': |
539 | 539 | // convert checkbox on/off into the correct search filter |
540 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
541 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
542 | - if ( $input['id'] == $field_id ) { |
|
543 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
544 | - $filter['operator'] = 'is'; |
|
540 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
541 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
542 | + if ( $input[ 'id' ] == $field_id ) { |
|
543 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
544 | + $filter[ 'operator' ] = 'is'; |
|
545 | 545 | break; |
546 | 546 | } |
547 | 547 | } |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | $filter = array(); |
552 | 552 | |
553 | 553 | foreach ( $value as $val ) { |
554 | - $filter[] = array( |
|
554 | + $filter[ ] = array( |
|
555 | 555 | 'key' => $field_id, |
556 | 556 | 'value' => $val, |
557 | 557 | 'operator' => 'is', |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | foreach ( $words as $word ) { |
573 | 573 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
574 | 574 | // Keep the same key for each filter |
575 | - $filter['value'] = $word; |
|
575 | + $filter[ 'value' ] = $word; |
|
576 | 576 | // Add a search for the value |
577 | - $filters[] = $filter; |
|
577 | + $filters[ ] = $filter; |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
@@ -596,14 +596,14 @@ discard block |
||
596 | 596 | } |
597 | 597 | $operator = 'start' === $k ? '>' : '<'; |
598 | 598 | |
599 | - $filter[] = array( |
|
599 | + $filter[ ] = array( |
|
600 | 600 | 'key' => $field_id, |
601 | 601 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
602 | 602 | 'operator' => $operator, |
603 | 603 | ); |
604 | 604 | } |
605 | 605 | } else { |
606 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
606 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | break; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | 'ymd_dot' => 'Y.m.d', |
635 | 635 | ); |
636 | 636 | |
637 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
637 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
638 | 638 | $format = $datepicker[ $field->dateFormat ]; |
639 | 639 | } |
640 | 640 | |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | public function add_template_path( $file_paths ) { |
666 | 666 | |
667 | 667 | // Index 100 is the default GravityView template path. |
668 | - $file_paths[102] = self::$file . 'templates/'; |
|
668 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
669 | 669 | |
670 | 670 | return $file_paths; |
671 | 671 | } |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | } |
689 | 689 | |
690 | 690 | // get configured search fields |
691 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
691 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
692 | 692 | |
693 | 693 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
694 | 694 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -702,24 +702,24 @@ discard block |
||
702 | 702 | |
703 | 703 | $updated_field = $field; |
704 | 704 | |
705 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
705 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range' ) ) ) { |
|
706 | 706 | $has_date = true; |
707 | 707 | } |
708 | 708 | |
709 | 709 | $updated_field = $this->get_search_filter_details( $updated_field ); |
710 | 710 | |
711 | - switch ( $field['field'] ) { |
|
711 | + switch ( $field[ 'field' ] ) { |
|
712 | 712 | |
713 | 713 | case 'search_all': |
714 | - $updated_field['key'] = 'search_all'; |
|
715 | - $updated_field['input'] = 'search_all'; |
|
716 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) ); |
|
714 | + $updated_field[ 'key' ] = 'search_all'; |
|
715 | + $updated_field[ 'input' ] = 'search_all'; |
|
716 | + $updated_field[ 'value' ] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) ); |
|
717 | 717 | break; |
718 | 718 | |
719 | 719 | case 'entry_date': |
720 | - $updated_field['key'] = 'entry_date'; |
|
721 | - $updated_field['input'] = 'entry_date'; |
|
722 | - $updated_field['value'] = array( |
|
720 | + $updated_field[ 'key' ] = 'entry_date'; |
|
721 | + $updated_field[ 'input' ] = 'entry_date'; |
|
722 | + $updated_field[ 'value' ] = array( |
|
723 | 723 | 'start' => esc_attr( stripslashes_deep( rgget( 'gv_start' ) ) ), |
724 | 724 | 'end' => esc_attr( stripslashes_deep( rgget( 'gv_end' ) ) ), |
725 | 725 | ); |
@@ -727,16 +727,16 @@ discard block |
||
727 | 727 | break; |
728 | 728 | |
729 | 729 | case 'entry_id': |
730 | - $updated_field['key'] = 'entry_id'; |
|
731 | - $updated_field['input'] = 'entry_id'; |
|
732 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) ); |
|
730 | + $updated_field[ 'key' ] = 'entry_id'; |
|
731 | + $updated_field[ 'input' ] = 'entry_id'; |
|
732 | + $updated_field[ 'value' ] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) ); |
|
733 | 733 | break; |
734 | 734 | |
735 | 735 | case 'created_by': |
736 | - $updated_field['key'] = 'created_by'; |
|
737 | - $updated_field['name'] = 'gv_by'; |
|
738 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) ); |
|
739 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
736 | + $updated_field[ 'key' ] = 'created_by'; |
|
737 | + $updated_field[ 'name' ] = 'gv_by'; |
|
738 | + $updated_field[ 'value' ] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) ); |
|
739 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
740 | 740 | break; |
741 | 741 | } |
742 | 742 | |
@@ -754,16 +754,16 @@ discard block |
||
754 | 754 | */ |
755 | 755 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
756 | 756 | |
757 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
757 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
758 | 758 | |
759 | 759 | /** @since 1.14 */ |
760 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
760 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
761 | 761 | |
762 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
762 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
763 | 763 | |
764 | 764 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
765 | 765 | |
766 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
766 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
767 | 767 | |
768 | 768 | if ( $has_date ) { |
769 | 769 | // enqueue datepicker stuff only if needed! |
@@ -785,10 +785,10 @@ discard block |
||
785 | 785 | public static function get_search_class( $custom_class = '' ) { |
786 | 786 | $gravityview_view = GravityView_View::getInstance(); |
787 | 787 | |
788 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
788 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
789 | 789 | |
790 | - if ( ! empty( $custom_class ) ) { |
|
791 | - $search_class .= ' '.$custom_class; |
|
790 | + if ( ! empty( $custom_class ) ) { |
|
791 | + $search_class .= ' ' . $custom_class; |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
@@ -831,11 +831,11 @@ discard block |
||
831 | 831 | |
832 | 832 | $label = rgget( 'label', $field ); |
833 | 833 | |
834 | - if( '' === $label ) { |
|
834 | + if ( '' === $label ) { |
|
835 | 835 | |
836 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
836 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
837 | 837 | |
838 | - switch( $field['field'] ) { |
|
838 | + switch ( $field[ 'field' ] ) { |
|
839 | 839 | case 'search_all': |
840 | 840 | $label = __( 'Search Entries:', 'gravityview' ); |
841 | 841 | break; |
@@ -853,10 +853,10 @@ discard block |
||
853 | 853 | break; |
854 | 854 | default: |
855 | 855 | // If this is a field input, not a field |
856 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
856 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
857 | 857 | |
858 | 858 | // Get the label for the field in question, which returns an array |
859 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
859 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
860 | 860 | |
861 | 861 | // Get the item with the `label` key |
862 | 862 | $values = wp_list_pluck( $items, 'label' ); |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | $form = $gravityview_view->getForm(); |
894 | 894 | |
895 | 895 | // for advanced field ids (eg, first name / last name ) |
896 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
896 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
897 | 897 | |
898 | 898 | // get searched value from $_GET (string or array) |
899 | 899 | $value = rgget( $name ); |
@@ -903,26 +903,26 @@ discard block |
||
903 | 903 | $value = is_array( $value ) ? array_map( 'urldecode', $value ) : urldecode( $value ); |
904 | 904 | |
905 | 905 | // get form field details |
906 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
906 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
907 | 907 | |
908 | 908 | $filter = array( |
909 | - 'key' => $field['field'], |
|
909 | + 'key' => $field[ 'field' ], |
|
910 | 910 | 'name' => $name, |
911 | 911 | 'label' => self::get_field_label( $field, $form_field ), |
912 | - 'input' => $field['input'], |
|
912 | + 'input' => $field[ 'input' ], |
|
913 | 913 | 'value' => _wp_specialchars( $value ), |
914 | - 'type' => $form_field['type'], |
|
914 | + 'type' => $form_field[ 'type' ], |
|
915 | 915 | ); |
916 | 916 | |
917 | 917 | // collect choices |
918 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
919 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
920 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
921 | - $filter['choices'] = $form_field['choices']; |
|
918 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
919 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
920 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
921 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
922 | 922 | } |
923 | 923 | |
924 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
925 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
924 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
925 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | return $filter; |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | |
947 | 947 | $choices = array(); |
948 | 948 | foreach ( $users as $user ) { |
949 | - $choices[] = array( |
|
949 | + $choices[ ] = array( |
|
950 | 950 | 'value' => $user->ID, |
951 | 951 | 'text' => $user->display_name, |
952 | 952 | ); |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | */ |
982 | 982 | public function add_datepicker_js_dependency( $js_dependencies ) { |
983 | 983 | |
984 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
984 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
985 | 985 | |
986 | 986 | return $js_dependencies; |
987 | 987 | } |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | 'isRTL' => is_rtl(), |
1026 | 1026 | ), $view_data ); |
1027 | 1027 | |
1028 | - $localizations['datepicker'] = $datepicker_settings; |
|
1028 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1029 | 1029 | |
1030 | 1030 | return $localizations; |
1031 | 1031 | |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | * @return void |
1055 | 1055 | */ |
1056 | 1056 | private function maybe_enqueue_flexibility() { |
1057 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1057 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1058 | 1058 | wp_enqueue_script( 'gv-flexibility' ); |
1059 | 1059 | } |
1060 | 1060 | } |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1077 | 1077 | |
1078 | 1078 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1079 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1079 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1080 | 1080 | |
1081 | 1081 | /** |
1082 | 1082 | * @filter `gravityview_search_datepicker_class` |
@@ -11,10 +11,10 @@ |
||
11 | 11 | ?> |
12 | 12 | |
13 | 13 | <div class="gv-search-box gv-search-date"> |
14 | - <?php if( ! gv_empty( $search_field['label'], false ) ) { ?> |
|
15 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
14 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false ) ) { ?> |
|
15 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
16 | 16 | <?php } ?> |
17 | 17 | <p> |
18 | - <input type="text" name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" value="<?php echo esc_attr( $search_field['value'] ); ?>" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" > |
|
18 | + <input type="text" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="<?php echo esc_attr( $search_field[ 'value' ] ); ?>" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" > |
|
19 | 19 | </p> |
20 | 20 | </div> |
21 | 21 | \ No newline at end of file |
@@ -10,22 +10,22 @@ |
||
10 | 10 | $search_field = $gravityview_view->search_field; |
11 | 11 | |
12 | 12 | // Make sure that there are choices to display |
13 | -if( empty( $search_field['choices'] ) ) { |
|
14 | - do_action('gravityview_log_debug', 'search-field-multiselect.php - No choices for field' ); |
|
13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
14 | + do_action( 'gravityview_log_debug', 'search-field-multiselect.php - No choices for field' ); |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class="gv-search-box gv-search-field-multiselect"> |
20 | - <?php if( ! gv_empty( $search_field['label'], false ) ) { ?> |
|
21 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
20 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false ) ) { ?> |
|
21 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
22 | 22 | <?php } ?> |
23 | 23 | <p> |
24 | - <select name="<?php echo esc_attr( $search_field['name'] ); ?>[]" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" multiple> |
|
25 | - <option value="" <?php gv_selected( '', $search_field['value'], true ); ?>>—</option> |
|
24 | + <select name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>[]" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" multiple> |
|
25 | + <option value="" <?php gv_selected( '', $search_field[ 'value' ], true ); ?>>—</option> |
|
26 | 26 | <?php |
27 | - foreach( $search_field['choices'] as $choice ) : ?> |
|
28 | - <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( $choice['value'], $search_field['value'], true ); ?>><?php echo esc_html( $choice['text'] ); ?></option> |
|
27 | + foreach ( $search_field[ 'choices' ] as $choice ) : ?> |
|
28 | + <option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( $choice[ 'value' ], $search_field[ 'value' ], true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option> |
|
29 | 29 | <?php endforeach; ?> |
30 | 30 | </select> |
31 | 31 | </p> |
@@ -10,22 +10,22 @@ |
||
10 | 10 | $search_field = $gravityview_view->search_field; |
11 | 11 | |
12 | 12 | // Make sure that there are choices to display |
13 | -if( empty( $search_field['choices'] ) ) { |
|
14 | - do_action('gravityview_log_debug', 'search-field-select.php - No choices for field' ); |
|
13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
14 | + do_action( 'gravityview_log_debug', 'search-field-select.php - No choices for field' ); |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class="gv-search-box gv-search-field-select"> |
20 | - <?php if( ! gv_empty( $search_field['label'], false ) ) { ?> |
|
21 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
20 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false ) ) { ?> |
|
21 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
22 | 22 | <?php } ?> |
23 | 23 | <p> |
24 | - <select name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"> |
|
25 | - <option value="" <?php selected( '', $search_field['value'], true ); ?>>—</option> |
|
24 | + <select name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"> |
|
25 | + <option value="" <?php selected( '', $search_field[ 'value' ], true ); ?>>—</option> |
|
26 | 26 | <?php |
27 | - foreach( $search_field['choices'] as $choice ) : ?> |
|
28 | - <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php selected( $choice['value'], $search_field['value'], true ); ?>><?php echo esc_html( $choice['text'] ); ?></option> |
|
27 | + foreach ( $search_field[ 'choices' ] as $choice ) : ?> |
|
28 | + <option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php selected( $choice[ 'value' ], $search_field[ 'value' ], true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option> |
|
29 | 29 | <?php endforeach; ?> |
30 | 30 | </select> |
31 | 31 | </p> |
@@ -10,10 +10,10 @@ |
||
10 | 10 | |
11 | 11 | ?> |
12 | 12 | <div class="gv-search-box gv-search-field-text"> |
13 | - <?php if( ! gv_empty( $search_field['label'], false ) ) { ?> |
|
14 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
13 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false ) ) { ?> |
|
14 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
15 | 15 | <?php } ?> |
16 | 16 | <p> |
17 | - <input type="text" name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" value="<?php echo esc_attr( $search_field['value'] ); ?>"> |
|
17 | + <input type="text" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="<?php echo esc_attr( $search_field[ 'value' ] ); ?>"> |
|
18 | 18 | </p> |
19 | 19 | </div> |
20 | 20 | \ No newline at end of file |