@@ -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 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
| 362 | 362 | |
| 363 | 363 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 364 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 364 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 365 | 365 | $input_type = 'boolean'; // on/off checkbox |
| 366 | 366 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
| 367 | 367 | $input_type = 'multi'; //multiselect |
@@ -405,19 +405,19 @@ discard block |
||
| 405 | 405 | $post_id = 0; |
| 406 | 406 | |
| 407 | 407 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 408 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 409 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 408 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
| 409 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
| 410 | 410 | } |
| 411 | 411 | // We're in the WordPress Widget context, and the base View ID should be used |
| 412 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 413 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 412 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
| 413 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | $args = gravityview_get_permalink_query_args( $post_id ); |
| 417 | 417 | |
| 418 | 418 | // Add hidden fields to the search form |
| 419 | 419 | foreach ( $args as $key => $value ) { |
| 420 | - $search_fields[] = array( |
|
| 420 | + $search_fields[ ] = array( |
|
| 421 | 421 | 'name' => $key, |
| 422 | 422 | 'input' => 'hidden', |
| 423 | 423 | 'value' => $value, |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | */ |
| 439 | 439 | public function filter_entries( $search_criteria ) { |
| 440 | 440 | |
| 441 | - if( 'post' === $this->search_method ) { |
|
| 441 | + if ( 'post' === $this->search_method ) { |
|
| 442 | 442 | $get = $_POST; |
| 443 | 443 | } else { |
| 444 | 444 | $get = $_GET; |
@@ -455,15 +455,15 @@ discard block |
||
| 455 | 455 | $get = gv_map_deep( $get, 'rawurldecode' ); |
| 456 | 456 | |
| 457 | 457 | // add free search |
| 458 | - if ( ! empty( $get['gv_search'] ) ) { |
|
| 458 | + if ( ! empty( $get[ 'gv_search' ] ) ) { |
|
| 459 | 459 | |
| 460 | 460 | // Search for a piece |
| 461 | - $words = explode( ' ', $get['gv_search'] ); |
|
| 461 | + $words = explode( ' ', $get[ 'gv_search' ] ); |
|
| 462 | 462 | |
| 463 | 463 | $words = array_filter( $words ); |
| 464 | 464 | |
| 465 | 465 | foreach ( $words as $word ) { |
| 466 | - $search_criteria['field_filters'][] = array( |
|
| 466 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 467 | 467 | 'key' => null, // The field ID to search |
| 468 | 468 | 'value' => $word, // The value to search |
| 469 | 469 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | //start date & end date |
| 475 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
| 476 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
| 475 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
| 476 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
| 477 | 477 | |
| 478 | 478 | /** |
| 479 | 479 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -488,16 +488,16 @@ discard block |
||
| 488 | 488 | /** |
| 489 | 489 | * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) |
| 490 | 490 | */ |
| 491 | - if( !empty( $curr_start ) ) { |
|
| 492 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 491 | + if ( ! empty( $curr_start ) ) { |
|
| 492 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 493 | 493 | } |
| 494 | - if( !empty( $curr_end ) ) { |
|
| 495 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 494 | + if ( ! empty( $curr_end ) ) { |
|
| 495 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | // search for a specific entry ID |
| 499 | 499 | if ( ! empty( $get[ 'gv_id' ] ) ) { |
| 500 | - $search_criteria['field_filters'][] = array( |
|
| 500 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 501 | 501 | 'key' => 'id', |
| 502 | 502 | 'value' => absint( $get[ 'gv_id' ] ), |
| 503 | 503 | 'operator' => '=', |
@@ -506,36 +506,36 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | // search for a specific Created_by ID |
| 508 | 508 | if ( ! empty( $get[ 'gv_by' ] ) ) { |
| 509 | - $search_criteria['field_filters'][] = array( |
|
| 509 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 510 | 510 | 'key' => 'created_by', |
| 511 | - 'value' => absint( $get['gv_by'] ), |
|
| 511 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
| 512 | 512 | 'operator' => '=', |
| 513 | 513 | ); |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | |
| 517 | 517 | // Get search mode passed in URL |
| 518 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
| 518 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
| 519 | 519 | |
| 520 | 520 | // get the other search filters |
| 521 | 521 | foreach ( $get as $key => $value ) { |
| 522 | 522 | |
| 523 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
| 523 | + if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[ 0 ] ) ) ) { |
|
| 524 | 524 | continue; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | // could return simple filter or multiple filters |
| 528 | 528 | $filter = $this->prepare_field_filter( $key, $value ); |
| 529 | 529 | |
| 530 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 531 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 530 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
| 531 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
| 532 | 532 | |
| 533 | 533 | // if date range type, set search mode to ALL |
| 534 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 534 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 535 | 535 | $mode = 'all'; |
| 536 | 536 | } |
| 537 | - } elseif( !empty( $filter ) ) { |
|
| 538 | - $search_criteria['field_filters'][] = $filter; |
|
| 537 | + } elseif ( ! empty( $filter ) ) { |
|
| 538 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
| 539 | 539 | } |
| 540 | 540 | } |
| 541 | 541 | |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | * @since 1.5.1 |
| 545 | 545 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
| 546 | 546 | */ |
| 547 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 547 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 548 | 548 | |
| 549 | 549 | do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
| 550 | 550 | |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | $field_id = str_replace( 'filter_', '', $key ); |
| 571 | 571 | |
| 572 | 572 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
| 573 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
| 573 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
| 574 | 574 | $field_id = str_replace( '_', '.', $field_id ); |
| 575 | 575 | } |
| 576 | 576 | |
@@ -584,11 +584,11 @@ discard block |
||
| 584 | 584 | 'value' => $value, |
| 585 | 585 | ); |
| 586 | 586 | |
| 587 | - switch ( $form_field['type'] ) { |
|
| 587 | + switch ( $form_field[ 'type' ] ) { |
|
| 588 | 588 | |
| 589 | 589 | case 'select': |
| 590 | 590 | case 'radio': |
| 591 | - $filter['operator'] = 'is'; |
|
| 591 | + $filter[ 'operator' ] = 'is'; |
|
| 592 | 592 | break; |
| 593 | 593 | |
| 594 | 594 | case 'post_category': |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | foreach ( $value as $val ) { |
| 604 | 604 | $cat = get_term( $val, 'category' ); |
| 605 | - $filter[] = array( |
|
| 605 | + $filter[ ] = array( |
|
| 606 | 606 | 'key' => $field_id, |
| 607 | 607 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 608 | 608 | 'operator' => 'is', |
@@ -621,18 +621,18 @@ discard block |
||
| 621 | 621 | $filter = array(); |
| 622 | 622 | |
| 623 | 623 | foreach ( $value as $val ) { |
| 624 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
| 624 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | break; |
| 628 | 628 | |
| 629 | 629 | case 'checkbox': |
| 630 | 630 | // convert checkbox on/off into the correct search filter |
| 631 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
| 632 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
| 633 | - if ( $input['id'] == $field_id ) { |
|
| 634 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
| 635 | - $filter['operator'] = 'is'; |
|
| 631 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
| 632 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
| 633 | + if ( $input[ 'id' ] == $field_id ) { |
|
| 634 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
| 635 | + $filter[ 'operator' ] = 'is'; |
|
| 636 | 636 | break; |
| 637 | 637 | } |
| 638 | 638 | } |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | $filter = array(); |
| 643 | 643 | |
| 644 | 644 | foreach ( $value as $val ) { |
| 645 | - $filter[] = array( |
|
| 645 | + $filter[ ] = array( |
|
| 646 | 646 | 'key' => $field_id, |
| 647 | 647 | 'value' => $val, |
| 648 | 648 | 'operator' => 'is', |
@@ -663,9 +663,9 @@ discard block |
||
| 663 | 663 | foreach ( $words as $word ) { |
| 664 | 664 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 665 | 665 | // Keep the same key for each filter |
| 666 | - $filter['value'] = $word; |
|
| 666 | + $filter[ 'value' ] = $word; |
|
| 667 | 667 | // Add a search for the value |
| 668 | - $filters[] = $filter; |
|
| 668 | + $filters[ ] = $filter; |
|
| 669 | 669 | } |
| 670 | 670 | } |
| 671 | 671 | |
@@ -692,19 +692,19 @@ discard block |
||
| 692 | 692 | * @since 1.16.3 |
| 693 | 693 | * Safeguard until GF implements '<=' operator |
| 694 | 694 | */ |
| 695 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 695 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 696 | 696 | $operator = '<'; |
| 697 | 697 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - $filter[] = array( |
|
| 700 | + $filter[ ] = array( |
|
| 701 | 701 | 'key' => $field_id, |
| 702 | 702 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
| 703 | 703 | 'operator' => $operator, |
| 704 | 704 | ); |
| 705 | 705 | } |
| 706 | 706 | } else { |
| 707 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 707 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | break; |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | 'ymd_dot' => 'Y.m.d', |
| 736 | 736 | ); |
| 737 | 737 | |
| 738 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 738 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 739 | 739 | $format = $datepicker[ $field->dateFormat ]; |
| 740 | 740 | } |
| 741 | 741 | |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | public function add_template_path( $file_paths ) { |
| 767 | 767 | |
| 768 | 768 | // Index 100 is the default GravityView template path. |
| 769 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 769 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 770 | 770 | |
| 771 | 771 | return $file_paths; |
| 772 | 772 | } |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | $has_date = false; |
| 786 | 786 | |
| 787 | 787 | foreach ( $search_fields as $k => $field ) { |
| 788 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 788 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 789 | 789 | $has_date = true; |
| 790 | 790 | break; |
| 791 | 791 | } |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | // get configured search fields |
| 815 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 815 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 816 | 816 | |
| 817 | 817 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 818 | 818 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -827,34 +827,34 @@ discard block |
||
| 827 | 827 | |
| 828 | 828 | $updated_field = $this->get_search_filter_details( $updated_field ); |
| 829 | 829 | |
| 830 | - switch ( $field['field'] ) { |
|
| 830 | + switch ( $field[ 'field' ] ) { |
|
| 831 | 831 | |
| 832 | 832 | case 'search_all': |
| 833 | - $updated_field['key'] = 'search_all'; |
|
| 834 | - $updated_field['input'] = 'search_all'; |
|
| 835 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 833 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 834 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 835 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 836 | 836 | break; |
| 837 | 837 | |
| 838 | 838 | case 'entry_date': |
| 839 | - $updated_field['key'] = 'entry_date'; |
|
| 840 | - $updated_field['input'] = 'entry_date'; |
|
| 841 | - $updated_field['value'] = array( |
|
| 839 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 840 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 841 | + $updated_field[ 'value' ] = array( |
|
| 842 | 842 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 843 | 843 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 844 | 844 | ); |
| 845 | 845 | break; |
| 846 | 846 | |
| 847 | 847 | case 'entry_id': |
| 848 | - $updated_field['key'] = 'entry_id'; |
|
| 849 | - $updated_field['input'] = 'entry_id'; |
|
| 850 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 848 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 849 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 850 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 851 | 851 | break; |
| 852 | 852 | |
| 853 | 853 | case 'created_by': |
| 854 | - $updated_field['key'] = 'created_by'; |
|
| 855 | - $updated_field['name'] = 'gv_by'; |
|
| 856 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 857 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
| 854 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 855 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 856 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 857 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
| 858 | 858 | break; |
| 859 | 859 | } |
| 860 | 860 | |
@@ -872,16 +872,16 @@ discard block |
||
| 872 | 872 | */ |
| 873 | 873 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
| 874 | 874 | |
| 875 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 875 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 876 | 876 | |
| 877 | 877 | /** @since 1.14 */ |
| 878 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 878 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 879 | 879 | |
| 880 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 880 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 881 | 881 | |
| 882 | 882 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 883 | 883 | |
| 884 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 884 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 885 | 885 | |
| 886 | 886 | if ( $this->has_date_field( $search_fields ) ) { |
| 887 | 887 | // enqueue datepicker stuff only if needed! |
@@ -903,10 +903,10 @@ discard block |
||
| 903 | 903 | public static function get_search_class( $custom_class = '' ) { |
| 904 | 904 | $gravityview_view = GravityView_View::getInstance(); |
| 905 | 905 | |
| 906 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 906 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 907 | 907 | |
| 908 | - if ( ! empty( $custom_class ) ) { |
|
| 909 | - $search_class .= ' '.$custom_class; |
|
| 908 | + if ( ! empty( $custom_class ) ) { |
|
| 909 | + $search_class .= ' ' . $custom_class; |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | /** |
@@ -948,11 +948,11 @@ discard block |
||
| 948 | 948 | |
| 949 | 949 | $label = rgget( 'label', $field ); |
| 950 | 950 | |
| 951 | - if( '' === $label ) { |
|
| 951 | + if ( '' === $label ) { |
|
| 952 | 952 | |
| 953 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 953 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 954 | 954 | |
| 955 | - switch( $field['field'] ) { |
|
| 955 | + switch ( $field[ 'field' ] ) { |
|
| 956 | 956 | case 'search_all': |
| 957 | 957 | $label = __( 'Search Entries:', 'gravityview' ); |
| 958 | 958 | break; |
@@ -964,10 +964,10 @@ discard block |
||
| 964 | 964 | break; |
| 965 | 965 | default: |
| 966 | 966 | // If this is a field input, not a field |
| 967 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 967 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 968 | 968 | |
| 969 | 969 | // Get the label for the field in question, which returns an array |
| 970 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 970 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 971 | 971 | |
| 972 | 972 | // Get the item with the `label` key |
| 973 | 973 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1006,32 +1006,32 @@ discard block |
||
| 1006 | 1006 | $form = $gravityview_view->getForm(); |
| 1007 | 1007 | |
| 1008 | 1008 | // for advanced field ids (eg, first name / last name ) |
| 1009 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 1009 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 1010 | 1010 | |
| 1011 | 1011 | // get searched value from $_GET/$_POST (string or array) |
| 1012 | 1012 | $value = $this->rgget_or_rgpost( $name ); |
| 1013 | 1013 | |
| 1014 | 1014 | // get form field details |
| 1015 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 1015 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 1016 | 1016 | |
| 1017 | 1017 | $filter = array( |
| 1018 | - 'key' => $field['field'], |
|
| 1018 | + 'key' => $field[ 'field' ], |
|
| 1019 | 1019 | 'name' => $name, |
| 1020 | 1020 | 'label' => self::get_field_label( $field, $form_field ), |
| 1021 | - 'input' => $field['input'], |
|
| 1021 | + 'input' => $field[ 'input' ], |
|
| 1022 | 1022 | 'value' => $value, |
| 1023 | - 'type' => $form_field['type'], |
|
| 1023 | + 'type' => $form_field[ 'type' ], |
|
| 1024 | 1024 | ); |
| 1025 | 1025 | |
| 1026 | 1026 | // collect choices |
| 1027 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 1028 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 1029 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 1030 | - $filter['choices'] = $form_field['choices']; |
|
| 1027 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 1028 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 1029 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 1030 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 1034 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 1033 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 1034 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | return $filter; |
@@ -1055,7 +1055,7 @@ discard block |
||
| 1055 | 1055 | |
| 1056 | 1056 | $choices = array(); |
| 1057 | 1057 | foreach ( $users as $user ) { |
| 1058 | - $choices[] = array( |
|
| 1058 | + $choices[ ] = array( |
|
| 1059 | 1059 | 'value' => $user->ID, |
| 1060 | 1060 | 'text' => $user->display_name, |
| 1061 | 1061 | ); |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | */ |
| 1111 | 1111 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1112 | 1112 | |
| 1113 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1113 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1114 | 1114 | |
| 1115 | 1115 | return $js_dependencies; |
| 1116 | 1116 | } |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | 'isRTL' => is_rtl(), |
| 1155 | 1155 | ), $view_data ); |
| 1156 | 1156 | |
| 1157 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1157 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1158 | 1158 | |
| 1159 | 1159 | return $localizations; |
| 1160 | 1160 | |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | * @return void |
| 1184 | 1184 | */ |
| 1185 | 1185 | private function maybe_enqueue_flexibility() { |
| 1186 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1186 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 1187 | 1187 | wp_enqueue_script( 'gv-flexibility' ); |
| 1188 | 1188 | } |
| 1189 | 1189 | } |
@@ -1205,7 +1205,7 @@ discard block |
||
| 1205 | 1205 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 1206 | 1206 | |
| 1207 | 1207 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1208 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1208 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1209 | 1209 | |
| 1210 | 1210 | /** |
| 1211 | 1211 | * @filter `gravityview_search_datepicker_class` |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | function __construct() { |
| 19 | 19 | |
| 20 | - $this->widget_description = __('Insert custom text or HTML as a widget', 'gravityview' ); |
|
| 20 | + $this->widget_description = __( 'Insert custom text or HTML as a widget', 'gravityview' ); |
|
| 21 | 21 | |
| 22 | 22 | $default_values = array( |
| 23 | 23 | 'header' => 1, |
@@ -42,39 +42,39 @@ discard block |
||
| 42 | 42 | ), |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | - parent::__construct( __( 'Custom Content', 'gravityview' ) , 'custom_content', $default_values, $settings ); |
|
| 45 | + parent::__construct( __( 'Custom Content', 'gravityview' ), 'custom_content', $default_values, $settings ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
| 48 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
| 49 | 49 | |
| 50 | - if( !$this->pre_render_frontend() ) { |
|
| 50 | + if ( ! $this->pre_render_frontend() ) { |
|
| 51 | 51 | return; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if( !empty( $widget_args['title'] ) ) { |
|
| 55 | - echo $widget_args['title']; |
|
| 54 | + if ( ! empty( $widget_args[ 'title' ] ) ) { |
|
| 55 | + echo $widget_args[ 'title' ]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | // Make sure the class is loaded in DataTables |
| 60 | - if( !class_exists( 'GFFormDisplay' ) ) { |
|
| 60 | + if ( ! class_exists( 'GFFormDisplay' ) ) { |
|
| 61 | 61 | include_once( GFCommon::get_base_path() . '/form_display.php' ); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $widget_args['content'] = trim( rtrim( $widget_args['content'] ) ); |
|
| 64 | + $widget_args[ 'content' ] = trim( rtrim( $widget_args[ 'content' ] ) ); |
|
| 65 | 65 | |
| 66 | 66 | // No custom content |
| 67 | - if( empty( $widget_args['content'] ) ) { |
|
| 68 | - do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: No content.', get_class($this)) ); |
|
| 67 | + if ( empty( $widget_args[ 'content' ] ) ) { |
|
| 68 | + do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: No content.', get_class( $this ) ) ); |
|
| 69 | 69 | return; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Add paragraphs? |
| 73 | - if( !empty( $widget_args['wpautop'] ) ) { |
|
| 74 | - $widget_args['content'] = wpautop( $widget_args['content'] ); |
|
| 73 | + if ( ! empty( $widget_args[ 'wpautop' ] ) ) { |
|
| 74 | + $widget_args[ 'content' ] = wpautop( $widget_args[ 'content' ] ); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $content = $widget_args['content']; |
|
| 77 | + $content = $widget_args[ 'content' ]; |
|
| 78 | 78 | |
| 79 | 79 | $content = GravityView_Merge_Tags::replace_variables( $content ); |
| 80 | 80 | |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | // Add custom class |
| 87 | - $class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 87 | + $class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 88 | 88 | $class = gravityview_sanitize_html_class( $class ); |
| 89 | 89 | |
| 90 | - echo '<div class="gv-widget-custom-content '.$class.'">'. $content .'</div>'; |
|
| 90 | + echo '<div class="gv-widget-custom-content ' . $class . '">' . $content . '</div>'; |
|
| 91 | 91 | |
| 92 | 92 | } |
| 93 | 93 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | function __construct() { |
| 18 | 18 | |
| 19 | - $this->widget_description = __('Summary of the number of visible entries out of the total results.', 'gravityview' ); |
|
| 19 | + $this->widget_description = __( 'Summary of the number of visible entries out of the total results.', 'gravityview' ); |
|
| 20 | 20 | |
| 21 | 21 | $default_values = array( |
| 22 | 22 | 'header' => 1, |
@@ -25,18 +25,18 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $settings = array(); |
| 27 | 27 | |
| 28 | - parent::__construct( __( 'Show Pagination Info', 'gravityview' ) , 'page_info', $default_values, $settings ); |
|
| 28 | + parent::__construct( __( 'Show Pagination Info', 'gravityview' ), 'page_info', $default_values, $settings ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
| 31 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
| 32 | 32 | $gravityview_view = GravityView_View::getInstance(); |
| 33 | 33 | |
| 34 | - if( !$this->pre_render_frontend() ) { |
|
| 34 | + if ( ! $this->pre_render_frontend() ) { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if( !empty( $widget_args['title'] ) ) { |
|
| 39 | - echo $widget_args['title']; |
|
| 38 | + if ( ! empty( $widget_args[ 'title' ] ) ) { |
|
| 39 | + echo $widget_args[ 'title' ]; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $pagination_counts = $gravityview_view->getPaginationCounts(); |
@@ -45,16 +45,16 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $output = ''; |
| 47 | 47 | |
| 48 | - if( ! empty( $pagination_counts ) ) { |
|
| 48 | + if ( ! empty( $pagination_counts ) ) { |
|
| 49 | 49 | |
| 50 | - $first = $pagination_counts['first']; |
|
| 51 | - $last = $pagination_counts['last']; |
|
| 52 | - $total = $pagination_counts['total']; |
|
| 50 | + $first = $pagination_counts[ 'first' ]; |
|
| 51 | + $last = $pagination_counts[ 'last' ]; |
|
| 52 | + $total = $pagination_counts[ 'total' ]; |
|
| 53 | 53 | |
| 54 | - $class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 54 | + $class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 55 | 55 | $class = gravityview_sanitize_html_class( $class ); |
| 56 | 56 | |
| 57 | - $output = '<div class="gv-widget-pagination '.$class.'"><p>'. sprintf(__( 'Displaying %1$s - %2$s of %3$s', 'gravityview' ), number_format_i18n( $first ), number_format_i18n( $last ), number_format_i18n( $total ) ) . '</p></div>'; |
|
| 57 | + $output = '<div class="gv-widget-pagination ' . $class . '"><p>' . sprintf( __( 'Displaying %1$s - %2$s of %3$s', 'gravityview' ), number_format_i18n( $first ), number_format_i18n( $last ), number_format_i18n( $total ) ) . '</p></div>'; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -170,25 +170,25 @@ discard block |
||
| 170 | 170 | public function get_output() { |
| 171 | 171 | |
| 172 | 172 | // No Entries |
| 173 | - if( empty( $this->entries ) ) { |
|
| 174 | - return '<div class="gv-no-results">'.$this->empty_message.'</div>'; |
|
| 173 | + if ( empty( $this->entries ) ) { |
|
| 174 | + return '<div class="gv-no-results">' . $this->empty_message . '</div>'; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $output = ''; |
| 178 | 178 | $current_entry = GravityView_View::getInstance()->getCurrentEntry(); |
| 179 | 179 | |
| 180 | - $output .= '<'. $this->wrapper_tag .'>'; |
|
| 180 | + $output .= '<' . $this->wrapper_tag . '>'; |
|
| 181 | 181 | |
| 182 | - foreach( $this->entries as $entry ) { |
|
| 182 | + foreach ( $this->entries as $entry ) { |
|
| 183 | 183 | |
| 184 | - if( $this->skip_entry( $entry, $current_entry ) ) { |
|
| 184 | + if ( $this->skip_entry( $entry, $current_entry ) ) { |
|
| 185 | 185 | continue; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $output .= $this->get_item_output( $entry ); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - $output .= '</'. $this->wrapper_tag .'>'; |
|
| 191 | + $output .= '</' . $this->wrapper_tag . '>'; |
|
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | 194 | * @filter `gravityview/widget/recent-entries/output` Modify the HTML of the Recent Entries widget output |
@@ -211,15 +211,15 @@ discard block |
||
| 211 | 211 | private function skip_entry( $entry, $current_entry ) { |
| 212 | 212 | |
| 213 | 213 | // If skip entry is off, or there's no current entry, return false |
| 214 | - if( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
| 214 | + if ( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // If in Single or Edit mode, $current_entry will be an array. |
| 219 | - $current_entry_id = is_array( $current_entry ) ? $current_entry['id'] : $current_entry; |
|
| 219 | + $current_entry_id = is_array( $current_entry ) ? $current_entry[ 'id' ] : $current_entry; |
|
| 220 | 220 | |
| 221 | 221 | // If the entry ID matches the current entry, yes: skip |
| 222 | - if( $entry['id'] === $current_entry_id ) { |
|
| 222 | + if ( $entry[ 'id' ] === $current_entry_id ) { |
|
| 223 | 223 | return true; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | $item_output = gravityview_get_link( $link, $this->link_format ); |
| 248 | 248 | |
| 249 | - if( !empty( $this->after_link ) ) { |
|
| 249 | + if ( ! empty( $this->after_link ) ) { |
|
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | 252 | * @filter `gravityview/entry-list/after-link` Modify the content displayed after the entry link in an entry list |
@@ -255,14 +255,14 @@ discard block |
||
| 255 | 255 | * @param array $entry Gravity Forms entry array |
| 256 | 256 | * @param GravityView_Entry_List $this The current class instance |
| 257 | 257 | */ |
| 258 | - $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>'.$this->after_link.'</div>', $entry, $this ); |
|
| 258 | + $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>' . $this->after_link . '</div>', $entry, $this ); |
|
| 259 | 259 | |
| 260 | 260 | $item_output .= $after_link; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $item_output = GravityView_API::replace_variables( $item_output, $this->form, $entry ); |
| 264 | 264 | |
| 265 | - $item_output = '<'. $this->item_tag .'>'. $item_output .'</'. $this->item_tag .'>'; |
|
| 265 | + $item_output = '<' . $this->item_tag . '>' . $item_output . '</' . $this->item_tag . '>'; |
|
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | 268 | * @filter `gravityview/entry-list/item` Modify each item's output in an entry list |