@@ -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 |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 222 | 222 | $script_source = empty( $script_min ) ? '/source' : ''; |
| 223 | 223 | |
| 224 | - 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 ); |
|
| 224 | + 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 ); |
|
| 225 | 225 | |
| 226 | 226 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
| 227 | 227 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
| 244 | 244 | */ |
| 245 | 245 | public function register_no_conflict( $allowed ) { |
| 246 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
| 246 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
| 247 | 247 | return $allowed; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -256,24 +256,24 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public static function get_searchable_fields() { |
| 258 | 258 | |
| 259 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 259 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 260 | 260 | exit( '0' ); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $form = ''; |
| 264 | 264 | |
| 265 | 265 | // Fetch the form for the current View |
| 266 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
| 266 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
| 267 | 267 | |
| 268 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 268 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
| 269 | 269 | |
| 270 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
| 270 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
| 271 | 271 | |
| 272 | - $form = (int) $_POST['formid']; |
|
| 272 | + $form = (int)$_POST[ 'formid' ]; |
|
| 273 | 273 | |
| 274 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 274 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 275 | 275 | |
| 276 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 276 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 277 | 277 | |
| 278 | 278 | } |
| 279 | 279 | |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | ) |
| 319 | 319 | ); |
| 320 | 320 | |
| 321 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 322 | - $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'] ); |
|
| 321 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 322 | + $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' ] ); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // Get fields with sub-inputs and no parent |
@@ -341,13 +341,13 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | foreach ( $fields as $id => $field ) { |
| 343 | 343 | |
| 344 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 344 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 345 | 345 | continue; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
| 348 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
| 349 | 349 | |
| 350 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
| 350 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
| 371 | 371 | |
| 372 | 372 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 373 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 373 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 374 | 374 | $input_type = 'boolean'; // on/off checkbox |
| 375 | 375 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
| 376 | 376 | $input_type = 'multi'; //multiselect |
@@ -414,19 +414,19 @@ discard block |
||
| 414 | 414 | $post_id = 0; |
| 415 | 415 | |
| 416 | 416 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 417 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 418 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 417 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
| 418 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
| 419 | 419 | } |
| 420 | 420 | // We're in the WordPress Widget context, and the base View ID should be used |
| 421 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 422 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 421 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
| 422 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | $args = gravityview_get_permalink_query_args( $post_id ); |
| 426 | 426 | |
| 427 | 427 | // Add hidden fields to the search form |
| 428 | 428 | foreach ( $args as $key => $value ) { |
| 429 | - $search_fields[] = array( |
|
| 429 | + $search_fields[ ] = array( |
|
| 430 | 430 | 'name' => $key, |
| 431 | 431 | 'input' => 'hidden', |
| 432 | 432 | 'value' => $value, |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | */ |
| 448 | 448 | public function filter_entries( $search_criteria ) { |
| 449 | 449 | |
| 450 | - if( 'post' === $this->search_method ) { |
|
| 450 | + if ( 'post' === $this->search_method ) { |
|
| 451 | 451 | $get = $_POST; |
| 452 | 452 | } else { |
| 453 | 453 | $get = $_GET; |
@@ -464,12 +464,12 @@ discard block |
||
| 464 | 464 | $get = gv_map_deep( $get, 'rawurldecode' ); |
| 465 | 465 | |
| 466 | 466 | // Make sure array key is set up |
| 467 | - $search_criteria['field_filters'] = rgar( $search_criteria, 'field_filters', array() ); |
|
| 467 | + $search_criteria[ 'field_filters' ] = rgar( $search_criteria, 'field_filters', array() ); |
|
| 468 | 468 | |
| 469 | 469 | // add free search |
| 470 | - if ( ! empty( $get['gv_search'] ) ) { |
|
| 470 | + if ( ! empty( $get[ 'gv_search' ] ) ) { |
|
| 471 | 471 | |
| 472 | - $search_all_value = trim( $get['gv_search'] ); |
|
| 472 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
| 473 | 473 | |
| 474 | 474 | /** |
| 475 | 475 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | $split_words = apply_filters( 'gravityview/search-all-split-words', true ); |
| 480 | 480 | |
| 481 | - if( $split_words ) { |
|
| 481 | + if ( $split_words ) { |
|
| 482 | 482 | |
| 483 | 483 | // Search for a piece |
| 484 | 484 | $words = explode( ' ', $search_all_value ); |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | foreach ( $words as $word ) { |
| 497 | - $search_criteria['field_filters'][] = array( |
|
| 497 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 498 | 498 | 'key' => null, // The field ID to search |
| 499 | 499 | 'value' => $word, // The value to search |
| 500 | 500 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -503,8 +503,8 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | //start date & end date |
| 506 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
| 507 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
| 506 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
| 507 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
| 508 | 508 | |
| 509 | 509 | /** |
| 510 | 510 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -519,16 +519,16 @@ discard block |
||
| 519 | 519 | /** |
| 520 | 520 | * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) |
| 521 | 521 | */ |
| 522 | - if( !empty( $curr_start ) ) { |
|
| 523 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 522 | + if ( ! empty( $curr_start ) ) { |
|
| 523 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 524 | 524 | } |
| 525 | - if( !empty( $curr_end ) ) { |
|
| 526 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 525 | + if ( ! empty( $curr_end ) ) { |
|
| 526 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | // search for a specific entry ID |
| 530 | 530 | if ( ! empty( $get[ 'gv_id' ] ) ) { |
| 531 | - $search_criteria['field_filters'][] = array( |
|
| 531 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 532 | 532 | 'key' => 'id', |
| 533 | 533 | 'value' => absint( $get[ 'gv_id' ] ), |
| 534 | 534 | 'operator' => '=', |
@@ -537,36 +537,36 @@ discard block |
||
| 537 | 537 | |
| 538 | 538 | // search for a specific Created_by ID |
| 539 | 539 | if ( ! empty( $get[ 'gv_by' ] ) ) { |
| 540 | - $search_criteria['field_filters'][] = array( |
|
| 540 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 541 | 541 | 'key' => 'created_by', |
| 542 | - 'value' => absint( $get['gv_by'] ), |
|
| 542 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
| 543 | 543 | 'operator' => '=', |
| 544 | 544 | ); |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | |
| 548 | 548 | // Get search mode passed in URL |
| 549 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
| 549 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
| 550 | 550 | |
| 551 | 551 | // get the other search filters |
| 552 | 552 | foreach ( $get as $key => $value ) { |
| 553 | 553 | |
| 554 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
| 554 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
| 555 | 555 | continue; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | // could return simple filter or multiple filters |
| 559 | 559 | $filter = $this->prepare_field_filter( $key, $value ); |
| 560 | 560 | |
| 561 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 562 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 561 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
| 562 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
| 563 | 563 | |
| 564 | 564 | // if date range type, set search mode to ALL |
| 565 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 565 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 566 | 566 | $mode = 'all'; |
| 567 | 567 | } |
| 568 | - } elseif( !empty( $filter ) ) { |
|
| 569 | - $search_criteria['field_filters'][] = $filter; |
|
| 568 | + } elseif ( ! empty( $filter ) ) { |
|
| 569 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * @since 1.5.1 |
| 576 | 576 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
| 577 | 577 | */ |
| 578 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 578 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 579 | 579 | |
| 580 | 580 | do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
| 581 | 581 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | $field_id = str_replace( 'filter_', '', $key ); |
| 602 | 602 | |
| 603 | 603 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
| 604 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
| 604 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
| 605 | 605 | $field_id = str_replace( '_', '.', $field_id ); |
| 606 | 606 | } |
| 607 | 607 | |
@@ -615,11 +615,11 @@ discard block |
||
| 615 | 615 | 'value' => $value, |
| 616 | 616 | ); |
| 617 | 617 | |
| 618 | - switch ( $form_field['type'] ) { |
|
| 618 | + switch ( $form_field[ 'type' ] ) { |
|
| 619 | 619 | |
| 620 | 620 | case 'select': |
| 621 | 621 | case 'radio': |
| 622 | - $filter['operator'] = 'is'; |
|
| 622 | + $filter[ 'operator' ] = 'is'; |
|
| 623 | 623 | break; |
| 624 | 624 | |
| 625 | 625 | case 'post_category': |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | |
| 634 | 634 | foreach ( $value as $val ) { |
| 635 | 635 | $cat = get_term( $val, 'category' ); |
| 636 | - $filter[] = array( |
|
| 636 | + $filter[ ] = array( |
|
| 637 | 637 | 'key' => $field_id, |
| 638 | 638 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 639 | 639 | 'operator' => 'is', |
@@ -652,18 +652,18 @@ discard block |
||
| 652 | 652 | $filter = array(); |
| 653 | 653 | |
| 654 | 654 | foreach ( $value as $val ) { |
| 655 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
| 655 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | break; |
| 659 | 659 | |
| 660 | 660 | case 'checkbox': |
| 661 | 661 | // convert checkbox on/off into the correct search filter |
| 662 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
| 663 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
| 664 | - if ( $input['id'] == $field_id ) { |
|
| 665 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
| 666 | - $filter['operator'] = 'is'; |
|
| 662 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
| 663 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
| 664 | + if ( $input[ 'id' ] == $field_id ) { |
|
| 665 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
| 666 | + $filter[ 'operator' ] = 'is'; |
|
| 667 | 667 | break; |
| 668 | 668 | } |
| 669 | 669 | } |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | $filter = array(); |
| 674 | 674 | |
| 675 | 675 | foreach ( $value as $val ) { |
| 676 | - $filter[] = array( |
|
| 676 | + $filter[ ] = array( |
|
| 677 | 677 | 'key' => $field_id, |
| 678 | 678 | 'value' => $val, |
| 679 | 679 | 'operator' => 'is', |
@@ -694,9 +694,9 @@ discard block |
||
| 694 | 694 | foreach ( $words as $word ) { |
| 695 | 695 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 696 | 696 | // Keep the same key for each filter |
| 697 | - $filter['value'] = $word; |
|
| 697 | + $filter[ 'value' ] = $word; |
|
| 698 | 698 | // Add a search for the value |
| 699 | - $filters[] = $filter; |
|
| 699 | + $filters[ ] = $filter; |
|
| 700 | 700 | } |
| 701 | 701 | } |
| 702 | 702 | |
@@ -704,12 +704,12 @@ discard block |
||
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | // State/Province should be exact matches |
| 707 | - if ( 'address' === $form_field['type'] ) { |
|
| 707 | + if ( 'address' === $form_field[ 'type' ] ) { |
|
| 708 | 708 | |
| 709 | 709 | $input_id = gravityview_get_input_id_from_id( $field_id ); |
| 710 | 710 | |
| 711 | 711 | if ( 4 === $input_id ) { |
| 712 | - $filter['operator'] = 'is'; |
|
| 712 | + $filter[ 'operator' ] = 'is'; |
|
| 713 | 713 | }; |
| 714 | 714 | } |
| 715 | 715 | |
@@ -733,19 +733,19 @@ discard block |
||
| 733 | 733 | * @since 1.16.3 |
| 734 | 734 | * Safeguard until GF implements '<=' operator |
| 735 | 735 | */ |
| 736 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 736 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 737 | 737 | $operator = '<'; |
| 738 | 738 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - $filter[] = array( |
|
| 741 | + $filter[ ] = array( |
|
| 742 | 742 | 'key' => $field_id, |
| 743 | 743 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
| 744 | 744 | 'operator' => $operator, |
| 745 | 745 | ); |
| 746 | 746 | } |
| 747 | 747 | } else { |
| 748 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 748 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | break; |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | 'ymd_dot' => 'Y.m.d', |
| 777 | 777 | ); |
| 778 | 778 | |
| 779 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 779 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 780 | 780 | $format = $datepicker[ $field->dateFormat ]; |
| 781 | 781 | } |
| 782 | 782 | |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | public function add_template_path( $file_paths ) { |
| 808 | 808 | |
| 809 | 809 | // Index 100 is the default GravityView template path. |
| 810 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 810 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 811 | 811 | |
| 812 | 812 | return $file_paths; |
| 813 | 813 | } |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | $has_date = false; |
| 827 | 827 | |
| 828 | 828 | foreach ( $search_fields as $k => $field ) { |
| 829 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 829 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 830 | 830 | $has_date = true; |
| 831 | 831 | break; |
| 832 | 832 | } |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | // get configured search fields |
| 856 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 856 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 857 | 857 | |
| 858 | 858 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 859 | 859 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -868,34 +868,34 @@ discard block |
||
| 868 | 868 | |
| 869 | 869 | $updated_field = $this->get_search_filter_details( $updated_field ); |
| 870 | 870 | |
| 871 | - switch ( $field['field'] ) { |
|
| 871 | + switch ( $field[ 'field' ] ) { |
|
| 872 | 872 | |
| 873 | 873 | case 'search_all': |
| 874 | - $updated_field['key'] = 'search_all'; |
|
| 875 | - $updated_field['input'] = 'search_all'; |
|
| 876 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 874 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 875 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 876 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 877 | 877 | break; |
| 878 | 878 | |
| 879 | 879 | case 'entry_date': |
| 880 | - $updated_field['key'] = 'entry_date'; |
|
| 881 | - $updated_field['input'] = 'entry_date'; |
|
| 882 | - $updated_field['value'] = array( |
|
| 880 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 881 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 882 | + $updated_field[ 'value' ] = array( |
|
| 883 | 883 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 884 | 884 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 885 | 885 | ); |
| 886 | 886 | break; |
| 887 | 887 | |
| 888 | 888 | case 'entry_id': |
| 889 | - $updated_field['key'] = 'entry_id'; |
|
| 890 | - $updated_field['input'] = 'entry_id'; |
|
| 891 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 889 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 890 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 891 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 892 | 892 | break; |
| 893 | 893 | |
| 894 | 894 | case 'created_by': |
| 895 | - $updated_field['key'] = 'created_by'; |
|
| 896 | - $updated_field['name'] = 'gv_by'; |
|
| 897 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 898 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
| 895 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 896 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 897 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 898 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
| 899 | 899 | break; |
| 900 | 900 | } |
| 901 | 901 | |
@@ -913,16 +913,16 @@ discard block |
||
| 913 | 913 | */ |
| 914 | 914 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
| 915 | 915 | |
| 916 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 916 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 917 | 917 | |
| 918 | 918 | /** @since 1.14 */ |
| 919 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 919 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 920 | 920 | |
| 921 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 921 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 922 | 922 | |
| 923 | 923 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 924 | 924 | |
| 925 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 925 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 926 | 926 | |
| 927 | 927 | if ( $this->has_date_field( $search_fields ) ) { |
| 928 | 928 | // enqueue datepicker stuff only if needed! |
@@ -944,10 +944,10 @@ discard block |
||
| 944 | 944 | public static function get_search_class( $custom_class = '' ) { |
| 945 | 945 | $gravityview_view = GravityView_View::getInstance(); |
| 946 | 946 | |
| 947 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 947 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 948 | 948 | |
| 949 | - if ( ! empty( $custom_class ) ) { |
|
| 950 | - $search_class .= ' '.$custom_class; |
|
| 949 | + if ( ! empty( $custom_class ) ) { |
|
| 950 | + $search_class .= ' ' . $custom_class; |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | /** |
@@ -989,11 +989,11 @@ discard block |
||
| 989 | 989 | |
| 990 | 990 | $label = rgget( 'label', $field ); |
| 991 | 991 | |
| 992 | - if( '' === $label ) { |
|
| 992 | + if ( '' === $label ) { |
|
| 993 | 993 | |
| 994 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 994 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 995 | 995 | |
| 996 | - switch( $field['field'] ) { |
|
| 996 | + switch ( $field[ 'field' ] ) { |
|
| 997 | 997 | case 'search_all': |
| 998 | 998 | $label = __( 'Search Entries:', 'gravityview' ); |
| 999 | 999 | break; |
@@ -1005,10 +1005,10 @@ discard block |
||
| 1005 | 1005 | break; |
| 1006 | 1006 | default: |
| 1007 | 1007 | // If this is a field input, not a field |
| 1008 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 1008 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 1009 | 1009 | |
| 1010 | 1010 | // Get the label for the field in question, which returns an array |
| 1011 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 1011 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 1012 | 1012 | |
| 1013 | 1013 | // Get the item with the `label` key |
| 1014 | 1014 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1047,32 +1047,32 @@ discard block |
||
| 1047 | 1047 | $form = $gravityview_view->getForm(); |
| 1048 | 1048 | |
| 1049 | 1049 | // for advanced field ids (eg, first name / last name ) |
| 1050 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 1050 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 1051 | 1051 | |
| 1052 | 1052 | // get searched value from $_GET/$_POST (string or array) |
| 1053 | 1053 | $value = $this->rgget_or_rgpost( $name ); |
| 1054 | 1054 | |
| 1055 | 1055 | // get form field details |
| 1056 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 1056 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 1057 | 1057 | |
| 1058 | 1058 | $filter = array( |
| 1059 | - 'key' => $field['field'], |
|
| 1059 | + 'key' => $field[ 'field' ], |
|
| 1060 | 1060 | 'name' => $name, |
| 1061 | 1061 | 'label' => self::get_field_label( $field, $form_field ), |
| 1062 | - 'input' => $field['input'], |
|
| 1062 | + 'input' => $field[ 'input' ], |
|
| 1063 | 1063 | 'value' => $value, |
| 1064 | - 'type' => $form_field['type'], |
|
| 1064 | + 'type' => $form_field[ 'type' ], |
|
| 1065 | 1065 | ); |
| 1066 | 1066 | |
| 1067 | 1067 | // collect choices |
| 1068 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 1069 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 1070 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 1071 | - $filter['choices'] = $form_field['choices']; |
|
| 1068 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 1069 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 1070 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 1071 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 1075 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 1074 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 1075 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | return $filter; |
@@ -1096,7 +1096,7 @@ discard block |
||
| 1096 | 1096 | |
| 1097 | 1097 | $choices = array(); |
| 1098 | 1098 | foreach ( $users as $user ) { |
| 1099 | - $choices[] = array( |
|
| 1099 | + $choices[ ] = array( |
|
| 1100 | 1100 | 'value' => $user->ID, |
| 1101 | 1101 | 'text' => $user->display_name, |
| 1102 | 1102 | ); |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | */ |
| 1152 | 1152 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1153 | 1153 | |
| 1154 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1154 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1155 | 1155 | |
| 1156 | 1156 | return $js_dependencies; |
| 1157 | 1157 | } |
@@ -1195,7 +1195,7 @@ discard block |
||
| 1195 | 1195 | 'isRTL' => is_rtl(), |
| 1196 | 1196 | ), $view_data ); |
| 1197 | 1197 | |
| 1198 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1198 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1199 | 1199 | |
| 1200 | 1200 | return $localizations; |
| 1201 | 1201 | |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | * @return void |
| 1225 | 1225 | */ |
| 1226 | 1226 | private function maybe_enqueue_flexibility() { |
| 1227 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1227 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 1228 | 1228 | wp_enqueue_script( 'gv-flexibility' ); |
| 1229 | 1229 | } |
| 1230 | 1230 | } |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 1247 | 1247 | |
| 1248 | 1248 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1249 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1249 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1250 | 1250 | |
| 1251 | 1251 | /** |
| 1252 | 1252 | * @filter `gravityview_search_datepicker_class` |