@@ -19,12 +19,12 @@ |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | function render_input( $override_input = null ) { |
22 | - if( isset( $override_input ) ) { |
|
22 | + if ( isset( $override_input ) ) { |
|
23 | 23 | echo $override_input; |
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
27 | - foreach( $this->field['options'] as $value => $label ) : ?> |
|
27 | + foreach ( $this->field[ 'options' ] as $value => $label ) : ?> |
|
28 | 28 | <label class="<?php echo $this->get_label_class(); ?>"> |
29 | 29 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>-<?php echo esc_attr( $value ); ?>" type="radio" value="<?php echo esc_attr( $value ); ?>" <?php checked( $value, $this->value, true ); ?> /> <?php echo esc_html( $label ); ?> |
30 | 30 | </label> |
@@ -38,8 +38,8 @@ |
||
38 | 38 | // Set the $_field_id var |
39 | 39 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type ); |
40 | 40 | |
41 | - if( $this->is_choice_value_enabled() ) { |
|
42 | - $field_options['choice_display'] = array( |
|
41 | + if ( $this->is_choice_value_enabled() ) { |
|
42 | + $field_options[ 'choice_display' ] = array( |
|
43 | 43 | 'type' => 'radio', |
44 | 44 | 'value' => 'value', |
45 | 45 | 'label' => __( 'What should be displayed:', 'gravityview' ), |
@@ -48,25 +48,25 @@ |
||
48 | 48 | |
49 | 49 | $quiz_fields = GFAPI::get_fields_by_type( $form, 'quiz' ); |
50 | 50 | |
51 | - if( ! empty( $quiz_fields ) ) { |
|
51 | + if ( ! empty( $quiz_fields ) ) { |
|
52 | 52 | |
53 | - $fields['gquiz_score'] = array( |
|
53 | + $fields[ 'gquiz_score' ] = array( |
|
54 | 54 | 'label' => __( 'Quiz Score Total', 'gravityview' ), |
55 | 55 | 'type' => 'quiz_score', |
56 | 56 | 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
57 | 57 | ); |
58 | - $fields['gquiz_percent'] = array( |
|
58 | + $fields[ 'gquiz_percent' ] = array( |
|
59 | 59 | 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
60 | 60 | 'type' => 'quiz_percent', |
61 | 61 | 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
62 | 62 | ); |
63 | - $fields['gquiz_grade'] = array( |
|
63 | + $fields[ 'gquiz_grade' ] = array( |
|
64 | 64 | /* translators: This is a field type used by the Gravity Forms Quiz Addon. "A" is 100-90, "B" is 89-80, "C" is 79-70, etc. */ |
65 | 65 | 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
66 | 66 | 'type' => 'quiz_grade', |
67 | 67 | 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
68 | 68 | ); |
69 | - $fields['gquiz_is_pass'] = array( |
|
69 | + $fields[ 'gquiz_is_pass' ] = array( |
|
70 | 70 | 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
71 | 71 | 'type' => 'quiz_is_pass', |
72 | 72 | 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @return string If a custom field label isn't set, return the field label for the password field |
51 | 51 | */ |
52 | - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ |
|
52 | + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { |
|
53 | 53 | |
54 | 54 | // If using a custom label, no need to fetch the parent label |
55 | 55 | if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return string If a custom field label isn't set, return the field label for the password field |
51 | 51 | */ |
52 | - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ |
|
52 | + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { |
|
53 | 53 | |
54 | 54 | // If using a custom label, no need to fetch the parent label |
55 | - if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { |
|
55 | + if ( ! is_numeric( $field[ 'id' ] ) || ! empty( $field[ 'custom_label' ] ) ) { |
|
56 | 56 | return $label; |
57 | 57 | } |
58 | 58 | |
59 | - $field_object = GFFormsModel::get_field( $form, $field['id'] ); |
|
59 | + $field_object = GFFormsModel::get_field( $form, $field[ 'id' ] ); |
|
60 | 60 | |
61 | - if( $field_object && 'password' === $field_object->type ) { |
|
62 | - $label = $field['label']; |
|
61 | + if ( $field_object && 'password' === $field_object->type ) { |
|
62 | + $label = $field[ 'label' ]; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return $label; |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | function add_form_fields( $fields = array(), $form = array(), $include_parent_field = true ) { |
80 | 80 | |
81 | 81 | foreach ( $fields as $key => $field ) { |
82 | - if( 'password' === $field['type'] ) { |
|
82 | + if ( 'password' === $field[ 'type' ] ) { |
|
83 | 83 | |
84 | 84 | // The Enter Password input |
85 | - if( floor( $key ) === floatval( $key ) ) { |
|
85 | + if ( floor( $key ) === floatval( $key ) ) { |
|
86 | 86 | |
87 | - if( ! empty( $field['parent'] ) ) { |
|
88 | - $field['label'] = $field['parent']->label; |
|
89 | - $field['adminOnly'] = $field['parent']->adminOnly; |
|
90 | - $field['adminLabel'] = $field['parent']->adminLabel; |
|
87 | + if ( ! empty( $field[ 'parent' ] ) ) { |
|
88 | + $field[ 'label' ] = $field[ 'parent' ]->label; |
|
89 | + $field[ 'adminOnly' ] = $field[ 'parent' ]->adminOnly; |
|
90 | + $field[ 'adminLabel' ] = $field[ 'parent' ]->adminLabel; |
|
91 | 91 | // Don't show as a child input |
92 | - unset( $field['parent'] ); |
|
92 | + unset( $field[ 'parent' ] ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $fields[ $key ] = $field; |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * @param \GV\Entry $entry The entry. |
39 | 39 | * @param \GV\Request $request The request context. |
40 | 40 | * |
41 | - * @return mixed $value The filtered value. |
|
41 | + * @return string $value The filtered value. |
|
42 | 42 | */ |
43 | 43 | public function get_value( $value, $field, $view, $source, $entry, $request ) { |
44 | 44 | /** Passwords should never be exposed. */ |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * Add admin script to the no-conflict scripts whitelist |
203 | 203 | * @param array $allowed Scripts allowed in no-conflict mode |
204 | - * @return array Scripts allowed in no-conflict mode, plus the search widget script |
|
204 | + * @return string[] Scripts allowed in no-conflict mode, plus the search widget script |
|
205 | 205 | */ |
206 | 206 | public function register_no_conflict( $allowed ) { |
207 | 207 | $allowed[] = 'gravityview_searchwidget_admin'; |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | /** |
890 | 890 | * Get the label for a search form field |
891 | 891 | * @param array $field Field setting as sent by the GV configuration - has `field`, `input` (input type), and `label` keys |
892 | - * @param array $form_field Form field data, as fetched by `gravityview_get_field()` |
|
892 | + * @param GF_Field|null $form_field Form field data, as fetched by `gravityview_get_field()` |
|
893 | 893 | * @return string Label for the search form |
894 | 894 | */ |
895 | 895 | private static function get_field_label( $field, $form_field = array() ) { |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | /** |
1059 | 1059 | * Require the datepicker script for the frontend GV script |
1060 | 1060 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
1061 | - * @return array Array required scripts, with `jquery-ui-datepicker` added |
|
1061 | + * @return string[] Array required scripts, with `jquery-ui-datepicker` added |
|
1062 | 1062 | */ |
1063 | 1063 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1064 | 1064 | |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | /** |
1071 | 1071 | * Modify the array passed to wp_localize_script() |
1072 | 1072 | * |
1073 | - * @param array $js_localization The data padded to the Javascript file |
|
1073 | + * @param array $localizations The data padded to the Javascript file |
|
1074 | 1074 | * @param array $view_data View data array with View settings |
1075 | 1075 | * |
1076 | 1076 | * @return array |
@@ -603,7 +603,8 @@ discard block |
||
603 | 603 | // Fast-forward 24 hour on the end time |
604 | 604 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
605 | 605 | $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
606 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
606 | + if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { |
|
607 | +// See https://github.com/gravityview/GravityView/issues/1056 |
|
607 | 608 | $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
608 | 609 | } |
609 | 610 | } |
@@ -874,7 +875,7 @@ discard block |
||
874 | 875 | 'ymd_dot' => 'Y.m.d', |
875 | 876 | ); |
876 | 877 | |
877 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
878 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
878 | 879 | $format = $datepicker[ $field->dateFormat ]; |
879 | 880 | } |
880 | 881 |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'type' => 'radio', |
65 | 65 | 'full_width' => true, |
66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
68 | 68 | 'value' => 'any', |
69 | 69 | 'class' => 'hide-if-js', |
70 | 70 | 'options' => array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
88 | 88 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
89 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
89 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
90 | 90 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
91 | 91 | |
92 | 92 | // ajax - get the searchable fields |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
225 | 225 | $script_source = empty( $script_min ) ? '/source' : ''; |
226 | 226 | |
227 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
227 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
228 | 228 | |
229 | 229 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
230 | 230 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
247 | 247 | */ |
248 | 248 | public function register_no_conflict( $allowed ) { |
249 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
249 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
250 | 250 | return $allowed; |
251 | 251 | } |
252 | 252 | |
@@ -259,24 +259,24 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public static function get_searchable_fields() { |
261 | 261 | |
262 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
262 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
263 | 263 | exit( '0' ); |
264 | 264 | } |
265 | 265 | |
266 | 266 | $form = ''; |
267 | 267 | |
268 | 268 | // Fetch the form for the current View |
269 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
269 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
270 | 270 | |
271 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
271 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
272 | 272 | |
273 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
273 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
274 | 274 | |
275 | - $form = (int) $_POST['formid']; |
|
275 | + $form = (int)$_POST[ 'formid' ]; |
|
276 | 276 | |
277 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
277 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
278 | 278 | |
279 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
279 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
280 | 280 | |
281 | 281 | } |
282 | 282 | |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | ), |
326 | 326 | ); |
327 | 327 | |
328 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
329 | - $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'] ); |
|
328 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
329 | + $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' ] ); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | // Get fields with sub-inputs and no parent |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | |
349 | 349 | foreach ( $fields as $id => $field ) { |
350 | 350 | |
351 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
351 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
352 | 352 | continue; |
353 | 353 | } |
354 | 354 | |
355 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
355 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
356 | 356 | |
357 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
357 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
378 | 378 | |
379 | 379 | // @todo - This needs to be improved - many fields have . including products and addresses |
380 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
380 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
381 | 381 | $input_type = 'boolean'; // on/off checkbox |
382 | 382 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
383 | 383 | $input_type = 'multi'; //multiselect |
@@ -421,19 +421,19 @@ discard block |
||
421 | 421 | $post_id = 0; |
422 | 422 | |
423 | 423 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
424 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
425 | - $post_id = absint( $widget_args['post_id'] ); |
|
424 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
425 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
426 | 426 | } |
427 | 427 | // We're in the WordPress Widget context, and the base View ID should be used |
428 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
429 | - $post_id = absint( $widget_args['view_id'] ); |
|
428 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
429 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | $args = gravityview_get_permalink_query_args( $post_id ); |
433 | 433 | |
434 | 434 | // Add hidden fields to the search form |
435 | 435 | foreach ( $args as $key => $value ) { |
436 | - $search_fields[] = array( |
|
436 | + $search_fields[ ] = array( |
|
437 | 437 | 'name' => $key, |
438 | 438 | 'input' => 'hidden', |
439 | 439 | 'value' => $value, |
@@ -472,22 +472,22 @@ discard block |
||
472 | 472 | /** |
473 | 473 | * Include the sidebar Widgets. |
474 | 474 | */ |
475 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
475 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
476 | 476 | |
477 | 477 | foreach ( $widgets as $widget ) { |
478 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
479 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
478 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
479 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
480 | 480 | foreach ( $_fields as $field ) { |
481 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
481 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | 487 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
488 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
488 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
489 | 489 | foreach ( $_fields as $field ) { |
490 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
490 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
491 | 491 | } |
492 | 492 | } |
493 | 493 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | */ |
505 | 505 | public function filter_entries( $search_criteria, $form_id = null, $args = array() ) { |
506 | 506 | |
507 | - if( 'post' === $this->search_method ) { |
|
507 | + if ( 'post' === $this->search_method ) { |
|
508 | 508 | $get = $_POST; |
509 | 509 | } else { |
510 | 510 | $get = $_GET; |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | $get = gv_map_deep( $get, 'rawurldecode' ); |
524 | 524 | |
525 | 525 | // Make sure array key is set up |
526 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
526 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
527 | 527 | |
528 | 528 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
529 | 529 | |
530 | 530 | // add free search |
531 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
531 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
532 | 532 | |
533 | - $search_all_value = trim( $get['gv_search'] ); |
|
533 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
534 | 534 | |
535 | 535 | /** |
536 | 536 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | } |
556 | 556 | |
557 | 557 | foreach ( $words as $word ) { |
558 | - $search_criteria['field_filters'][] = array( |
|
558 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
559 | 559 | 'key' => null, // The field ID to search |
560 | 560 | 'value' => $word, // The value to search |
561 | 561 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -568,14 +568,14 @@ discard block |
||
568 | 568 | /** |
569 | 569 | * Get and normalize the dates according to the input format. |
570 | 570 | */ |
571 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
572 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
571 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
572 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
573 | 573 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
577 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
578 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
577 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
578 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
579 | 579 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
580 | 580 | } |
581 | 581 | } |
@@ -610,22 +610,22 @@ discard block |
||
610 | 610 | */ |
611 | 611 | if ( ! empty( $curr_start ) ) { |
612 | 612 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
613 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
613 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | if ( ! empty( $curr_end ) ) { |
617 | 617 | // Fast-forward 24 hour on the end time |
618 | 618 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
619 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
620 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
621 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
619 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
620 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
621 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | } |
625 | 625 | |
626 | 626 | // search for a specific entry ID |
627 | 627 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
628 | - $search_criteria['field_filters'][] = array( |
|
628 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
629 | 629 | 'key' => 'id', |
630 | 630 | 'value' => absint( $get[ 'gv_id' ] ), |
631 | 631 | 'operator' => '=', |
@@ -634,42 +634,42 @@ discard block |
||
634 | 634 | |
635 | 635 | // search for a specific Created_by ID |
636 | 636 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
637 | - $search_criteria['field_filters'][] = array( |
|
637 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
638 | 638 | 'key' => 'created_by', |
639 | - 'value' => absint( $get['gv_by'] ), |
|
639 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
640 | 640 | 'operator' => '=', |
641 | 641 | ); |
642 | 642 | } |
643 | 643 | |
644 | 644 | |
645 | 645 | // Get search mode passed in URL |
646 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
646 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
647 | 647 | |
648 | 648 | // get the other search filters |
649 | 649 | foreach ( $get as $key => $value ) { |
650 | 650 | |
651 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
651 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
652 | 652 | continue; |
653 | 653 | } |
654 | 654 | |
655 | 655 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
656 | 656 | |
657 | 657 | // could return simple filter or multiple filters |
658 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
658 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
659 | 659 | continue; |
660 | 660 | } |
661 | 661 | |
662 | 662 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
663 | 663 | |
664 | - if ( isset( $filter[0]['value'] ) ) { |
|
665 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
664 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
665 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
666 | 666 | |
667 | 667 | // if date range type, set search mode to ALL |
668 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
668 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
669 | 669 | $mode = 'all'; |
670 | 670 | } |
671 | - } elseif( !empty( $filter ) ) { |
|
672 | - $search_criteria['field_filters'][] = $filter; |
|
671 | + } elseif ( ! empty( $filter ) ) { |
|
672 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * @since 1.5.1 |
679 | 679 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
680 | 680 | */ |
681 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
681 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
682 | 682 | |
683 | 683 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
684 | 684 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | $field_id = str_replace( 'filter_', '', $key ); |
707 | 707 | |
708 | 708 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
709 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
709 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
710 | 710 | $field_id = str_replace( '_', '.', $field_id ); |
711 | 711 | } |
712 | 712 | |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | |
742 | 742 | case 'select': |
743 | 743 | case 'radio': |
744 | - $filter['operator'] = 'is'; |
|
744 | + $filter[ 'operator' ] = 'is'; |
|
745 | 745 | break; |
746 | 746 | |
747 | 747 | case 'post_category': |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | |
756 | 756 | foreach ( $value as $val ) { |
757 | 757 | $cat = get_term( $val, 'category' ); |
758 | - $filter[] = array( |
|
758 | + $filter[ ] = array( |
|
759 | 759 | 'key' => $filter_key, |
760 | 760 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
761 | 761 | 'operator' => 'is', |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | $filter = array(); |
775 | 775 | |
776 | 776 | foreach ( $value as $val ) { |
777 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
777 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | break; |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | // convert checkbox on/off into the correct search filter |
784 | 784 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
785 | 785 | foreach ( $form_field->inputs as $k => $input ) { |
786 | - if ( $input['id'] == $filter_key ) { |
|
787 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
788 | - $filter['operator'] = 'is'; |
|
786 | + if ( $input[ 'id' ] == $filter_key ) { |
|
787 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
788 | + $filter[ 'operator' ] = 'is'; |
|
789 | 789 | break; |
790 | 790 | } |
791 | 791 | } |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | $filter = array(); |
796 | 796 | |
797 | 797 | foreach ( $value as $val ) { |
798 | - $filter[] = array( |
|
798 | + $filter[ ] = array( |
|
799 | 799 | 'key' => $filter_key, |
800 | 800 | 'value' => $val, |
801 | 801 | 'operator' => 'is', |
@@ -816,9 +816,9 @@ discard block |
||
816 | 816 | foreach ( $words as $word ) { |
817 | 817 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
818 | 818 | // Keep the same key for each filter |
819 | - $filter['value'] = $word; |
|
819 | + $filter[ 'value' ] = $word; |
|
820 | 820 | // Add a search for the value |
821 | - $filters[] = $filter; |
|
821 | + $filters[ ] = $filter; |
|
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
@@ -832,19 +832,19 @@ discard block |
||
832 | 832 | |
833 | 833 | foreach ( $searchable_fields as $searchable_field ) { |
834 | 834 | |
835 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
835 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
836 | 836 | continue; |
837 | 837 | } |
838 | 838 | |
839 | 839 | // Only exact-match dropdowns, not text search |
840 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
840 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
841 | 841 | continue; |
842 | 842 | } |
843 | 843 | |
844 | 844 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
845 | 845 | |
846 | 846 | if ( 4 === $input_id ) { |
847 | - $filter['operator'] = 'is'; |
|
847 | + $filter[ 'operator' ] = 'is'; |
|
848 | 848 | }; |
849 | 849 | } |
850 | 850 | } |
@@ -869,19 +869,19 @@ discard block |
||
869 | 869 | * @since 1.16.3 |
870 | 870 | * Safeguard until GF implements '<=' operator |
871 | 871 | */ |
872 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
872 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
873 | 873 | $operator = '<'; |
874 | 874 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
875 | 875 | } |
876 | 876 | |
877 | - $filter[] = array( |
|
877 | + $filter[ ] = array( |
|
878 | 878 | 'key' => $filter_key, |
879 | 879 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
880 | 880 | 'operator' => $operator, |
881 | 881 | ); |
882 | 882 | } |
883 | 883 | } else { |
884 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
884 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | break; |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | 'ymd_dot' => 'Y.m.d', |
913 | 913 | ); |
914 | 914 | |
915 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
915 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
916 | 916 | $format = $datepicker[ $field->dateFormat ]; |
917 | 917 | } |
918 | 918 | |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | public function add_template_path( $file_paths ) { |
946 | 946 | |
947 | 947 | // Index 100 is the default GravityView template path. |
948 | - $file_paths[102] = self::$file . 'templates/'; |
|
948 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
949 | 949 | |
950 | 950 | return $file_paths; |
951 | 951 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $has_date = false; |
965 | 965 | |
966 | 966 | foreach ( $search_fields as $k => $field ) { |
967 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
967 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
968 | 968 | $has_date = true; |
969 | 969 | break; |
970 | 970 | } |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | } |
992 | 992 | |
993 | 993 | // get configured search fields |
994 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
994 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
995 | 995 | |
996 | 996 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
997 | 997 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1006,34 +1006,34 @@ discard block |
||
1006 | 1006 | |
1007 | 1007 | $updated_field = $this->get_search_filter_details( $updated_field ); |
1008 | 1008 | |
1009 | - switch ( $field['field'] ) { |
|
1009 | + switch ( $field[ 'field' ] ) { |
|
1010 | 1010 | |
1011 | 1011 | case 'search_all': |
1012 | - $updated_field['key'] = 'search_all'; |
|
1013 | - $updated_field['input'] = 'search_all'; |
|
1014 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1012 | + $updated_field[ 'key' ] = 'search_all'; |
|
1013 | + $updated_field[ 'input' ] = 'search_all'; |
|
1014 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1015 | 1015 | break; |
1016 | 1016 | |
1017 | 1017 | case 'entry_date': |
1018 | - $updated_field['key'] = 'entry_date'; |
|
1019 | - $updated_field['input'] = 'entry_date'; |
|
1020 | - $updated_field['value'] = array( |
|
1018 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1019 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1020 | + $updated_field[ 'value' ] = array( |
|
1021 | 1021 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1022 | 1022 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1023 | 1023 | ); |
1024 | 1024 | break; |
1025 | 1025 | |
1026 | 1026 | case 'entry_id': |
1027 | - $updated_field['key'] = 'entry_id'; |
|
1028 | - $updated_field['input'] = 'entry_id'; |
|
1029 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1027 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1028 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1029 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1030 | 1030 | break; |
1031 | 1031 | |
1032 | 1032 | case 'created_by': |
1033 | - $updated_field['key'] = 'created_by'; |
|
1034 | - $updated_field['name'] = 'gv_by'; |
|
1035 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1036 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
1033 | + $updated_field[ 'key' ] = 'created_by'; |
|
1034 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1035 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1036 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
1037 | 1037 | break; |
1038 | 1038 | } |
1039 | 1039 | |
@@ -1052,16 +1052,16 @@ discard block |
||
1052 | 1052 | */ |
1053 | 1053 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1054 | 1054 | |
1055 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1055 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1056 | 1056 | |
1057 | 1057 | /** @since 1.14 */ |
1058 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1058 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1059 | 1059 | |
1060 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1060 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1061 | 1061 | |
1062 | 1062 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1063 | 1063 | |
1064 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1064 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1065 | 1065 | |
1066 | 1066 | if ( $this->has_date_field( $search_fields ) ) { |
1067 | 1067 | // enqueue datepicker stuff only if needed! |
@@ -1083,10 +1083,10 @@ discard block |
||
1083 | 1083 | public static function get_search_class( $custom_class = '' ) { |
1084 | 1084 | $gravityview_view = GravityView_View::getInstance(); |
1085 | 1085 | |
1086 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1086 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1087 | 1087 | |
1088 | - if ( ! empty( $custom_class ) ) { |
|
1089 | - $search_class .= ' '.$custom_class; |
|
1088 | + if ( ! empty( $custom_class ) ) { |
|
1089 | + $search_class .= ' ' . $custom_class; |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | /** |
@@ -1130,9 +1130,9 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | if ( ! $label ) { |
1132 | 1132 | |
1133 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1133 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1134 | 1134 | |
1135 | - switch( $field['field'] ) { |
|
1135 | + switch ( $field[ 'field' ] ) { |
|
1136 | 1136 | case 'search_all': |
1137 | 1137 | $label = __( 'Search Entries:', 'gravityview' ); |
1138 | 1138 | break; |
@@ -1144,10 +1144,10 @@ discard block |
||
1144 | 1144 | break; |
1145 | 1145 | default: |
1146 | 1146 | // If this is a field input, not a field |
1147 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1147 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1148 | 1148 | |
1149 | 1149 | // Get the label for the field in question, which returns an array |
1150 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1150 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1151 | 1151 | |
1152 | 1152 | // Get the item with the `label` key |
1153 | 1153 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1186,32 +1186,32 @@ discard block |
||
1186 | 1186 | $form = $gravityview_view->getForm(); |
1187 | 1187 | |
1188 | 1188 | // for advanced field ids (eg, first name / last name ) |
1189 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1189 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1190 | 1190 | |
1191 | 1191 | // get searched value from $_GET/$_POST (string or array) |
1192 | 1192 | $value = $this->rgget_or_rgpost( $name ); |
1193 | 1193 | |
1194 | 1194 | // get form field details |
1195 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1195 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1196 | 1196 | |
1197 | 1197 | $filter = array( |
1198 | - 'key' => $field['field'], |
|
1198 | + 'key' => $field[ 'field' ], |
|
1199 | 1199 | 'name' => $name, |
1200 | 1200 | 'label' => self::get_field_label( $field, $form_field ), |
1201 | - 'input' => $field['input'], |
|
1201 | + 'input' => $field[ 'input' ], |
|
1202 | 1202 | 'value' => $value, |
1203 | - 'type' => $form_field['type'], |
|
1203 | + 'type' => $form_field[ 'type' ], |
|
1204 | 1204 | ); |
1205 | 1205 | |
1206 | 1206 | // collect choices |
1207 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1208 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1209 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1210 | - $filter['choices'] = $form_field['choices']; |
|
1207 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1208 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1209 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1210 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1214 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1213 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1214 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1215 | 1215 | } |
1216 | 1216 | |
1217 | 1217 | return $filter; |
@@ -1235,7 +1235,7 @@ discard block |
||
1235 | 1235 | |
1236 | 1236 | $choices = array(); |
1237 | 1237 | foreach ( $users as $user ) { |
1238 | - $choices[] = array( |
|
1238 | + $choices[ ] = array( |
|
1239 | 1239 | 'value' => $user->ID, |
1240 | 1240 | 'text' => $user->display_name, |
1241 | 1241 | ); |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | */ |
1291 | 1291 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1292 | 1292 | |
1293 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1293 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1294 | 1294 | |
1295 | 1295 | return $js_dependencies; |
1296 | 1296 | } |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | 'isRTL' => is_rtl(), |
1335 | 1335 | ), $view_data ); |
1336 | 1336 | |
1337 | - $localizations['datepicker'] = $datepicker_settings; |
|
1337 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1338 | 1338 | |
1339 | 1339 | return $localizations; |
1340 | 1340 | |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | * @return void |
1362 | 1362 | */ |
1363 | 1363 | private function maybe_enqueue_flexibility() { |
1364 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1364 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1365 | 1365 | wp_enqueue_script( 'gv-flexibility' ); |
1366 | 1366 | } |
1367 | 1367 | } |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1384 | 1384 | |
1385 | 1385 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1386 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1386 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1387 | 1387 | |
1388 | 1388 | /** |
1389 | 1389 | * @filter `gravityview_search_datepicker_class` |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | 'slug' => 'edit', |
25 | 25 | 'type' => 'internal', |
26 | 26 | 'label' => __( 'Edit Table', 'gravityview' ), |
27 | - 'description' => __('Display items in a table view.', 'gravityview'), |
|
28 | - 'logo' => plugins_url('includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE), |
|
27 | + 'description' => __( 'Display items in a table view.', 'gravityview' ), |
|
28 | + 'logo' => plugins_url( 'includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE ), |
|
29 | 29 | 'css_source' => gravityview_css_url( 'table-view.css', GRAVITYVIEW_DIR . 'templates/css/' ), |
30 | 30 | ); |
31 | 31 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | '1-1' => array( |
43 | 43 | array( |
44 | 44 | 'areaid' => 'edit-fields', |
45 | - 'title' => __('Visible Edit Fields', 'gravityview' ) |
|
45 | + 'title' => __( 'Visible Edit Fields', 'gravityview' ) |
|
46 | 46 | ) |
47 | 47 | ) |
48 | 48 | ) |
@@ -36,7 +36,6 @@ |
||
36 | 36 | * @since 1.16.4 |
37 | 37 | * @since 1.17 Moved to GravityView_Plugin_Hooks_Gravity_Forms_Survey class |
38 | 38 | * |
39 | - * @param array $form |
|
40 | 39 | * |
41 | 40 | * @return array Form, with all fields set to `allowsPrepopulate => true` |
42 | 41 | */ |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $return = $input_type; |
47 | 47 | |
48 | - if( 'survey' === $field_type ) { |
|
48 | + if ( 'survey' === $field_type ) { |
|
49 | 49 | $return = 'select'; |
50 | 50 | } |
51 | 51 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | public function fix_survey_fields( $fields ) { |
66 | 66 | |
67 | 67 | /** @var GF_Field $field */ |
68 | - foreach( $fields as &$field ) { |
|
69 | - if( 'survey' === $field->type ) { |
|
68 | + foreach ( $fields as &$field ) { |
|
69 | + if ( 'survey' === $field->type ) { |
|
70 | 70 | $field->allowsPrepopulate = true; |
71 | 71 | } |
72 | 72 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | function add_render_hooks() { |
85 | - add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10, 3 ); |
|
85 | + add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10, 3 ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | function remove_render_hooks() { |
98 | - remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10 ); |
|
98 | + remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10 ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function fix_survey_field_value( $value, $field, $name ) { |
115 | 115 | |
116 | - if( 'survey' === $field->type ) { |
|
116 | + if ( 'survey' === $field->type ) { |
|
117 | 117 | |
118 | - $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry(); |
|
118 | + $entry = GravityView_Edit_Entry::getInstance()->instances[ 'render' ]->get_entry(); |
|
119 | 119 | |
120 | 120 | // We need to run through each survey row until we find a match for expected values |
121 | 121 | foreach ( $entry as $field_id => $field_value ) { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | list( $row_val, $col_val ) = explode( ':', $field_value, 2 ); |
129 | 129 | |
130 | 130 | // If the $name matches the $row_val, we are processing the correct row |
131 | - if( $row_val === $name ) { |
|
131 | + if ( $row_val === $name ) { |
|
132 | 132 | $value = $field_value; |
133 | 133 | break; |
134 | 134 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return void |
31 | 31 | */ |
32 | 32 | private function add_hooks() { |
33 | - add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value'), 10, 2 ); |
|
33 | + add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value' ), 10, 2 ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function edit_entry_field_value( $field_value, $field ) { |
47 | 47 | |
48 | - if( 'list' === $field->inputType ) { |
|
48 | + if ( 'list' === $field->inputType ) { |
|
49 | 49 | $field_value = is_string( $field_value ) ? json_decode( $field_value, true ) : $field_value; |
50 | 50 | |
51 | 51 | if ( ! is_array( $field_value ) ) { |
@@ -12,10 +12,10 @@ |
||
12 | 12 | |
13 | 13 | $field_info_items = array(); |
14 | 14 | |
15 | - if( !empty( $this->item['description'] ) ) { |
|
15 | + if ( ! empty( $this->item[ 'description' ] ) ) { |
|
16 | 16 | |
17 | - $field_info_items[] = array( |
|
18 | - 'value' => $this->item['description'] |
|
17 | + $field_info_items[ ] = array( |
|
18 | + 'value' => $this->item[ 'description' ] |
|
19 | 19 | ); |
20 | 20 | |
21 | 21 | } |