@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'type' => 'radio', |
65 | 65 | 'full_width' => true, |
66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
68 | 68 | 'value' => 'any', |
69 | 69 | 'class' => 'hide-if-js', |
70 | 70 | 'options' => array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
88 | 88 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
89 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
89 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
90 | 90 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
91 | 91 | |
92 | 92 | // ajax - get the searchable fields |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
230 | 230 | $script_source = empty( $script_min ) ? '/source' : ''; |
231 | 231 | |
232 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
232 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
233 | 233 | |
234 | 234 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
235 | 235 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
252 | 252 | */ |
253 | 253 | public function register_no_conflict( $allowed ) { |
254 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
254 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
255 | 255 | return $allowed; |
256 | 256 | } |
257 | 257 | |
@@ -264,24 +264,24 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public static function get_searchable_fields() { |
266 | 266 | |
267 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
267 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
268 | 268 | exit( '0' ); |
269 | 269 | } |
270 | 270 | |
271 | 271 | $form = ''; |
272 | 272 | |
273 | 273 | // Fetch the form for the current View |
274 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
274 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
275 | 275 | |
276 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
276 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
277 | 277 | |
278 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
278 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
279 | 279 | |
280 | - $form = (int) $_POST['formid']; |
|
280 | + $form = (int)$_POST[ 'formid' ]; |
|
281 | 281 | |
282 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
282 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
283 | 283 | |
284 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
284 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | ); |
332 | 332 | |
333 | 333 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
334 | - $custom_fields['is_approved'] = array( |
|
334 | + $custom_fields[ 'is_approved' ] = array( |
|
335 | 335 | 'text' => esc_html__( 'Approval Status', 'gravityview' ), |
336 | 336 | 'type' => 'multi', |
337 | 337 | ); |
338 | 338 | } |
339 | 339 | |
340 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
341 | - $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'] ); |
|
340 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
341 | + $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' ] ); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | // Get fields with sub-inputs and no parent |
@@ -360,13 +360,13 @@ discard block |
||
360 | 360 | |
361 | 361 | foreach ( $fields as $id => $field ) { |
362 | 362 | |
363 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
363 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
364 | 364 | continue; |
365 | 365 | } |
366 | 366 | |
367 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
367 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
368 | 368 | |
369 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
369 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
390 | 390 | |
391 | 391 | // @todo - This needs to be improved - many fields have . including products and addresses |
392 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
392 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
393 | 393 | $input_type = 'boolean'; // on/off checkbox |
394 | 394 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
395 | 395 | $input_type = 'multi'; //multiselect |
@@ -433,19 +433,19 @@ discard block |
||
433 | 433 | $post_id = 0; |
434 | 434 | |
435 | 435 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
436 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
437 | - $post_id = absint( $widget_args['post_id'] ); |
|
436 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
437 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
438 | 438 | } |
439 | 439 | // We're in the WordPress Widget context, and the base View ID should be used |
440 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
441 | - $post_id = absint( $widget_args['view_id'] ); |
|
440 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
441 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | $args = gravityview_get_permalink_query_args( $post_id ); |
445 | 445 | |
446 | 446 | // Add hidden fields to the search form |
447 | 447 | foreach ( $args as $key => $value ) { |
448 | - $search_fields[] = array( |
|
448 | + $search_fields[ ] = array( |
|
449 | 449 | 'name' => $key, |
450 | 450 | 'input' => 'hidden', |
451 | 451 | 'value' => $value, |
@@ -484,28 +484,28 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * Include the sidebar Widgets. |
486 | 486 | */ |
487 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
487 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
488 | 488 | |
489 | 489 | foreach ( $widgets as $widget ) { |
490 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
491 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
490 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
491 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
492 | 492 | foreach ( $_fields as $field ) { |
493 | - if ( empty( $field['form_id'] ) ) { |
|
494 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
493 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
494 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
495 | 495 | } |
496 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
496 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | 502 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
503 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
503 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
504 | 504 | foreach ( $_fields as $field ) { |
505 | - if ( empty( $field['form_id'] ) ) { |
|
506 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
505 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
506 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
507 | 507 | } |
508 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
508 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
509 | 509 | } |
510 | 510 | } |
511 | 511 | } |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
536 | 536 | } |
537 | 537 | |
538 | - if( 'post' === $this->search_method ) { |
|
538 | + if ( 'post' === $this->search_method ) { |
|
539 | 539 | $get = $_POST; |
540 | 540 | } else { |
541 | 541 | $get = $_GET; |
@@ -554,15 +554,15 @@ discard block |
||
554 | 554 | $get = gv_map_deep( $get, 'rawurldecode' ); |
555 | 555 | |
556 | 556 | // Make sure array key is set up |
557 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
557 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
558 | 558 | |
559 | 559 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
560 | 560 | $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); |
561 | 561 | |
562 | 562 | // add free search |
563 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
563 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
564 | 564 | |
565 | - $search_all_value = trim( $get['gv_search'] ); |
|
565 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
566 | 566 | |
567 | 567 | /** |
568 | 568 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | } |
588 | 588 | |
589 | 589 | foreach ( $words as $word ) { |
590 | - $search_criteria['field_filters'][] = array( |
|
590 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
591 | 591 | 'key' => null, // The field ID to search |
592 | 592 | 'value' => $word, // The value to search |
593 | 593 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -600,14 +600,14 @@ discard block |
||
600 | 600 | /** |
601 | 601 | * Get and normalize the dates according to the input format. |
602 | 602 | */ |
603 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
604 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
603 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
604 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
605 | 605 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
609 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
610 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
609 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
610 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
611 | 611 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
612 | 612 | } |
613 | 613 | } |
@@ -642,22 +642,22 @@ discard block |
||
642 | 642 | */ |
643 | 643 | if ( ! empty( $curr_start ) ) { |
644 | 644 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
645 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
645 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | if ( ! empty( $curr_end ) ) { |
649 | 649 | // Fast-forward 24 hour on the end time |
650 | 650 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
651 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
652 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
653 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
651 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
652 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
653 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
658 | 658 | // search for a specific entry ID |
659 | 659 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
660 | - $search_criteria['field_filters'][] = array( |
|
660 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
661 | 661 | 'key' => 'id', |
662 | 662 | 'value' => absint( $get[ 'gv_id' ] ), |
663 | 663 | 'operator' => '=', |
@@ -666,20 +666,20 @@ discard block |
||
666 | 666 | |
667 | 667 | // search for a specific Created_by ID |
668 | 668 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
669 | - $search_criteria['field_filters'][] = array( |
|
669 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
670 | 670 | 'key' => 'created_by', |
671 | - 'value' => $get['gv_by'], |
|
671 | + 'value' => $get[ 'gv_by' ], |
|
672 | 672 | 'operator' => '=', |
673 | 673 | ); |
674 | 674 | } |
675 | 675 | |
676 | 676 | // Get search mode passed in URL |
677 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
677 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
678 | 678 | |
679 | 679 | // get the other search filters |
680 | 680 | foreach ( $get as $key => $value ) { |
681 | 681 | |
682 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
682 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
683 | 683 | continue; |
684 | 684 | } |
685 | 685 | |
@@ -689,15 +689,15 @@ discard block |
||
689 | 689 | continue; |
690 | 690 | } |
691 | 691 | |
692 | - if ( isset( $filter[0]['value'] ) ) { |
|
693 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
692 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
693 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
694 | 694 | |
695 | 695 | // if date range type, set search mode to ALL |
696 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
696 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
697 | 697 | $mode = 'all'; |
698 | 698 | } |
699 | - } elseif( !empty( $filter ) ) { |
|
700 | - $search_criteria['field_filters'][] = $filter; |
|
699 | + } elseif ( ! empty( $filter ) ) { |
|
700 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | * @since 1.5.1 |
707 | 707 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
708 | 708 | */ |
709 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
709 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
710 | 710 | |
711 | 711 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
712 | 712 | |
@@ -731,19 +731,19 @@ discard block |
||
731 | 731 | */ |
732 | 732 | $search_criteria = $this->filter_entries( array(), null, array( 'id' => $view->ID ), true /** force search_criteria */ ); |
733 | 733 | |
734 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
734 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
735 | 735 | return; |
736 | 736 | } |
737 | 737 | |
738 | 738 | $widgets = $view->widgets->by_id( $this->widget_id ); |
739 | 739 | if ( $widgets->count() ) { |
740 | 740 | $widgets = $widgets->all(); |
741 | - $widget = $widgets[0]; |
|
741 | + $widget = $widgets[ 0 ]; |
|
742 | 742 | |
743 | 743 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
744 | 744 | |
745 | - foreach ( (array) $search_fields as $search_field ) { |
|
746 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
745 | + foreach ( (array)$search_fields as $search_field ) { |
|
746 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
747 | 747 | $created_by_text_mode = true; |
748 | 748 | } |
749 | 749 | } |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | $extra_conditions = array(); |
753 | 753 | $mode = 'any'; |
754 | 754 | |
755 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
755 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
756 | 756 | if ( ! is_array( $filter ) ) { |
757 | 757 | if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) { |
758 | 758 | $mode = $filter; |
@@ -761,13 +761,13 @@ discard block |
||
761 | 761 | } |
762 | 762 | |
763 | 763 | // Construct a manual query for unapproved statuses |
764 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
765 | - $_tmp_query = new GF_Query( $view->form->ID, array( |
|
764 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
765 | + $_tmp_query = new GF_Query( $view->form->ID, array( |
|
766 | 766 | 'field_filters' => array( |
767 | 767 | array( |
768 | 768 | 'operator' => 'in', |
769 | 769 | 'key' => 'is_approved', |
770 | - 'value' => (array) $filter['value'], |
|
770 | + 'value' => (array)$filter[ 'value' ], |
|
771 | 771 | ), |
772 | 772 | array( |
773 | 773 | 'operator' => 'is', |
@@ -779,30 +779,30 @@ discard block |
||
779 | 779 | ) ); |
780 | 780 | $_tmp_query_parts = $_tmp_query->_introspect(); |
781 | 781 | |
782 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
782 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
783 | 783 | |
784 | 784 | $filter = false; |
785 | 785 | continue; |
786 | 786 | } |
787 | 787 | |
788 | 788 | // Construct manual query for text mode creator search |
789 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
790 | - $extra_conditions[] = new GravityView_Widget_Search_GF_Query_Condition( $filter, $view ); |
|
789 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
790 | + $extra_conditions[ ] = new GravityView_Widget_Search_GF_Query_Condition( $filter, $view ); |
|
791 | 791 | $filter = false; |
792 | 792 | continue; |
793 | 793 | } |
794 | 794 | |
795 | 795 | // By default, we want searches to be wildcard for each field. |
796 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
796 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
797 | 797 | |
798 | 798 | // For multichoice, let's have an in (OR) search. |
799 | - if ( is_array( $filter['value'] ) ) { |
|
800 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
799 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
800 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | // Default form with joins functionality |
804 | - if ( empty( $filter['form_id'] ) ) { |
|
805 | - $filter['form_id'] = $view->form ? $view->form->ID : 0; |
|
804 | + if ( empty( $filter[ 'form_id' ] ) ) { |
|
805 | + $filter[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | /** |
@@ -810,12 +810,12 @@ discard block |
||
810 | 810 | * @param string $operator Existing search operator |
811 | 811 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
812 | 812 | */ |
813 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
813 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | $search_conditions = array(); |
817 | 817 | |
818 | - if ( $filters = array_filter( $search_criteria['field_filters'] ) ) { |
|
818 | + if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) { |
|
819 | 819 | |
820 | 820 | foreach ( $filters as $filter ) { |
821 | 821 | if ( ! is_array( $filter ) ) { |
@@ -828,16 +828,16 @@ discard block |
||
828 | 828 | * code by reusing what's inside GF_Query already as they |
829 | 829 | * take care of many small things like forcing numeric, etc. |
830 | 830 | */ |
831 | - $_tmp_query = new GF_Query( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
831 | + $_tmp_query = new GF_Query( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
832 | 832 | $_tmp_query_parts = $_tmp_query->_introspect(); |
833 | - $search_condition = $_tmp_query_parts['where']; |
|
833 | + $search_condition = $_tmp_query_parts[ 'where' ]; |
|
834 | 834 | |
835 | 835 | /** |
836 | 836 | * Make sure the column alias is correct. |
837 | 837 | */ |
838 | 838 | $left = $search_condition->left; |
839 | 839 | $alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' ); |
840 | - $search_conditions[] = new GF_Query_Condition( |
|
840 | + $search_conditions[ ] = new GF_Query_Condition( |
|
841 | 841 | new GF_Query_Column( $left->field_id, $left->source, $alias ), |
842 | 842 | $search_condition->operator, |
843 | 843 | $search_condition->right |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | /** |
858 | 858 | * Combine the parts as a new WHERE clause. |
859 | 859 | */ |
860 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) ); |
|
860 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) ); |
|
861 | 861 | $query->where( $where ); |
862 | 862 | } |
863 | 863 | |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | $field_id = str_replace( 'filter_', '', $key ); |
881 | 881 | |
882 | 882 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
883 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
883 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
884 | 884 | $field_id = str_replace( '_', '.', $field_id ); |
885 | 885 | } |
886 | 886 | |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | // form is in searchable fields |
933 | 933 | $found = false; |
934 | 934 | foreach ( $searchable_fields as $field ) { |
935 | - if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) { |
|
935 | + if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) { |
|
936 | 936 | $found = true; |
937 | 937 | break; |
938 | 938 | } |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | |
969 | 969 | case 'select': |
970 | 970 | case 'radio': |
971 | - $filter['operator'] = 'is'; |
|
971 | + $filter[ 'operator' ] = 'is'; |
|
972 | 972 | break; |
973 | 973 | |
974 | 974 | case 'post_category': |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | |
983 | 983 | foreach ( $value as $val ) { |
984 | 984 | $cat = get_term( $val, 'category' ); |
985 | - $filter[] = array( |
|
985 | + $filter[ ] = array( |
|
986 | 986 | 'key' => $field_id, |
987 | 987 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
988 | 988 | 'operator' => 'is', |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | $filter = array(); |
1002 | 1002 | |
1003 | 1003 | foreach ( $value as $val ) { |
1004 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
1004 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | break; |
@@ -1010,9 +1010,9 @@ discard block |
||
1010 | 1010 | // convert checkbox on/off into the correct search filter |
1011 | 1011 | if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
1012 | 1012 | foreach ( $form_field->inputs as $k => $input ) { |
1013 | - if ( $input['id'] == $field_id ) { |
|
1014 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
1015 | - $filter['operator'] = 'is'; |
|
1013 | + if ( $input[ 'id' ] == $field_id ) { |
|
1014 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
1015 | + $filter[ 'operator' ] = 'is'; |
|
1016 | 1016 | break; |
1017 | 1017 | } |
1018 | 1018 | } |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | $filter = array(); |
1023 | 1023 | |
1024 | 1024 | foreach ( $value as $val ) { |
1025 | - $filter[] = array( |
|
1025 | + $filter[ ] = array( |
|
1026 | 1026 | 'key' => $field_id, |
1027 | 1027 | 'value' => $val, |
1028 | 1028 | 'operator' => 'is', |
@@ -1043,9 +1043,9 @@ discard block |
||
1043 | 1043 | foreach ( $words as $word ) { |
1044 | 1044 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
1045 | 1045 | // Keep the same key for each filter |
1046 | - $filter['value'] = $word; |
|
1046 | + $filter[ 'value' ] = $word; |
|
1047 | 1047 | // Add a search for the value |
1048 | - $filters[] = $filter; |
|
1048 | + $filters[ ] = $filter; |
|
1049 | 1049 | } |
1050 | 1050 | } |
1051 | 1051 | |
@@ -1059,19 +1059,19 @@ discard block |
||
1059 | 1059 | |
1060 | 1060 | foreach ( $searchable_fields as $searchable_field ) { |
1061 | 1061 | |
1062 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
1062 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
1063 | 1063 | continue; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | // Only exact-match dropdowns, not text search |
1067 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
1067 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
1068 | 1068 | continue; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
1072 | 1072 | |
1073 | 1073 | if ( 4 === $input_id ) { |
1074 | - $filter['operator'] = 'is'; |
|
1074 | + $filter[ 'operator' ] = 'is'; |
|
1075 | 1075 | }; |
1076 | 1076 | } |
1077 | 1077 | } |
@@ -1098,12 +1098,12 @@ discard block |
||
1098 | 1098 | * @since 1.16.3 |
1099 | 1099 | * Safeguard until GF implements '<=' operator |
1100 | 1100 | */ |
1101 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1101 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1102 | 1102 | $operator = '<'; |
1103 | 1103 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1104 | 1104 | } |
1105 | 1105 | |
1106 | - $filter[] = array( |
|
1106 | + $filter[ ] = array( |
|
1107 | 1107 | 'key' => $field_id, |
1108 | 1108 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1109 | 1109 | 'operator' => $operator, |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | } |
1112 | 1112 | } else { |
1113 | 1113 | $date = $value; |
1114 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1114 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | break; |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | 'ymd_dot' => 'Y.m.d', |
1143 | 1143 | ); |
1144 | 1144 | |
1145 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1145 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1146 | 1146 | $format = $datepicker[ $field->dateFormat ]; |
1147 | 1147 | } |
1148 | 1148 | |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | public function add_template_path( $file_paths ) { |
1180 | 1180 | |
1181 | 1181 | // Index 100 is the default GravityView template path. |
1182 | - $file_paths[102] = self::$file . 'templates/'; |
|
1182 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1183 | 1183 | |
1184 | 1184 | return $file_paths; |
1185 | 1185 | } |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | $has_date = false; |
1199 | 1199 | |
1200 | 1200 | foreach ( $search_fields as $k => $field ) { |
1201 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1201 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1202 | 1202 | $has_date = true; |
1203 | 1203 | break; |
1204 | 1204 | } |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | // get configured search fields |
1228 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1228 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1229 | 1229 | |
1230 | 1230 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1231 | 1231 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1240,40 +1240,40 @@ discard block |
||
1240 | 1240 | |
1241 | 1241 | $updated_field = $this->get_search_filter_details( $updated_field ); |
1242 | 1242 | |
1243 | - switch ( $field['field'] ) { |
|
1243 | + switch ( $field[ 'field' ] ) { |
|
1244 | 1244 | |
1245 | 1245 | case 'search_all': |
1246 | - $updated_field['key'] = 'search_all'; |
|
1247 | - $updated_field['input'] = 'search_all'; |
|
1248 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1246 | + $updated_field[ 'key' ] = 'search_all'; |
|
1247 | + $updated_field[ 'input' ] = 'search_all'; |
|
1248 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1249 | 1249 | break; |
1250 | 1250 | |
1251 | 1251 | case 'entry_date': |
1252 | - $updated_field['key'] = 'entry_date'; |
|
1253 | - $updated_field['input'] = 'entry_date'; |
|
1254 | - $updated_field['value'] = array( |
|
1252 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1253 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1254 | + $updated_field[ 'value' ] = array( |
|
1255 | 1255 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1256 | 1256 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1257 | 1257 | ); |
1258 | 1258 | break; |
1259 | 1259 | |
1260 | 1260 | case 'entry_id': |
1261 | - $updated_field['key'] = 'entry_id'; |
|
1262 | - $updated_field['input'] = 'entry_id'; |
|
1263 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1261 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1262 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1263 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1264 | 1264 | break; |
1265 | 1265 | |
1266 | 1266 | case 'created_by': |
1267 | - $updated_field['key'] = 'created_by'; |
|
1268 | - $updated_field['name'] = 'gv_by'; |
|
1269 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1270 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
1267 | + $updated_field[ 'key' ] = 'created_by'; |
|
1268 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1269 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1270 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
1271 | 1271 | break; |
1272 | 1272 | |
1273 | 1273 | case 'is_approved': |
1274 | - $updated_field['key'] = 'is_approved'; |
|
1275 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1276 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1274 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1275 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1276 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1277 | 1277 | break; |
1278 | 1278 | } |
1279 | 1279 | |
@@ -1292,16 +1292,16 @@ discard block |
||
1292 | 1292 | */ |
1293 | 1293 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1294 | 1294 | |
1295 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1295 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1296 | 1296 | |
1297 | 1297 | /** @since 1.14 */ |
1298 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1298 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1299 | 1299 | |
1300 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1300 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1301 | 1301 | |
1302 | 1302 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1303 | 1303 | |
1304 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1304 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1305 | 1305 | |
1306 | 1306 | if ( $this->has_date_field( $search_fields ) ) { |
1307 | 1307 | // enqueue datepicker stuff only if needed! |
@@ -1323,10 +1323,10 @@ discard block |
||
1323 | 1323 | public static function get_search_class( $custom_class = '' ) { |
1324 | 1324 | $gravityview_view = GravityView_View::getInstance(); |
1325 | 1325 | |
1326 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1326 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1327 | 1327 | |
1328 | - if ( ! empty( $custom_class ) ) { |
|
1329 | - $search_class .= ' '.$custom_class; |
|
1328 | + if ( ! empty( $custom_class ) ) { |
|
1329 | + $search_class .= ' ' . $custom_class; |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | /** |
@@ -1370,9 +1370,9 @@ discard block |
||
1370 | 1370 | |
1371 | 1371 | if ( ! $label ) { |
1372 | 1372 | |
1373 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1373 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1374 | 1374 | |
1375 | - switch( $field['field'] ) { |
|
1375 | + switch ( $field[ 'field' ] ) { |
|
1376 | 1376 | case 'search_all': |
1377 | 1377 | $label = __( 'Search Entries:', 'gravityview' ); |
1378 | 1378 | break; |
@@ -1384,10 +1384,10 @@ discard block |
||
1384 | 1384 | break; |
1385 | 1385 | default: |
1386 | 1386 | // If this is a field input, not a field |
1387 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1387 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1388 | 1388 | |
1389 | 1389 | // Get the label for the field in question, which returns an array |
1390 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1390 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1391 | 1391 | |
1392 | 1392 | // Get the item with the `label` key |
1393 | 1393 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1426,32 +1426,32 @@ discard block |
||
1426 | 1426 | $form = $gravityview_view->getForm(); |
1427 | 1427 | |
1428 | 1428 | // for advanced field ids (eg, first name / last name ) |
1429 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1429 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1430 | 1430 | |
1431 | 1431 | // get searched value from $_GET/$_POST (string or array) |
1432 | 1432 | $value = $this->rgget_or_rgpost( $name ); |
1433 | 1433 | |
1434 | 1434 | // get form field details |
1435 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1435 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1436 | 1436 | |
1437 | 1437 | $filter = array( |
1438 | - 'key' => $field['field'], |
|
1438 | + 'key' => $field[ 'field' ], |
|
1439 | 1439 | 'name' => $name, |
1440 | 1440 | 'label' => self::get_field_label( $field, $form_field ), |
1441 | - 'input' => $field['input'], |
|
1441 | + 'input' => $field[ 'input' ], |
|
1442 | 1442 | 'value' => $value, |
1443 | - 'type' => $form_field['type'], |
|
1443 | + 'type' => $form_field[ 'type' ], |
|
1444 | 1444 | ); |
1445 | 1445 | |
1446 | 1446 | // collect choices |
1447 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1448 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1449 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1450 | - $filter['choices'] = $form_field['choices']; |
|
1447 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1448 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1449 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1450 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1451 | 1451 | } |
1452 | 1452 | |
1453 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1454 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1453 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1454 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | return $filter; |
@@ -1475,7 +1475,7 @@ discard block |
||
1475 | 1475 | |
1476 | 1476 | $choices = array(); |
1477 | 1477 | foreach ( $users as $user ) { |
1478 | - $choices[] = array( |
|
1478 | + $choices[ ] = array( |
|
1479 | 1479 | 'value' => $user->ID, |
1480 | 1480 | 'text' => $user->display_name, |
1481 | 1481 | ); |
@@ -1495,9 +1495,9 @@ discard block |
||
1495 | 1495 | |
1496 | 1496 | $choices = array(); |
1497 | 1497 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1498 | - $choices[] = array( |
|
1499 | - 'value' => $status['value'], |
|
1500 | - 'text' => $status['label'], |
|
1498 | + $choices[ ] = array( |
|
1499 | + 'value' => $status[ 'value' ], |
|
1500 | + 'text' => $status[ 'label' ], |
|
1501 | 1501 | ); |
1502 | 1502 | } |
1503 | 1503 | |
@@ -1549,7 +1549,7 @@ discard block |
||
1549 | 1549 | */ |
1550 | 1550 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1551 | 1551 | |
1552 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1552 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1553 | 1553 | |
1554 | 1554 | return $js_dependencies; |
1555 | 1555 | } |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | 'isRTL' => is_rtl(), |
1594 | 1594 | ), $view_data ); |
1595 | 1595 | |
1596 | - $localizations['datepicker'] = $datepicker_settings; |
|
1596 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1597 | 1597 | |
1598 | 1598 | return $localizations; |
1599 | 1599 | |
@@ -1620,7 +1620,7 @@ discard block |
||
1620 | 1620 | * @return void |
1621 | 1621 | */ |
1622 | 1622 | private function maybe_enqueue_flexibility() { |
1623 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1623 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1624 | 1624 | wp_enqueue_script( 'gv-flexibility' ); |
1625 | 1625 | } |
1626 | 1626 | } |
@@ -1642,7 +1642,7 @@ discard block |
||
1642 | 1642 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1643 | 1643 | |
1644 | 1644 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1645 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1645 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1646 | 1646 | |
1647 | 1647 | /** |
1648 | 1648 | * @filter `gravityview_search_datepicker_class` |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | public function add_preview_inputs() { |
1722 | 1722 | global $wp; |
1723 | 1723 | |
1724 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
1724 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
1725 | 1725 | return; |
1726 | 1726 | } |
1727 | 1727 | |
@@ -1746,7 +1746,7 @@ discard block |
||
1746 | 1746 | */ |
1747 | 1747 | class GravityView_Widget_Search_GF_Query_Condition extends \GF_Query_Condition { |
1748 | 1748 | public function __construct( $filter, $view ) { |
1749 | - $this->value = $filter['value']; |
|
1749 | + $this->value = $filter[ 'value' ]; |
|
1750 | 1750 | $this->view = $view; |
1751 | 1751 | } |
1752 | 1752 | |
@@ -1778,11 +1778,11 @@ discard block |
||
1778 | 1778 | $conditions = array(); |
1779 | 1779 | |
1780 | 1780 | foreach ( $user_fields as $user_field ) { |
1781 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1781 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | foreach ( $user_meta_fields as $meta_field ) { |
1785 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1785 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1786 | 1786 | } |
1787 | 1787 | |
1788 | 1788 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $supports = array( 'title', 'revisions' ); |
109 | 109 | |
110 | 110 | if ( $is_hierarchical ) { |
111 | - $supports[] = 'page-attributes'; |
|
111 | + $supports[ ] = 'page-attributes'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | $rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' ); |
211 | 211 | |
212 | 212 | add_filter( 'query_vars', function( $query_vars ) { |
213 | - $query_vars[] = 'csv'; |
|
213 | + $query_vars[ ] = 'csv'; |
|
214 | 214 | return $query_vars; |
215 | 215 | } ); |
216 | 216 | |
217 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) { |
|
217 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) { |
|
218 | 218 | call_user_func_array( 'add_rewrite_rule', $rule ); |
219 | 219 | } |
220 | 220 | } |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | return $content; |
284 | 284 | } |
285 | 285 | |
286 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
286 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Editing a single entry. |
290 | 290 | */ |
291 | 291 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
292 | - if ( $entry['status'] != 'active' ) { |
|
292 | + if ( $entry[ 'status' ] != 'active' ) { |
|
293 | 293 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
294 | 294 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
295 | 295 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
303 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
303 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
304 | 304 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
305 | 305 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
306 | 306 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | foreach ( $entryset as $e ) { |
325 | 325 | |
326 | - if ( 'active' !== $e['status'] ) { |
|
326 | + if ( 'active' !== $e[ 'status' ] ) { |
|
327 | 327 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
328 | 328 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
329 | 329 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | if ( $show_only_approved && ! $is_admin_and_can_view ) { |
337 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
337 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
338 | 338 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
339 | 339 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
340 | 340 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
510 | 510 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
511 | 511 | |
512 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
512 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | return $joins; |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | if ( ! $view->form ) { |
605 | 605 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
606 | 606 | 'view_id' => $view->ID, |
607 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
607 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
608 | 608 | ) ); |
609 | 609 | } |
610 | 610 | |
@@ -837,34 +837,33 @@ discard block |
||
837 | 837 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
838 | 838 | */ |
839 | 839 | $parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
840 | - $parameters['context_view_id'] = $this->ID; |
|
840 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
841 | 841 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
842 | 842 | |
843 | 843 | if ( $request instanceof REST\Request ) { |
844 | 844 | $atts = $this->settings->as_atts(); |
845 | 845 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
846 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
846 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
847 | 847 | ) ); |
848 | - $parameters['paging'] = $paging_parameters['paging']; |
|
848 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
849 | 849 | } |
850 | 850 | |
851 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
852 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
851 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
853 | 852 | |
854 | 853 | /** |
855 | 854 | * Cleanup duplicate field_filter parameters to simplify the query. |
856 | 855 | */ |
857 | 856 | $unique_field_filters = array(); |
858 | - foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
857 | + foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
859 | 858 | if ( 'mode' === $key ) { |
860 | - $unique_field_filters['mode'] = $filter; |
|
859 | + $unique_field_filters[ 'mode' ] = $filter; |
|
861 | 860 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
862 | - $unique_field_filters[] = $filter; |
|
861 | + $unique_field_filters[ ] = $filter; |
|
863 | 862 | } |
864 | 863 | } |
865 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
864 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
866 | 865 | |
867 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
866 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
868 | 867 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
869 | 868 | } |
870 | 869 | |
@@ -872,10 +871,10 @@ discard block |
||
872 | 871 | /** |
873 | 872 | * New \GF_Query stuff :) |
874 | 873 | */ |
875 | - $query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
874 | + $query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
876 | 875 | |
877 | - $query->limit( $parameters['paging']['page_size'] ) |
|
878 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
876 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
877 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
879 | 878 | |
880 | 879 | /** |
881 | 880 | * Any joins? |
@@ -917,15 +916,15 @@ discard block |
||
917 | 916 | } ); |
918 | 917 | } else { |
919 | 918 | $entries = $this->form->entries |
920 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
919 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
921 | 920 | ->offset( $this->settings->get( 'offset' ) ) |
922 | - ->limit( $parameters['paging']['page_size'] ) |
|
921 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
923 | 922 | ->page( $page ); |
924 | 923 | |
925 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
924 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
926 | 925 | $field = new \GV\Field(); |
927 | - $field->ID = $parameters['sorting']['key']; |
|
928 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
926 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
927 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
929 | 928 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
930 | 929 | } |
931 | 930 | } |