@@ -7,17 +7,17 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
12 | -$name = $gravityview_view->search_field['name']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | +$name = $gravityview_view->search_field[ 'name' ]; |
|
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="gv-search-box gv-search-date"> |
16 | - <?php if( ! gv_empty( $label, false ) ) { ?> |
|
17 | - <label for="search-box-<?php echo esc_attr( $name ).'-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
16 | + <?php if ( ! gv_empty( $label, false ) ) { ?> |
|
17 | + <label for="search-box-<?php echo esc_attr( $name ) . '-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
18 | 18 | <?php } ?> |
19 | 19 | <p> |
20 | - <input name="<?php echo esc_attr( $name ).'[start]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo $value['start']; ?>"> |
|
21 | - <input name="<?php echo esc_attr( $name ).'[end]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo $value['end']; ?>"> |
|
20 | + <input name="<?php echo esc_attr( $name ) . '[start]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo $value[ 'start' ]; ?>"> |
|
21 | + <input name="<?php echo esc_attr( $name ) . '[end]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo $value[ 'end' ]; ?>"> |
|
22 | 22 | </p> |
23 | 23 | </div> |
24 | 24 | \ No newline at end of file |
@@ -7,14 +7,14 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="gv-search-box"> |
16 | 16 | <div class="gv-search"> |
17 | - <?php if( ! gv_empty( $label, false ) ) { ?> |
|
17 | + <?php if ( ! gv_empty( $label, false ) ) { ?> |
|
18 | 18 | <label for="gv_search_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
19 | 19 | <?php } ?> |
20 | 20 | <p><input type="text" name="gv_search" id="gv_search_<?php echo $view_id; ?>" value="<?php echo $value; ?>" /></p> |
@@ -7,13 +7,13 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class="gv-search-box"> |
15 | 15 | <div class="gv-search"> |
16 | - <?php if( ! gv_empty( $label, false ) ) { ?> |
|
16 | + <?php if ( ! gv_empty( $label, false ) ) { ?> |
|
17 | 17 | <label for="gv_entry_id_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
18 | 18 | <?php } ?> |
19 | 19 | <p><input type="text" name="gv_id" id="gv_entry_id_<?php echo $view_id; ?>" value="<?php echo $value; ?>" /></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-checkbox.php - No choices for field' ); |
|
13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
14 | + do_action( 'gravityview_log_debug', 'search-field-checkbox.php - No choices for field' ); |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class="gv-search-box"> |
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 | - <?php foreach( $search_field['choices'] as $choice ) { ?> |
|
24 | + <?php foreach ( $search_field[ 'choices' ] as $choice ) { ?> |
|
25 | 25 | |
26 | - <label for="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" class="gv-check-radio"> |
|
27 | - <input type="checkbox" name="<?php echo esc_attr( $search_field['name'] ); ?>[]" value="<?php echo esc_attr( $choice['value'] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" <?php gv_selected( $choice['value'], $search_field['value'], true, 'checked' ); ?>> |
|
28 | - <?php echo esc_html( $choice['text'] ); ?> |
|
26 | + <label for="search-box-<?php echo sanitize_html_class( $search_field[ 'name' ] . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" class="gv-check-radio"> |
|
27 | + <input type="checkbox" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>[]" value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field[ 'name' ] . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" <?php gv_selected( $choice[ 'value' ], $search_field[ 'value' ], true, 'checked' ); ?>> |
|
28 | + <?php echo esc_html( $choice[ 'text' ] ); ?> |
|
29 | 29 | </label> |
30 | 30 | |
31 | 31 | <?php } ?> |
@@ -7,17 +7,17 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="gv-search-box gv-search-date"> |
16 | - <?php if( ! gv_empty( $label, false ) ) { ?> |
|
16 | + <?php if ( ! gv_empty( $label, false ) ) { ?> |
|
17 | 17 | <label for="gv_start_date_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
18 | 18 | <?php } ?> |
19 | 19 | <p> |
20 | - <input name="gv_start" id="gv_start_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo $value['start']; ?>"> |
|
21 | - <input name="gv_end" id="gv_end_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo $value['end']; ?>"> |
|
20 | + <input name="gv_start" id="gv_start_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo $value[ 'start' ]; ?>"> |
|
21 | + <input name="gv_end" id="gv_end_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo $value[ 'end' ]; ?>"> |
|
22 | 22 | </p> |
23 | 23 | </div> |
24 | 24 | \ 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-radio.php - No choices for field' ); |
|
13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
14 | + do_action( 'gravityview_log_debug', 'search-field-radio.php - No choices for field' ); |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class="gv-search-box"> |
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 | - <?php foreach( $search_field['choices'] as $choice ) { ?> |
|
24 | + <?php foreach ( $search_field[ 'choices' ] as $choice ) { ?> |
|
25 | 25 | |
26 | - <label for="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" class="gv-check-radio"> |
|
27 | - <input type="radio" name="<?php echo esc_attr( $search_field['name'] ); ?>" value="<?php echo esc_attr( $choice['value'] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field['name'].$choice['value'].$choice['text'] ); ?>" <?php checked( $choice['value'], $search_field['value'], true ); ?>> |
|
28 | - <?php echo esc_html( $choice['text'] ); ?> |
|
26 | + <label for="search-box-<?php echo sanitize_html_class( $search_field[ 'name' ] . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" class="gv-check-radio"> |
|
27 | + <input type="radio" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field[ 'name' ] . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" <?php checked( $choice[ 'value' ], $search_field[ 'value' ], true ); ?>> |
|
28 | + <?php echo esc_html( $choice[ 'text' ] ); ?> |
|
29 | 29 | </label> |
30 | 30 | |
31 | 31 | <?php } ?> |
@@ -12,8 +12,8 @@ |
||
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class="gv-search-box"> |
15 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" class="gv-check-radio"> |
|
16 | - <input type="checkbox" name="<?php echo esc_attr( $search_field['name'] ); ?>" value="1" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" <?php checked( '1', $search_field['value'], true ); ?>> |
|
17 | - <?php if( ! gv_empty( $search_field['label'], false ) ) { echo esc_html( $search_field['label'] ); } ?> |
|
15 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" class="gv-check-radio"> |
|
16 | + <input type="checkbox" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="1" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" <?php checked( '1', $search_field[ 'value' ], true ); ?>> |
|
17 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false ) ) { echo esc_html( $search_field[ 'label' ] ); } ?> |
|
18 | 18 | </label> |
19 | 19 | </div> |
20 | 20 | \ No newline at end of file |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | */ |
24 | 24 | do_action( 'gravityview_search_widget_fields_before', $this ); |
25 | 25 | |
26 | - foreach( $this->search_fields as $search_field ) { |
|
26 | + foreach ( $this->search_fields as $search_field ) { |
|
27 | 27 | $gravityview_view->search_field = $search_field; |
28 | - $this->render( 'search-field', $search_field['input'], false ); |
|
28 | + $this->render( 'search-field', $search_field[ 'input' ], false ); |
|
29 | 29 | |
30 | 30 | // show/hide the search button if there are input type fields |
31 | - if( !$has_inputs && $search_field['input'] != 'link' ) { |
|
31 | + if ( ! $has_inputs && $search_field[ 'input' ] != 'link' ) { |
|
32 | 32 | $has_inputs = true; |
33 | 33 | } |
34 | 34 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | do_action( 'gravityview_search_widget_fields_after', $this ); |
41 | 41 | |
42 | - if( $has_inputs ) { ?> |
|
42 | + if ( $has_inputs ) { ?> |
|
43 | 43 | <div class="gv-search-box gv-search-box-submit"> |
44 | 44 | <?php |
45 | 45 |
@@ -622,7 +622,7 @@ |
||
622 | 622 | 'ymd_dot' => 'Y.m.d', |
623 | 623 | ); |
624 | 624 | |
625 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
625 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
626 | 626 | $format = $datepicker[ $field->dateFormat ]; |
627 | 627 | } |
628 | 628 |
@@ -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 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | 'type' => 'radio', |
64 | 64 | 'full_width' => true, |
65 | 65 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
66 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
66 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
67 | 67 | 'value' => 'any', |
68 | 68 | 'class' => 'hide-if-js', |
69 | 69 | 'options' => array( |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
87 | 87 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
88 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
88 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
89 | 89 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
90 | 90 | |
91 | 91 | // ajax - get the searchable fields |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
213 | 213 | $script_source = empty( $script_min ) ? '/source' : ''; |
214 | 214 | |
215 | - 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 ); |
|
215 | + 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 ); |
|
216 | 216 | |
217 | 217 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
218 | 218 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
235 | 235 | */ |
236 | 236 | public function register_no_conflict( $allowed ) { |
237 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
237 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
238 | 238 | return $allowed; |
239 | 239 | } |
240 | 240 | |
@@ -247,24 +247,24 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public static function get_searchable_fields() { |
249 | 249 | |
250 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
250 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
251 | 251 | exit( '0' ); |
252 | 252 | } |
253 | 253 | |
254 | 254 | $form = ''; |
255 | 255 | |
256 | 256 | // Fetch the form for the current View |
257 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
257 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
258 | 258 | |
259 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
259 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
260 | 260 | |
261 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
261 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
262 | 262 | |
263 | - $form = (int) $_POST['formid']; |
|
263 | + $form = (int)$_POST[ 'formid' ]; |
|
264 | 264 | |
265 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
265 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
266 | 266 | |
267 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
267 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
268 | 268 | |
269 | 269 | } |
270 | 270 | |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | ) |
310 | 310 | ); |
311 | 311 | |
312 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
313 | - $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'] ); |
|
312 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
313 | + $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' ] ); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | // Get fields with sub-inputs and no parent |
@@ -332,13 +332,13 @@ discard block |
||
332 | 332 | |
333 | 333 | foreach ( $fields as $id => $field ) { |
334 | 334 | |
335 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
335 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
336 | 336 | continue; |
337 | 337 | } |
338 | 338 | |
339 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
339 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
340 | 340 | |
341 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
341 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | public static function get_search_input_types( $id = '', $field_type = null ) { |
361 | 361 | |
362 | 362 | // @todo - This needs to be improved - many fields have . including products and addresses |
363 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
363 | + if ( false !== strpos( (string)$id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
364 | 364 | $input_type = 'boolean'; // on/off checkbox |
365 | 365 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
366 | 366 | $input_type = 'multi'; //multiselect |
@@ -402,19 +402,19 @@ discard block |
||
402 | 402 | $post_id = 0; |
403 | 403 | |
404 | 404 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
405 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
406 | - $post_id = absint( $widget_args['post_id'] ); |
|
405 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
406 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
407 | 407 | } |
408 | 408 | // We're in the WordPress Widget context, and the base View ID should be used |
409 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
410 | - $post_id = absint( $widget_args['view_id'] ); |
|
409 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
410 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | $args = gravityview_get_permalink_query_args( $post_id ); |
414 | 414 | |
415 | 415 | // Add hidden fields to the search form |
416 | 416 | foreach ( $args as $key => $value ) { |
417 | - $search_fields[] = array( |
|
417 | + $search_fields[ ] = array( |
|
418 | 418 | 'name' => $key, |
419 | 419 | 'input' => 'hidden', |
420 | 420 | 'value' => $value, |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | */ |
436 | 436 | public function filter_entries( $search_criteria ) { |
437 | 437 | |
438 | - if( 'post' === $this->search_method ) { |
|
438 | + if ( 'post' === $this->search_method ) { |
|
439 | 439 | $get = $_POST; |
440 | 440 | } else { |
441 | 441 | $get = $_GET; |
@@ -452,15 +452,15 @@ discard block |
||
452 | 452 | $get = gv_map_deep( $get, 'rawurldecode' ); |
453 | 453 | |
454 | 454 | // add free search |
455 | - if ( ! empty( $get['gv_search'] ) ) { |
|
455 | + if ( ! empty( $get[ 'gv_search' ] ) ) { |
|
456 | 456 | |
457 | 457 | // Search for a piece |
458 | - $words = explode( ' ', $get['gv_search'] ); |
|
458 | + $words = explode( ' ', $get[ 'gv_search' ] ); |
|
459 | 459 | |
460 | 460 | $words = array_filter( $words ); |
461 | 461 | |
462 | 462 | foreach ( $words as $word ) { |
463 | - $search_criteria['field_filters'][] = array( |
|
463 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
464 | 464 | 'key' => null, // The field ID to search |
465 | 465 | 'value' => $word, // The value to search |
466 | 466 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | } |
470 | 470 | |
471 | 471 | //start date & end date |
472 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
473 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
472 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
473 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
474 | 474 | |
475 | 475 | /** |
476 | 476 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -485,16 +485,16 @@ discard block |
||
485 | 485 | /** |
486 | 486 | * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) |
487 | 487 | */ |
488 | - if( !empty( $curr_start ) ) { |
|
489 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
488 | + if ( ! empty( $curr_start ) ) { |
|
489 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
490 | 490 | } |
491 | - if( !empty( $curr_end ) ) { |
|
492 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
491 | + if ( ! empty( $curr_end ) ) { |
|
492 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | // search for a specific entry ID |
496 | 496 | if ( ! empty( $get[ 'gv_id' ] ) ) { |
497 | - $search_criteria['field_filters'][] = array( |
|
497 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
498 | 498 | 'key' => 'id', |
499 | 499 | 'value' => absint( $get[ 'gv_id' ] ), |
500 | 500 | 'operator' => '=', |
@@ -503,36 +503,36 @@ discard block |
||
503 | 503 | |
504 | 504 | // search for a specific Created_by ID |
505 | 505 | if ( ! empty( $get[ 'gv_by' ] ) ) { |
506 | - $search_criteria['field_filters'][] = array( |
|
506 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
507 | 507 | 'key' => 'created_by', |
508 | - 'value' => absint( $get['gv_by'] ), |
|
508 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
509 | 509 | 'operator' => '=', |
510 | 510 | ); |
511 | 511 | } |
512 | 512 | |
513 | 513 | |
514 | 514 | // Get search mode passed in URL |
515 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
515 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
516 | 516 | |
517 | 517 | // get the other search filters |
518 | 518 | foreach ( $get as $key => $value ) { |
519 | 519 | |
520 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
520 | + if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[ 0 ] ) ) ) { |
|
521 | 521 | continue; |
522 | 522 | } |
523 | 523 | |
524 | 524 | // could return simple filter or multiple filters |
525 | 525 | $filter = $this->prepare_field_filter( $key, $value ); |
526 | 526 | |
527 | - if ( isset( $filter[0]['value'] ) ) { |
|
528 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
527 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
528 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
529 | 529 | |
530 | 530 | // if date range type, set search mode to ALL |
531 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
531 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
532 | 532 | $mode = 'all'; |
533 | 533 | } |
534 | - } elseif( !empty( $filter ) ) { |
|
535 | - $search_criteria['field_filters'][] = $filter; |
|
534 | + } elseif ( ! empty( $filter ) ) { |
|
535 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
536 | 536 | } |
537 | 537 | } |
538 | 538 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * @since 1.5.1 |
542 | 542 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
543 | 543 | */ |
544 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
544 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
545 | 545 | |
546 | 546 | do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
547 | 547 | |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | $field_id = str_replace( 'filter_', '', $key ); |
568 | 568 | |
569 | 569 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
570 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
570 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
571 | 571 | $field_id = str_replace( '_', '.', $field_id ); |
572 | 572 | } |
573 | 573 | |
@@ -581,11 +581,11 @@ discard block |
||
581 | 581 | 'value' => $value, |
582 | 582 | ); |
583 | 583 | |
584 | - switch ( $form_field['type'] ) { |
|
584 | + switch ( $form_field[ 'type' ] ) { |
|
585 | 585 | |
586 | 586 | case 'select': |
587 | 587 | case 'radio': |
588 | - $filter['operator'] = 'is'; |
|
588 | + $filter[ 'operator' ] = 'is'; |
|
589 | 589 | break; |
590 | 590 | |
591 | 591 | case 'post_category': |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | |
600 | 600 | foreach ( $value as $val ) { |
601 | 601 | $cat = get_term( $val, 'category' ); |
602 | - $filter[] = array( |
|
602 | + $filter[ ] = array( |
|
603 | 603 | 'key' => $field_id, |
604 | 604 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
605 | 605 | 'operator' => 'is', |
@@ -618,18 +618,18 @@ discard block |
||
618 | 618 | $filter = array(); |
619 | 619 | |
620 | 620 | foreach ( $value as $val ) { |
621 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
621 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | break; |
625 | 625 | |
626 | 626 | case 'checkbox': |
627 | 627 | // convert checkbox on/off into the correct search filter |
628 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
629 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
630 | - if ( $input['id'] == $field_id ) { |
|
631 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
632 | - $filter['operator'] = 'is'; |
|
628 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
629 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
630 | + if ( $input[ 'id' ] == $field_id ) { |
|
631 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
632 | + $filter[ 'operator' ] = 'is'; |
|
633 | 633 | break; |
634 | 634 | } |
635 | 635 | } |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | $filter = array(); |
640 | 640 | |
641 | 641 | foreach ( $value as $val ) { |
642 | - $filter[] = array( |
|
642 | + $filter[ ] = array( |
|
643 | 643 | 'key' => $field_id, |
644 | 644 | 'value' => $val, |
645 | 645 | 'operator' => 'is', |
@@ -660,9 +660,9 @@ discard block |
||
660 | 660 | foreach ( $words as $word ) { |
661 | 661 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
662 | 662 | // Keep the same key for each filter |
663 | - $filter['value'] = $word; |
|
663 | + $filter[ 'value' ] = $word; |
|
664 | 664 | // Add a search for the value |
665 | - $filters[] = $filter; |
|
665 | + $filters[ ] = $filter; |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
@@ -689,19 +689,19 @@ discard block |
||
689 | 689 | * @since 1.16.3 |
690 | 690 | * Safeguard until GF implements '<=' operator |
691 | 691 | */ |
692 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
692 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
693 | 693 | $operator = '<'; |
694 | 694 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
695 | 695 | } |
696 | 696 | |
697 | - $filter[] = array( |
|
697 | + $filter[ ] = array( |
|
698 | 698 | 'key' => $field_id, |
699 | 699 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
700 | 700 | 'operator' => $operator, |
701 | 701 | ); |
702 | 702 | } |
703 | 703 | } else { |
704 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
704 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | break; |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | 'ymd_dot' => 'Y.m.d', |
733 | 733 | ); |
734 | 734 | |
735 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
735 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
736 | 736 | $format = $datepicker[ $field->dateFormat ]; |
737 | 737 | } |
738 | 738 | |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | public function add_template_path( $file_paths ) { |
764 | 764 | |
765 | 765 | // Index 100 is the default GravityView template path. |
766 | - $file_paths[102] = self::$file . 'templates/'; |
|
766 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
767 | 767 | |
768 | 768 | return $file_paths; |
769 | 769 | } |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | $has_date = false; |
783 | 783 | |
784 | 784 | foreach ( $search_fields as $k => $field ) { |
785 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
785 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
786 | 786 | $has_date = true; |
787 | 787 | break; |
788 | 788 | } |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | } |
810 | 810 | |
811 | 811 | // get configured search fields |
812 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
812 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
813 | 813 | |
814 | 814 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
815 | 815 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -824,34 +824,34 @@ discard block |
||
824 | 824 | |
825 | 825 | $updated_field = $this->get_search_filter_details( $updated_field ); |
826 | 826 | |
827 | - switch ( $field['field'] ) { |
|
827 | + switch ( $field[ 'field' ] ) { |
|
828 | 828 | |
829 | 829 | case 'search_all': |
830 | - $updated_field['key'] = 'search_all'; |
|
831 | - $updated_field['input'] = 'search_all'; |
|
832 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
830 | + $updated_field[ 'key' ] = 'search_all'; |
|
831 | + $updated_field[ 'input' ] = 'search_all'; |
|
832 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
833 | 833 | break; |
834 | 834 | |
835 | 835 | case 'entry_date': |
836 | - $updated_field['key'] = 'entry_date'; |
|
837 | - $updated_field['input'] = 'entry_date'; |
|
838 | - $updated_field['value'] = array( |
|
836 | + $updated_field[ 'key' ] = 'entry_date'; |
|
837 | + $updated_field[ 'input' ] = 'entry_date'; |
|
838 | + $updated_field[ 'value' ] = array( |
|
839 | 839 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
840 | 840 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
841 | 841 | ); |
842 | 842 | break; |
843 | 843 | |
844 | 844 | case 'entry_id': |
845 | - $updated_field['key'] = 'entry_id'; |
|
846 | - $updated_field['input'] = 'entry_id'; |
|
847 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
845 | + $updated_field[ 'key' ] = 'entry_id'; |
|
846 | + $updated_field[ 'input' ] = 'entry_id'; |
|
847 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
848 | 848 | break; |
849 | 849 | |
850 | 850 | case 'created_by': |
851 | - $updated_field['key'] = 'created_by'; |
|
852 | - $updated_field['name'] = 'gv_by'; |
|
853 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
854 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
851 | + $updated_field[ 'key' ] = 'created_by'; |
|
852 | + $updated_field[ 'name' ] = 'gv_by'; |
|
853 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
854 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
855 | 855 | break; |
856 | 856 | } |
857 | 857 | |
@@ -869,16 +869,16 @@ discard block |
||
869 | 869 | */ |
870 | 870 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
871 | 871 | |
872 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
872 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
873 | 873 | |
874 | 874 | /** @since 1.14 */ |
875 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
875 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
876 | 876 | |
877 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
877 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
878 | 878 | |
879 | 879 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
880 | 880 | |
881 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
881 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
882 | 882 | |
883 | 883 | if ( $this->has_date_field( $search_fields ) ) { |
884 | 884 | // enqueue datepicker stuff only if needed! |
@@ -900,10 +900,10 @@ discard block |
||
900 | 900 | public static function get_search_class( $custom_class = '' ) { |
901 | 901 | $gravityview_view = GravityView_View::getInstance(); |
902 | 902 | |
903 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
903 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
904 | 904 | |
905 | - if ( ! empty( $custom_class ) ) { |
|
906 | - $search_class .= ' '.$custom_class; |
|
905 | + if ( ! empty( $custom_class ) ) { |
|
906 | + $search_class .= ' ' . $custom_class; |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | /** |
@@ -945,11 +945,11 @@ discard block |
||
945 | 945 | |
946 | 946 | $label = rgget( 'label', $field ); |
947 | 947 | |
948 | - if( '' === $label ) { |
|
948 | + if ( '' === $label ) { |
|
949 | 949 | |
950 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
950 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
951 | 951 | |
952 | - switch( $field['field'] ) { |
|
952 | + switch ( $field[ 'field' ] ) { |
|
953 | 953 | case 'search_all': |
954 | 954 | $label = __( 'Search Entries:', 'gravityview' ); |
955 | 955 | break; |
@@ -961,10 +961,10 @@ discard block |
||
961 | 961 | break; |
962 | 962 | default: |
963 | 963 | // If this is a field input, not a field |
964 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
964 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
965 | 965 | |
966 | 966 | // Get the label for the field in question, which returns an array |
967 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
967 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
968 | 968 | |
969 | 969 | // Get the item with the `label` key |
970 | 970 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1003,32 +1003,32 @@ discard block |
||
1003 | 1003 | $form = $gravityview_view->getForm(); |
1004 | 1004 | |
1005 | 1005 | // for advanced field ids (eg, first name / last name ) |
1006 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1006 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1007 | 1007 | |
1008 | 1008 | // get searched value from $_GET/$_POST (string or array) |
1009 | 1009 | $value = $this->rgget_or_rgpost( $name ); |
1010 | 1010 | |
1011 | 1011 | // get form field details |
1012 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1012 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1013 | 1013 | |
1014 | 1014 | $filter = array( |
1015 | - 'key' => $field['field'], |
|
1015 | + 'key' => $field[ 'field' ], |
|
1016 | 1016 | 'name' => $name, |
1017 | 1017 | 'label' => self::get_field_label( $field, $form_field ), |
1018 | - 'input' => $field['input'], |
|
1018 | + 'input' => $field[ 'input' ], |
|
1019 | 1019 | 'value' => $value, |
1020 | - 'type' => $form_field['type'], |
|
1020 | + 'type' => $form_field[ 'type' ], |
|
1021 | 1021 | ); |
1022 | 1022 | |
1023 | 1023 | // collect choices |
1024 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1025 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1026 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1027 | - $filter['choices'] = $form_field['choices']; |
|
1024 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1025 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1026 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1027 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1031 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1030 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1031 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | return $filter; |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | |
1053 | 1053 | $choices = array(); |
1054 | 1054 | foreach ( $users as $user ) { |
1055 | - $choices[] = array( |
|
1055 | + $choices[ ] = array( |
|
1056 | 1056 | 'value' => $user->ID, |
1057 | 1057 | 'text' => $user->display_name, |
1058 | 1058 | ); |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | */ |
1108 | 1108 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1109 | 1109 | |
1110 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1110 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1111 | 1111 | |
1112 | 1112 | return $js_dependencies; |
1113 | 1113 | } |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | 'isRTL' => is_rtl(), |
1152 | 1152 | ), $view_data ); |
1153 | 1153 | |
1154 | - $localizations['datepicker'] = $datepicker_settings; |
|
1154 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1155 | 1155 | |
1156 | 1156 | return $localizations; |
1157 | 1157 | |
@@ -1180,7 +1180,7 @@ discard block |
||
1180 | 1180 | * @return void |
1181 | 1181 | */ |
1182 | 1182 | private function maybe_enqueue_flexibility() { |
1183 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1183 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1184 | 1184 | wp_enqueue_script( 'gv-flexibility' ); |
1185 | 1185 | } |
1186 | 1186 | } |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1203 | 1203 | |
1204 | 1204 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1205 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1205 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1206 | 1206 | |
1207 | 1207 | /** |
1208 | 1208 | * @filter `gravityview_search_datepicker_class` |