@@ -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 | |
@@ -386,14 +386,14 @@ |
||
| 386 | 386 | $curr_start = esc_attr( rgget( 'gv_start' ) ); |
| 387 | 387 | $curr_end = esc_attr( rgget( 'gv_end' ) ); |
| 388 | 388 | |
| 389 | - /** |
|
| 390 | - * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
| 391 | - * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
| 392 | - * @since 1.12 |
|
| 393 | - * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
| 394 | - * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
| 395 | - */ |
|
| 396 | - $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
| 389 | + /** |
|
| 390 | + * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
| 391 | + * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
| 392 | + * @since 1.12 |
|
| 393 | + * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
| 394 | + * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
| 395 | + */ |
|
| 396 | + $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
| 397 | 397 | |
| 398 | 398 | |
| 399 | 399 | /** |
@@ -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 |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 150 | 150 | $script_source = empty( $script_min ) ? '/source' : ''; |
| 151 | 151 | |
| 152 | - 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 ); |
|
| 152 | + 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 ); |
|
| 153 | 153 | |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
| 205 | 205 | */ |
| 206 | 206 | public function register_no_conflict( $allowed ) { |
| 207 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
| 207 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
| 208 | 208 | return $allowed; |
| 209 | 209 | } |
| 210 | 210 | |
@@ -217,24 +217,24 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public static function get_searchable_fields() { |
| 219 | 219 | |
| 220 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 220 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 221 | 221 | exit( '0' ); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | $form = ''; |
| 225 | 225 | |
| 226 | 226 | // Fetch the form for the current View |
| 227 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
| 227 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
| 228 | 228 | |
| 229 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 229 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
| 230 | 230 | |
| 231 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
| 231 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
| 232 | 232 | |
| 233 | - $form = (int) $_POST['formid']; |
|
| 233 | + $form = (int)$_POST[ 'formid' ]; |
|
| 234 | 234 | |
| 235 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 235 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 236 | 236 | |
| 237 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 237 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 238 | 238 | |
| 239 | 239 | } |
| 240 | 240 | |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | ) |
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 283 | - $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'] ); |
|
| 282 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 283 | + $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' ] ); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Get fields with sub-inputs and no parent |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | foreach ( $fields as $id => $field ) { |
| 304 | 304 | |
| 305 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 305 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 306 | 306 | continue; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
| 309 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
| 310 | 310 | |
| 311 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
| 311 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | public static function get_search_input_types( $id = '', $field_type = null ) { |
| 331 | 331 | |
| 332 | 332 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 333 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
| 333 | + if ( false !== strpos( (string)$id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
| 334 | 334 | $input_type = 'boolean'; // on/off checkbox |
| 335 | 335 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
| 336 | 336 | $input_type = 'multi'; //multiselect |
@@ -372,19 +372,19 @@ discard block |
||
| 372 | 372 | $post_id = 0; |
| 373 | 373 | |
| 374 | 374 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 375 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 376 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 375 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
| 376 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
| 377 | 377 | } |
| 378 | 378 | // We're in the WordPress Widget context, and the base View ID should be used |
| 379 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 380 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 379 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
| 380 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | $args = gravityview_get_permalink_query_args( $post_id ); |
| 384 | 384 | |
| 385 | 385 | // Add hidden fields to the search form |
| 386 | 386 | foreach ( $args as $key => $value ) { |
| 387 | - $search_fields[] = array( |
|
| 387 | + $search_fields[ ] = array( |
|
| 388 | 388 | 'name' => $key, |
| 389 | 389 | 'input' => 'hidden', |
| 390 | 390 | 'value' => $value, |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | public function filter_entries( $search_criteria ) { |
| 407 | 407 | |
| 408 | - if( 'post' === $this->search_method ) { |
|
| 408 | + if ( 'post' === $this->search_method ) { |
|
| 409 | 409 | $get = $_POST; |
| 410 | 410 | } else { |
| 411 | 411 | $get = $_GET; |
@@ -422,15 +422,15 @@ discard block |
||
| 422 | 422 | $get = gv_map_deep( $get, 'rawurldecode' ); |
| 423 | 423 | |
| 424 | 424 | // add free search |
| 425 | - if ( ! empty( $get['gv_search'] ) ) { |
|
| 425 | + if ( ! empty( $get[ 'gv_search' ] ) ) { |
|
| 426 | 426 | |
| 427 | 427 | // Search for a piece |
| 428 | - $words = explode( ' ', $get['gv_search'] ); |
|
| 428 | + $words = explode( ' ', $get[ 'gv_search' ] ); |
|
| 429 | 429 | |
| 430 | 430 | $words = array_filter( $words ); |
| 431 | 431 | |
| 432 | 432 | foreach ( $words as $word ) { |
| 433 | - $search_criteria['field_filters'][] = array( |
|
| 433 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 434 | 434 | 'key' => null, // The field ID to search |
| 435 | 435 | 'value' => $word, // The value to search |
| 436 | 436 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | //start date & end date |
| 442 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
| 443 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
| 442 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
| 443 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | 446 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -455,16 +455,16 @@ discard block |
||
| 455 | 455 | /** |
| 456 | 456 | * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) |
| 457 | 457 | */ |
| 458 | - if( !empty( $curr_start ) ) { |
|
| 459 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 458 | + if ( ! empty( $curr_start ) ) { |
|
| 459 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 460 | 460 | } |
| 461 | - if( !empty( $curr_end ) ) { |
|
| 462 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 461 | + if ( ! empty( $curr_end ) ) { |
|
| 462 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // search for a specific entry ID |
| 466 | 466 | if ( ! empty( $get[ 'gv_id' ] ) ) { |
| 467 | - $search_criteria['field_filters'][] = array( |
|
| 467 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 468 | 468 | 'key' => 'id', |
| 469 | 469 | 'value' => absint( $get[ 'gv_id' ] ), |
| 470 | 470 | 'operator' => '=', |
@@ -473,36 +473,36 @@ discard block |
||
| 473 | 473 | |
| 474 | 474 | // search for a specific Created_by ID |
| 475 | 475 | if ( ! empty( $get[ 'gv_by' ] ) ) { |
| 476 | - $search_criteria['field_filters'][] = array( |
|
| 476 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 477 | 477 | 'key' => 'created_by', |
| 478 | - 'value' => absint( $get['gv_by'] ), |
|
| 478 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
| 479 | 479 | 'operator' => '=', |
| 480 | 480 | ); |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | |
| 484 | 484 | // Get search mode passed in URL |
| 485 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
| 485 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
| 486 | 486 | |
| 487 | 487 | // get the other search filters |
| 488 | 488 | foreach ( $get as $key => $value ) { |
| 489 | 489 | |
| 490 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
| 490 | + if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[ 0 ] ) ) ) { |
|
| 491 | 491 | continue; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | // could return simple filter or multiple filters |
| 495 | 495 | $filter = $this->prepare_field_filter( $key, $value ); |
| 496 | 496 | |
| 497 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 498 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 497 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
| 498 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
| 499 | 499 | |
| 500 | 500 | // if date range type, set search mode to ALL |
| 501 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 501 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 502 | 502 | $mode = 'all'; |
| 503 | 503 | } |
| 504 | - } elseif( !empty( $filter ) ) { |
|
| 505 | - $search_criteria['field_filters'][] = $filter; |
|
| 504 | + } elseif ( ! empty( $filter ) ) { |
|
| 505 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | * @since 1.5.1 |
| 512 | 512 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
| 513 | 513 | */ |
| 514 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 514 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 515 | 515 | |
| 516 | 516 | do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
| 517 | 517 | |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | $field_id = str_replace( 'filter_', '', $key ); |
| 538 | 538 | |
| 539 | 539 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
| 540 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
| 540 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
| 541 | 541 | $field_id = str_replace( '_', '.', $field_id ); |
| 542 | 542 | } |
| 543 | 543 | |
@@ -551,11 +551,11 @@ discard block |
||
| 551 | 551 | 'value' => $value, |
| 552 | 552 | ); |
| 553 | 553 | |
| 554 | - switch ( $form_field['type'] ) { |
|
| 554 | + switch ( $form_field[ 'type' ] ) { |
|
| 555 | 555 | |
| 556 | 556 | case 'select': |
| 557 | 557 | case 'radio': |
| 558 | - $filter['operator'] = 'is'; |
|
| 558 | + $filter[ 'operator' ] = 'is'; |
|
| 559 | 559 | break; |
| 560 | 560 | |
| 561 | 561 | case 'post_category': |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | |
| 570 | 570 | foreach ( $value as $val ) { |
| 571 | 571 | $cat = get_term( $val, 'category' ); |
| 572 | - $filter[] = array( |
|
| 572 | + $filter[ ] = array( |
|
| 573 | 573 | 'key' => $field_id, |
| 574 | 574 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 575 | 575 | 'operator' => 'is', |
@@ -588,18 +588,18 @@ discard block |
||
| 588 | 588 | $filter = array(); |
| 589 | 589 | |
| 590 | 590 | foreach ( $value as $val ) { |
| 591 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
| 591 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | break; |
| 595 | 595 | |
| 596 | 596 | case 'checkbox': |
| 597 | 597 | // convert checkbox on/off into the correct search filter |
| 598 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
| 599 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
| 600 | - if ( $input['id'] == $field_id ) { |
|
| 601 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
| 602 | - $filter['operator'] = 'is'; |
|
| 598 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
| 599 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
| 600 | + if ( $input[ 'id' ] == $field_id ) { |
|
| 601 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
| 602 | + $filter[ 'operator' ] = 'is'; |
|
| 603 | 603 | break; |
| 604 | 604 | } |
| 605 | 605 | } |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | $filter = array(); |
| 610 | 610 | |
| 611 | 611 | foreach ( $value as $val ) { |
| 612 | - $filter[] = array( |
|
| 612 | + $filter[ ] = array( |
|
| 613 | 613 | 'key' => $field_id, |
| 614 | 614 | 'value' => $val, |
| 615 | 615 | 'operator' => 'is', |
@@ -630,9 +630,9 @@ discard block |
||
| 630 | 630 | foreach ( $words as $word ) { |
| 631 | 631 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 632 | 632 | // Keep the same key for each filter |
| 633 | - $filter['value'] = $word; |
|
| 633 | + $filter[ 'value' ] = $word; |
|
| 634 | 634 | // Add a search for the value |
| 635 | - $filters[] = $filter; |
|
| 635 | + $filters[ ] = $filter; |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | |
@@ -659,19 +659,19 @@ discard block |
||
| 659 | 659 | * @since 1.16.3 |
| 660 | 660 | * Safeguard until GF implements '<=' operator |
| 661 | 661 | */ |
| 662 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 662 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 663 | 663 | $operator = '<'; |
| 664 | 664 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - $filter[] = array( |
|
| 667 | + $filter[ ] = array( |
|
| 668 | 668 | 'key' => $field_id, |
| 669 | 669 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
| 670 | 670 | 'operator' => $operator, |
| 671 | 671 | ); |
| 672 | 672 | } |
| 673 | 673 | } else { |
| 674 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 674 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | break; |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | 'ymd_dot' => 'Y.m.d', |
| 703 | 703 | ); |
| 704 | 704 | |
| 705 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 705 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 706 | 706 | $format = $datepicker[ $field->dateFormat ]; |
| 707 | 707 | } |
| 708 | 708 | |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | public function add_template_path( $file_paths ) { |
| 734 | 734 | |
| 735 | 735 | // Index 100 is the default GravityView template path. |
| 736 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 736 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 737 | 737 | |
| 738 | 738 | return $file_paths; |
| 739 | 739 | } |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // get configured search fields |
| 759 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 759 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 760 | 760 | |
| 761 | 761 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 762 | 762 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -770,26 +770,26 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | $updated_field = $field; |
| 772 | 772 | |
| 773 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
| 773 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range' ) ) ) { |
|
| 774 | 774 | $has_date = true; |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | $updated_field = $this->get_search_filter_details( $updated_field ); |
| 778 | 778 | |
| 779 | - error_log("Field:Field = " . print_r($field['field'], true)); |
|
| 779 | + error_log( "Field:Field = " . print_r( $field[ 'field' ], true ) ); |
|
| 780 | 780 | |
| 781 | - switch ( $field['field'] ) { |
|
| 781 | + switch ( $field[ 'field' ] ) { |
|
| 782 | 782 | |
| 783 | 783 | case 'search_all': |
| 784 | - $updated_field['key'] = 'search_all'; |
|
| 785 | - $updated_field['input'] = 'search_all'; |
|
| 786 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 784 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 785 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 786 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 787 | 787 | break; |
| 788 | 788 | |
| 789 | 789 | case 'entry_date': |
| 790 | - $updated_field['key'] = 'entry_date'; |
|
| 791 | - $updated_field['input'] = 'entry_date'; |
|
| 792 | - $updated_field['value'] = array( |
|
| 790 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 791 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 792 | + $updated_field[ 'value' ] = array( |
|
| 793 | 793 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 794 | 794 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 795 | 795 | ); |
@@ -797,16 +797,16 @@ discard block |
||
| 797 | 797 | break; |
| 798 | 798 | |
| 799 | 799 | case 'entry_id': |
| 800 | - $updated_field['key'] = 'entry_id'; |
|
| 801 | - $updated_field['input'] = 'entry_id'; |
|
| 802 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 800 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 801 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 802 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 803 | 803 | break; |
| 804 | 804 | |
| 805 | 805 | case 'created_by': |
| 806 | - $updated_field['key'] = 'created_by'; |
|
| 807 | - $updated_field['name'] = 'gv_by'; |
|
| 808 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 809 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
| 806 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 807 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 808 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 809 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
| 810 | 810 | break; |
| 811 | 811 | } |
| 812 | 812 | |
@@ -824,16 +824,16 @@ discard block |
||
| 824 | 824 | */ |
| 825 | 825 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
| 826 | 826 | |
| 827 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 827 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 828 | 828 | |
| 829 | 829 | /** @since 1.14 */ |
| 830 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 830 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 831 | 831 | |
| 832 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 832 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 833 | 833 | |
| 834 | 834 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 835 | 835 | |
| 836 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 836 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 837 | 837 | |
| 838 | 838 | if ( $has_date ) { |
| 839 | 839 | // enqueue datepicker stuff only if needed! |
@@ -855,10 +855,10 @@ discard block |
||
| 855 | 855 | public static function get_search_class( $custom_class = '' ) { |
| 856 | 856 | $gravityview_view = GravityView_View::getInstance(); |
| 857 | 857 | |
| 858 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 858 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 859 | 859 | |
| 860 | - if ( ! empty( $custom_class ) ) { |
|
| 861 | - $search_class .= ' '.$custom_class; |
|
| 860 | + if ( ! empty( $custom_class ) ) { |
|
| 861 | + $search_class .= ' ' . $custom_class; |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | /** |
@@ -900,11 +900,11 @@ discard block |
||
| 900 | 900 | |
| 901 | 901 | $label = rgget( 'label', $field ); |
| 902 | 902 | |
| 903 | - if( '' === $label ) { |
|
| 903 | + if ( '' === $label ) { |
|
| 904 | 904 | |
| 905 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 905 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 906 | 906 | |
| 907 | - switch( $field['field'] ) { |
|
| 907 | + switch ( $field[ 'field' ] ) { |
|
| 908 | 908 | case 'search_all': |
| 909 | 909 | $label = __( 'Search Entries:', 'gravityview' ); |
| 910 | 910 | break; |
@@ -916,10 +916,10 @@ discard block |
||
| 916 | 916 | break; |
| 917 | 917 | default: |
| 918 | 918 | // If this is a field input, not a field |
| 919 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 919 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 920 | 920 | |
| 921 | 921 | // Get the label for the field in question, which returns an array |
| 922 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 922 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 923 | 923 | |
| 924 | 924 | // Get the item with the `label` key |
| 925 | 925 | $values = wp_list_pluck( $items, 'label' ); |
@@ -958,32 +958,32 @@ discard block |
||
| 958 | 958 | $form = $gravityview_view->getForm(); |
| 959 | 959 | |
| 960 | 960 | // for advanced field ids (eg, first name / last name ) |
| 961 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 961 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 962 | 962 | |
| 963 | 963 | // get searched value from $_GET/$_POST (string or array) |
| 964 | 964 | $value = $this->rgget_or_rgpost( $name ); |
| 965 | 965 | |
| 966 | 966 | // get form field details |
| 967 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 967 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 968 | 968 | |
| 969 | 969 | $filter = array( |
| 970 | - 'key' => $field['field'], |
|
| 970 | + 'key' => $field[ 'field' ], |
|
| 971 | 971 | 'name' => $name, |
| 972 | 972 | 'label' => self::get_field_label( $field, $form_field ), |
| 973 | - 'input' => $field['input'], |
|
| 973 | + 'input' => $field[ 'input' ], |
|
| 974 | 974 | 'value' => $value, |
| 975 | - 'type' => $form_field['type'], |
|
| 975 | + 'type' => $form_field[ 'type' ], |
|
| 976 | 976 | ); |
| 977 | 977 | |
| 978 | 978 | // collect choices |
| 979 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 980 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 981 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 982 | - $filter['choices'] = $form_field['choices']; |
|
| 979 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 980 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 981 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 982 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 986 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 985 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 986 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | return $filter; |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | |
| 1008 | 1008 | $choices = array(); |
| 1009 | 1009 | foreach ( $users as $user ) { |
| 1010 | - $choices[] = array( |
|
| 1010 | + $choices[ ] = array( |
|
| 1011 | 1011 | 'value' => $user->ID, |
| 1012 | 1012 | 'text' => $user->display_name, |
| 1013 | 1013 | ); |
@@ -1062,7 +1062,7 @@ discard block |
||
| 1062 | 1062 | */ |
| 1063 | 1063 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1064 | 1064 | |
| 1065 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1065 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1066 | 1066 | |
| 1067 | 1067 | return $js_dependencies; |
| 1068 | 1068 | } |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | 'isRTL' => is_rtl(), |
| 1107 | 1107 | ), $view_data ); |
| 1108 | 1108 | |
| 1109 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1109 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1110 | 1110 | |
| 1111 | 1111 | return $localizations; |
| 1112 | 1112 | |
@@ -1135,7 +1135,7 @@ discard block |
||
| 1135 | 1135 | * @return void |
| 1136 | 1136 | */ |
| 1137 | 1137 | private function maybe_enqueue_flexibility() { |
| 1138 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1138 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 1139 | 1139 | wp_enqueue_script( 'gv-flexibility' ); |
| 1140 | 1140 | } |
| 1141 | 1141 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 1158 | 1158 | |
| 1159 | 1159 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1160 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1160 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1161 | 1161 | |
| 1162 | 1162 | /** |
| 1163 | 1163 | * @filter `gravityview_search_datepicker_class` |