@@ -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 |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
228 | 228 | $script_source = empty( $script_min ) ? '/source' : ''; |
229 | 229 | |
230 | - 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 ); |
|
230 | + 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 ); |
|
231 | 231 | |
232 | 232 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
233 | 233 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
250 | 250 | */ |
251 | 251 | public function register_no_conflict( $allowed ) { |
252 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
252 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
253 | 253 | return $allowed; |
254 | 254 | } |
255 | 255 | |
@@ -262,24 +262,24 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public static function get_searchable_fields() { |
264 | 264 | |
265 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
265 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
266 | 266 | exit( '0' ); |
267 | 267 | } |
268 | 268 | |
269 | 269 | $form = ''; |
270 | 270 | |
271 | 271 | // Fetch the form for the current View |
272 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
272 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
273 | 273 | |
274 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
274 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
275 | 275 | |
276 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
276 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
277 | 277 | |
278 | - $form = (int) $_POST['formid']; |
|
278 | + $form = (int)$_POST[ 'formid' ]; |
|
279 | 279 | |
280 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
280 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
281 | 281 | |
282 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
282 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
283 | 283 | |
284 | 284 | } |
285 | 285 | |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | ); |
330 | 330 | |
331 | 331 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
332 | - $custom_fields['is_approved'] = array( |
|
332 | + $custom_fields[ 'is_approved' ] = array( |
|
333 | 333 | 'text' => esc_html__( 'Is Approved', 'gravityview' ), |
334 | 334 | 'type' => 'boolean', |
335 | 335 | ); |
336 | 336 | } |
337 | 337 | |
338 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
339 | - $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'] ); |
|
338 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
339 | + $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 | 340 | } |
341 | 341 | |
342 | 342 | // Get fields with sub-inputs and no parent |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | |
359 | 359 | foreach ( $fields as $id => $field ) { |
360 | 360 | |
361 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
361 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
362 | 362 | continue; |
363 | 363 | } |
364 | 364 | |
365 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
365 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
366 | 366 | |
367 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
367 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
388 | 388 | |
389 | 389 | // @todo - This needs to be improved - many fields have . including products and addresses |
390 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
390 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
391 | 391 | $input_type = 'boolean'; // on/off checkbox |
392 | 392 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
393 | 393 | $input_type = 'multi'; //multiselect |
@@ -431,19 +431,19 @@ discard block |
||
431 | 431 | $post_id = 0; |
432 | 432 | |
433 | 433 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
434 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
435 | - $post_id = absint( $widget_args['post_id'] ); |
|
434 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
435 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
436 | 436 | } |
437 | 437 | // We're in the WordPress Widget context, and the base View ID should be used |
438 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
439 | - $post_id = absint( $widget_args['view_id'] ); |
|
438 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
439 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | $args = gravityview_get_permalink_query_args( $post_id ); |
443 | 443 | |
444 | 444 | // Add hidden fields to the search form |
445 | 445 | foreach ( $args as $key => $value ) { |
446 | - $search_fields[] = array( |
|
446 | + $search_fields[ ] = array( |
|
447 | 447 | 'name' => $key, |
448 | 448 | 'input' => 'hidden', |
449 | 449 | 'value' => $value, |
@@ -482,22 +482,22 @@ discard block |
||
482 | 482 | /** |
483 | 483 | * Include the sidebar Widgets. |
484 | 484 | */ |
485 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
485 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
486 | 486 | |
487 | 487 | foreach ( $widgets as $widget ) { |
488 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
489 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
488 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
489 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
490 | 490 | foreach ( $_fields as $field ) { |
491 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
491 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
492 | 492 | } |
493 | 493 | } |
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
498 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
498 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
499 | 499 | foreach ( $_fields as $field ) { |
500 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
500 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | } |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
528 | 528 | } |
529 | 529 | |
530 | - if( 'post' === $this->search_method ) { |
|
530 | + if ( 'post' === $this->search_method ) { |
|
531 | 531 | $get = $_POST; |
532 | 532 | } else { |
533 | 533 | $get = $_GET; |
@@ -546,14 +546,14 @@ discard block |
||
546 | 546 | $get = gv_map_deep( $get, 'rawurldecode' ); |
547 | 547 | |
548 | 548 | // Make sure array key is set up |
549 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
549 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
550 | 550 | |
551 | 551 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
552 | 552 | |
553 | 553 | // add free search |
554 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
554 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
555 | 555 | |
556 | - $search_all_value = trim( $get['gv_search'] ); |
|
556 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
557 | 557 | |
558 | 558 | /** |
559 | 559 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | } |
579 | 579 | |
580 | 580 | foreach ( $words as $word ) { |
581 | - $search_criteria['field_filters'][] = array( |
|
581 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
582 | 582 | 'key' => null, // The field ID to search |
583 | 583 | 'value' => $word, // The value to search |
584 | 584 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | /** |
592 | 592 | * Get and normalize the dates according to the input format. |
593 | 593 | */ |
594 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
595 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
594 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
595 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
596 | 596 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
600 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
601 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
600 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
601 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
602 | 602 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
603 | 603 | } |
604 | 604 | } |
@@ -633,22 +633,22 @@ discard block |
||
633 | 633 | */ |
634 | 634 | if ( ! empty( $curr_start ) ) { |
635 | 635 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
636 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
636 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | if ( ! empty( $curr_end ) ) { |
640 | 640 | // Fast-forward 24 hour on the end time |
641 | 641 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
642 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
643 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
644 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
642 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
643 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
644 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | } |
648 | 648 | |
649 | 649 | // search for a specific entry ID |
650 | 650 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
651 | - $search_criteria['field_filters'][] = array( |
|
651 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
652 | 652 | 'key' => 'id', |
653 | 653 | 'value' => absint( $get[ 'gv_id' ] ), |
654 | 654 | 'operator' => '=', |
@@ -657,41 +657,41 @@ discard block |
||
657 | 657 | |
658 | 658 | // search for a specific Created_by ID |
659 | 659 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
660 | - $search_criteria['field_filters'][] = array( |
|
660 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
661 | 661 | 'key' => 'created_by', |
662 | - 'value' => $get['gv_by'], |
|
662 | + 'value' => $get[ 'gv_by' ], |
|
663 | 663 | 'operator' => '=', |
664 | 664 | ); |
665 | 665 | } |
666 | 666 | |
667 | 667 | // Get search mode passed in URL |
668 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
668 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
669 | 669 | |
670 | 670 | // get the other search filters |
671 | 671 | foreach ( $get as $key => $value ) { |
672 | 672 | |
673 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
673 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
674 | 674 | continue; |
675 | 675 | } |
676 | 676 | |
677 | 677 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
678 | 678 | |
679 | 679 | // could return simple filter or multiple filters |
680 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
680 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
681 | 681 | continue; |
682 | 682 | } |
683 | 683 | |
684 | 684 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
685 | 685 | |
686 | - if ( isset( $filter[0]['value'] ) ) { |
|
687 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
686 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
687 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
688 | 688 | |
689 | 689 | // if date range type, set search mode to ALL |
690 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
690 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
691 | 691 | $mode = 'all'; |
692 | 692 | } |
693 | - } elseif( !empty( $filter ) ) { |
|
694 | - $search_criteria['field_filters'][] = $filter; |
|
693 | + } elseif ( ! empty( $filter ) ) { |
|
694 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * @since 1.5.1 |
701 | 701 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
702 | 702 | */ |
703 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
703 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
704 | 704 | |
705 | 705 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
706 | 706 | |
@@ -725,16 +725,16 @@ discard block |
||
725 | 725 | */ |
726 | 726 | $search_criteria = $this->filter_entries( array(), null, array( 'id' => $view->ID ), true /** force search_criteria */ ); |
727 | 727 | |
728 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
728 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
729 | 729 | return; |
730 | 730 | } |
731 | 731 | |
732 | 732 | $widgets = $view->widgets->by_id( $this->widget_id ); |
733 | 733 | if ( $widgets->count() ) { |
734 | 734 | $widgets = $widgets->all(); |
735 | - $widget = $widgets[0]; |
|
735 | + $widget = $widgets[ 0 ]; |
|
736 | 736 | foreach ( $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) as $search_field ) { |
737 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
737 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
738 | 738 | $created_by_text_mode = true; |
739 | 739 | } |
740 | 740 | } |
@@ -742,19 +742,19 @@ discard block |
||
742 | 742 | |
743 | 743 | $extra_conditions = array(); |
744 | 744 | |
745 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
745 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
746 | 746 | if ( ! is_array( $filter ) ) { |
747 | 747 | continue; |
748 | 748 | } |
749 | 749 | |
750 | 750 | // Construct a manual query for unapproved statuses |
751 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, $filter['value'] ) ) { |
|
752 | - $_tmp_query = new GF_Query( $view->form->ID, array( |
|
751 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, $filter[ 'value' ] ) ) { |
|
752 | + $_tmp_query = new GF_Query( $view->form->ID, array( |
|
753 | 753 | 'field_filters' => array( |
754 | 754 | array( |
755 | 755 | 'operator' => 'in', |
756 | 756 | 'key' => 'is_approved', |
757 | - 'value' => $filter['value'], |
|
757 | + 'value' => $filter[ 'value' ], |
|
758 | 758 | ), |
759 | 759 | array( |
760 | 760 | 'operator' => 'is', |
@@ -766,25 +766,25 @@ discard block |
||
766 | 766 | ) ); |
767 | 767 | $_tmp_query_parts = $_tmp_query->_introspect(); |
768 | 768 | |
769 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
769 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
770 | 770 | |
771 | 771 | $filter = false; |
772 | 772 | continue; |
773 | 773 | } |
774 | 774 | |
775 | 775 | // Construct manual query for text mode creator search |
776 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
777 | - $extra_conditions[] = new GravityView_Widget_Search_GF_Query_Condition( $filter, $view ); |
|
776 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
777 | + $extra_conditions[ ] = new GravityView_Widget_Search_GF_Query_Condition( $filter, $view ); |
|
778 | 778 | $filter = false; |
779 | 779 | continue; |
780 | 780 | } |
781 | 781 | |
782 | 782 | // By default, we want searches to be wildcard for each field. |
783 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
783 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
784 | 784 | |
785 | 785 | // For multichoice, let's have an in (OR) search. |
786 | - if ( is_array( $filter['value'] ) ) { |
|
787 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
786 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
787 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | /** |
@@ -792,10 +792,10 @@ discard block |
||
792 | 792 | * @param string $operator Existing search operator |
793 | 793 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
794 | 794 | */ |
795 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
795 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
796 | 796 | } |
797 | 797 | |
798 | - $search_criteria['field_filters'] = array_filter( $search_criteria['field_filters'] ); |
|
798 | + $search_criteria[ 'field_filters' ] = array_filter( $search_criteria[ 'field_filters' ] ); |
|
799 | 799 | |
800 | 800 | /** |
801 | 801 | * Parse the filter criteria to generate the needed |
@@ -808,12 +808,12 @@ discard block |
||
808 | 808 | /** |
809 | 809 | * Grab the current clauses. We'll be combining them shortly. |
810 | 810 | */ |
811 | - $query_parts = $query->_introspect(); |
|
811 | + $query_parts = $query->_introspect(); |
|
812 | 812 | |
813 | 813 | /** |
814 | 814 | * Combine the parts as a new WHERE clause. |
815 | 815 | */ |
816 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'], $_tmp_query_parts['where'] ), $extra_conditions ) ); |
|
816 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ], $_tmp_query_parts[ 'where' ] ), $extra_conditions ) ); |
|
817 | 817 | $query->where( $where ); |
818 | 818 | } |
819 | 819 | |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | $field_id = str_replace( 'filter_', '', $key ); |
837 | 837 | |
838 | 838 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
839 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
839 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
840 | 840 | $field_id = str_replace( '_', '.', $field_id ); |
841 | 841 | } |
842 | 842 | |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | |
872 | 872 | case 'select': |
873 | 873 | case 'radio': |
874 | - $filter['operator'] = 'is'; |
|
874 | + $filter[ 'operator' ] = 'is'; |
|
875 | 875 | break; |
876 | 876 | |
877 | 877 | case 'post_category': |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | |
886 | 886 | foreach ( $value as $val ) { |
887 | 887 | $cat = get_term( $val, 'category' ); |
888 | - $filter[] = array( |
|
888 | + $filter[ ] = array( |
|
889 | 889 | 'key' => $filter_key, |
890 | 890 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
891 | 891 | 'operator' => 'is', |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | $filter = array(); |
905 | 905 | |
906 | 906 | foreach ( $value as $val ) { |
907 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
907 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | break; |
@@ -913,9 +913,9 @@ discard block |
||
913 | 913 | // convert checkbox on/off into the correct search filter |
914 | 914 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
915 | 915 | foreach ( $form_field->inputs as $k => $input ) { |
916 | - if ( $input['id'] == $filter_key ) { |
|
917 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
918 | - $filter['operator'] = 'is'; |
|
916 | + if ( $input[ 'id' ] == $filter_key ) { |
|
917 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
918 | + $filter[ 'operator' ] = 'is'; |
|
919 | 919 | break; |
920 | 920 | } |
921 | 921 | } |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | $filter = array(); |
926 | 926 | |
927 | 927 | foreach ( $value as $val ) { |
928 | - $filter[] = array( |
|
928 | + $filter[ ] = array( |
|
929 | 929 | 'key' => $filter_key, |
930 | 930 | 'value' => $val, |
931 | 931 | 'operator' => 'is', |
@@ -946,9 +946,9 @@ discard block |
||
946 | 946 | foreach ( $words as $word ) { |
947 | 947 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
948 | 948 | // Keep the same key for each filter |
949 | - $filter['value'] = $word; |
|
949 | + $filter[ 'value' ] = $word; |
|
950 | 950 | // Add a search for the value |
951 | - $filters[] = $filter; |
|
951 | + $filters[ ] = $filter; |
|
952 | 952 | } |
953 | 953 | } |
954 | 954 | |
@@ -962,19 +962,19 @@ discard block |
||
962 | 962 | |
963 | 963 | foreach ( $searchable_fields as $searchable_field ) { |
964 | 964 | |
965 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
965 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
966 | 966 | continue; |
967 | 967 | } |
968 | 968 | |
969 | 969 | // Only exact-match dropdowns, not text search |
970 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
970 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
971 | 971 | continue; |
972 | 972 | } |
973 | 973 | |
974 | 974 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
975 | 975 | |
976 | 976 | if ( 4 === $input_id ) { |
977 | - $filter['operator'] = 'is'; |
|
977 | + $filter[ 'operator' ] = 'is'; |
|
978 | 978 | }; |
979 | 979 | } |
980 | 980 | } |
@@ -1001,12 +1001,12 @@ discard block |
||
1001 | 1001 | * @since 1.16.3 |
1002 | 1002 | * Safeguard until GF implements '<=' operator |
1003 | 1003 | */ |
1004 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1004 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1005 | 1005 | $operator = '<'; |
1006 | 1006 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - $filter[] = array( |
|
1009 | + $filter[ ] = array( |
|
1010 | 1010 | 'key' => $filter_key, |
1011 | 1011 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1012 | 1012 | 'operator' => $operator, |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | } |
1015 | 1015 | } else { |
1016 | 1016 | $date = $value; |
1017 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1017 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | break; |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | 'ymd_dot' => 'Y.m.d', |
1046 | 1046 | ); |
1047 | 1047 | |
1048 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1048 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1049 | 1049 | $format = $datepicker[ $field->dateFormat ]; |
1050 | 1050 | } |
1051 | 1051 | |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | public function add_template_path( $file_paths ) { |
1083 | 1083 | |
1084 | 1084 | // Index 100 is the default GravityView template path. |
1085 | - $file_paths[102] = self::$file . 'templates/'; |
|
1085 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1086 | 1086 | |
1087 | 1087 | return $file_paths; |
1088 | 1088 | } |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | $has_date = false; |
1102 | 1102 | |
1103 | 1103 | foreach ( $search_fields as $k => $field ) { |
1104 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1104 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1105 | 1105 | $has_date = true; |
1106 | 1106 | break; |
1107 | 1107 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | // get configured search fields |
1131 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1131 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1132 | 1132 | |
1133 | 1133 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1134 | 1134 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1143,41 +1143,41 @@ discard block |
||
1143 | 1143 | |
1144 | 1144 | $updated_field = $this->get_search_filter_details( $updated_field ); |
1145 | 1145 | |
1146 | - switch ( $field['field'] ) { |
|
1146 | + switch ( $field[ 'field' ] ) { |
|
1147 | 1147 | |
1148 | 1148 | case 'search_all': |
1149 | - $updated_field['key'] = 'search_all'; |
|
1150 | - $updated_field['input'] = 'search_all'; |
|
1151 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1149 | + $updated_field[ 'key' ] = 'search_all'; |
|
1150 | + $updated_field[ 'input' ] = 'search_all'; |
|
1151 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1152 | 1152 | break; |
1153 | 1153 | |
1154 | 1154 | case 'entry_date': |
1155 | - $updated_field['key'] = 'entry_date'; |
|
1156 | - $updated_field['input'] = 'entry_date'; |
|
1157 | - $updated_field['value'] = array( |
|
1155 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1156 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1157 | + $updated_field[ 'value' ] = array( |
|
1158 | 1158 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1159 | 1159 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1160 | 1160 | ); |
1161 | 1161 | break; |
1162 | 1162 | |
1163 | 1163 | case 'entry_id': |
1164 | - $updated_field['key'] = 'entry_id'; |
|
1165 | - $updated_field['input'] = 'entry_id'; |
|
1166 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1164 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1165 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1166 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1167 | 1167 | break; |
1168 | 1168 | |
1169 | 1169 | case 'created_by': |
1170 | - $updated_field['key'] = 'created_by'; |
|
1171 | - $updated_field['name'] = 'gv_by'; |
|
1172 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1173 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
1170 | + $updated_field[ 'key' ] = 'created_by'; |
|
1171 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1172 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1173 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
1174 | 1174 | break; |
1175 | 1175 | |
1176 | 1176 | case 'is_approved': |
1177 | - $updated_field['key'] = 'is_approved'; |
|
1178 | - $updated_field['input'] = 'checkbox'; |
|
1179 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1180 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1177 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1178 | + $updated_field[ 'input' ] = 'checkbox'; |
|
1179 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1180 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1181 | 1181 | break; |
1182 | 1182 | } |
1183 | 1183 | |
@@ -1196,16 +1196,16 @@ discard block |
||
1196 | 1196 | */ |
1197 | 1197 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1198 | 1198 | |
1199 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1199 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1200 | 1200 | |
1201 | 1201 | /** @since 1.14 */ |
1202 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1202 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1203 | 1203 | |
1204 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1204 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1205 | 1205 | |
1206 | 1206 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1207 | 1207 | |
1208 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1208 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1209 | 1209 | |
1210 | 1210 | if ( $this->has_date_field( $search_fields ) ) { |
1211 | 1211 | // enqueue datepicker stuff only if needed! |
@@ -1227,10 +1227,10 @@ discard block |
||
1227 | 1227 | public static function get_search_class( $custom_class = '' ) { |
1228 | 1228 | $gravityview_view = GravityView_View::getInstance(); |
1229 | 1229 | |
1230 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1230 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1231 | 1231 | |
1232 | - if ( ! empty( $custom_class ) ) { |
|
1233 | - $search_class .= ' '.$custom_class; |
|
1232 | + if ( ! empty( $custom_class ) ) { |
|
1233 | + $search_class .= ' ' . $custom_class; |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | /** |
@@ -1274,9 +1274,9 @@ discard block |
||
1274 | 1274 | |
1275 | 1275 | if ( ! $label ) { |
1276 | 1276 | |
1277 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1277 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1278 | 1278 | |
1279 | - switch( $field['field'] ) { |
|
1279 | + switch ( $field[ 'field' ] ) { |
|
1280 | 1280 | case 'search_all': |
1281 | 1281 | $label = __( 'Search Entries:', 'gravityview' ); |
1282 | 1282 | break; |
@@ -1288,10 +1288,10 @@ discard block |
||
1288 | 1288 | break; |
1289 | 1289 | default: |
1290 | 1290 | // If this is a field input, not a field |
1291 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1291 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1292 | 1292 | |
1293 | 1293 | // Get the label for the field in question, which returns an array |
1294 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1294 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1295 | 1295 | |
1296 | 1296 | // Get the item with the `label` key |
1297 | 1297 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1330,32 +1330,32 @@ discard block |
||
1330 | 1330 | $form = $gravityview_view->getForm(); |
1331 | 1331 | |
1332 | 1332 | // for advanced field ids (eg, first name / last name ) |
1333 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1333 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1334 | 1334 | |
1335 | 1335 | // get searched value from $_GET/$_POST (string or array) |
1336 | 1336 | $value = $this->rgget_or_rgpost( $name ); |
1337 | 1337 | |
1338 | 1338 | // get form field details |
1339 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1339 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1340 | 1340 | |
1341 | 1341 | $filter = array( |
1342 | - 'key' => $field['field'], |
|
1342 | + 'key' => $field[ 'field' ], |
|
1343 | 1343 | 'name' => $name, |
1344 | 1344 | 'label' => self::get_field_label( $field, $form_field ), |
1345 | - 'input' => $field['input'], |
|
1345 | + 'input' => $field[ 'input' ], |
|
1346 | 1346 | 'value' => $value, |
1347 | - 'type' => $form_field['type'], |
|
1347 | + 'type' => $form_field[ 'type' ], |
|
1348 | 1348 | ); |
1349 | 1349 | |
1350 | 1350 | // collect choices |
1351 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1352 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1353 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1354 | - $filter['choices'] = $form_field['choices']; |
|
1351 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1352 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1353 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1354 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1358 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1357 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1358 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | return $filter; |
@@ -1379,7 +1379,7 @@ discard block |
||
1379 | 1379 | |
1380 | 1380 | $choices = array(); |
1381 | 1381 | foreach ( $users as $user ) { |
1382 | - $choices[] = array( |
|
1382 | + $choices[ ] = array( |
|
1383 | 1383 | 'value' => $user->ID, |
1384 | 1384 | 'text' => $user->display_name, |
1385 | 1385 | ); |
@@ -1399,9 +1399,9 @@ discard block |
||
1399 | 1399 | |
1400 | 1400 | $choices = array(); |
1401 | 1401 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1402 | - $choices[] = array( |
|
1403 | - 'value' => $status['value'], |
|
1404 | - 'text' => $status['label'], |
|
1402 | + $choices[ ] = array( |
|
1403 | + 'value' => $status[ 'value' ], |
|
1404 | + 'text' => $status[ 'label' ], |
|
1405 | 1405 | ); |
1406 | 1406 | } |
1407 | 1407 | |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | */ |
1454 | 1454 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1455 | 1455 | |
1456 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1456 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1457 | 1457 | |
1458 | 1458 | return $js_dependencies; |
1459 | 1459 | } |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | 'isRTL' => is_rtl(), |
1498 | 1498 | ), $view_data ); |
1499 | 1499 | |
1500 | - $localizations['datepicker'] = $datepicker_settings; |
|
1500 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1501 | 1501 | |
1502 | 1502 | return $localizations; |
1503 | 1503 | |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | * @return void |
1525 | 1525 | */ |
1526 | 1526 | private function maybe_enqueue_flexibility() { |
1527 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1527 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1528 | 1528 | wp_enqueue_script( 'gv-flexibility' ); |
1529 | 1529 | } |
1530 | 1530 | } |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1547 | 1547 | |
1548 | 1548 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1549 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1549 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1550 | 1550 | |
1551 | 1551 | /** |
1552 | 1552 | * @filter `gravityview_search_datepicker_class` |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | */ |
1630 | 1630 | class GravityView_Widget_Search_GF_Query_Condition extends \GF_Query_Condition { |
1631 | 1631 | public function __construct( $filter, $view ) { |
1632 | - $this->value = $filter['value']; |
|
1632 | + $this->value = $filter[ 'value' ]; |
|
1633 | 1633 | $this->view = $view; |
1634 | 1634 | } |
1635 | 1635 | |
@@ -1663,11 +1663,11 @@ discard block |
||
1663 | 1663 | $conditions = array(); |
1664 | 1664 | |
1665 | 1665 | foreach ( $user_fields as $user_field ) { |
1666 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1666 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1667 | 1667 | } |
1668 | 1668 | |
1669 | 1669 | foreach ( $user_meta_fields as $meta_field ) { |
1670 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1670 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1671 | 1671 | } |
1672 | 1672 | |
1673 | 1673 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | public static function is_value_match( $field_value, $target_value, $operation = 'is', $source_field = null, $rule = null, $form = null ) { |
41 | 41 | |
42 | 42 | if ( in_array( $source_field, array( 'date_created', 'date_updated', 'payment_date' ), true ) ) { |
43 | - $field_value = is_int( $field_value )? $field_value : strtotime( $field_value ); |
|
44 | - $target_value = is_int( $target_value )? $target_value : strtotime( $target_value ); |
|
43 | + $field_value = is_int( $field_value ) ? $field_value : strtotime( $field_value ); |
|
44 | + $target_value = is_int( $target_value ) ? $target_value : strtotime( $target_value ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | if ( $source_field instanceof GF_Field && $source_field->type == 'date' ) { |
48 | - $field_value = is_int( $field_value )? $field_value : strtotime( $field_value ); |
|
49 | - $target_value = is_int( $target_value )? $target_value : strtotime( $target_value ); |
|
48 | + $field_value = is_int( $field_value ) ? $field_value : strtotime( $field_value ); |
|
49 | + $target_value = is_int( $target_value ) ? $target_value : strtotime( $target_value ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | if ( in_array( $_operation = str_replace( ' ', '_', trim( $operation ) ), array( 'in', 'not_in' ) ) ) { |
53 | - return GVCommon::matches_operation( (array) $field_value, (array) $target_value, $_operation ); |
|
53 | + return GVCommon::matches_operation( (array)$field_value, (array)$target_value, $_operation ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return parent::is_value_match( $field_value, $target_value, $operation, $source_field, $rule, $form ); |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | |
75 | 75 | $post_data = self::get_post_fields( $form, $entry ); |
76 | 76 | |
77 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
77 | + $media = get_attached_media( 'image', $entry[ 'post_id' ] ); |
|
78 | 78 | |
79 | 79 | $post_images = array(); |
80 | 80 | |
81 | 81 | foreach ( $media as $media_item ) { |
82 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
83 | - if( |
|
82 | + foreach ( (array)$post_data[ 'images' ] as $post_data_item ) { |
|
83 | + if ( |
|
84 | 84 | \GV\Utils::get( $post_data_item, 'title' ) === $media_item->post_title && |
85 | 85 | \GV\Utils::get( $post_data_item, 'description' ) === $media_item->post_content && |
86 | 86 | \GV\Utils::get( $post_data_item, 'caption' ) === $media_item->post_excerpt |
87 | 87 | ) { |
88 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
88 | + $post_images[ "{$post_data_item[ 'field_id' ]}" ] = $media_item->ID; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * If the method changes to public, use Gravity Forms' method |
114 | 114 | * @todo: If/when the method is public, remove the unneeded copied code. |
115 | 115 | */ |
116 | - if( $reflection->isPublic() ) { |
|
116 | + if ( $reflection->isPublic() ) { |
|
117 | 117 | return parent::get_post_fields( $form, $entry ); |
118 | 118 | } |
119 | 119 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * If the method changes to public, use Gravity Forms' method |
141 | 141 | * @todo: If/when the method is public, remove the unneeded copied code. |
142 | 142 | */ |
143 | - if( $reflection->isPublic() ) { |
|
143 | + if ( $reflection->isPublic() ) { |
|
144 | 144 | return parent::copy_post_image( $url, $post_id ); |
145 | 145 | } |
146 | 146 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * If the method changes to public, use Gravity Forms' method |
176 | 176 | * @todo: If/when the method is public, remove the unneeded copied code. |
177 | 177 | */ |
178 | - if( $reflection->isPublic() ) { |
|
178 | + if ( $reflection->isPublic() ) { |
|
179 | 179 | return parent::media_handle_upload( $url, $post_id, $post_data ); |
180 | 180 | } |
181 | 181 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | $form = $gravityview_view->getForm(); |
33 | 33 | |
34 | - if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS['GravityView_API_field_label_override'] ) ) { |
|
34 | + if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS[ 'GravityView_API_field_label_override' ] ) ) { |
|
35 | 35 | /** Allow to fall through for back compatibility testing purposes. */ |
36 | 36 | } else { |
37 | 37 | return \GV\Mocks\GravityView_API_field_label( $form, $field, $entry, $force_show_label ); |
@@ -39,29 +39,29 @@ discard block |
||
39 | 39 | |
40 | 40 | $label = ''; |
41 | 41 | |
42 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
42 | + if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) { |
|
43 | 43 | |
44 | - $label = $field['label']; |
|
44 | + $label = $field[ 'label' ]; |
|
45 | 45 | |
46 | 46 | // Support Gravity Forms 1.9+ |
47 | - if( class_exists( 'GF_Field' ) ) { |
|
47 | + if ( class_exists( 'GF_Field' ) ) { |
|
48 | 48 | |
49 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
49 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
50 | 50 | |
51 | - if( $field_object ) { |
|
51 | + if ( $field_object ) { |
|
52 | 52 | |
53 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
53 | + $input = GFFormsModel::get_input( $field_object, $field[ 'id' ] ); |
|
54 | 54 | |
55 | 55 | // This is a complex field, with labels on a per-input basis |
56 | - if( $input ) { |
|
56 | + if ( $input ) { |
|
57 | 57 | |
58 | 58 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
59 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
59 | + $label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ]; |
|
60 | 60 | |
61 | 61 | } else { |
62 | 62 | |
63 | 63 | // This is a field with one label |
64 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
64 | + $label = $field_object->get_field_label( true, $field[ 'label' ] ); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
73 | - if ( !empty( $field['custom_label'] ) ) { |
|
73 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
74 | 74 | |
75 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
75 | + $label = self::replace_variables( $field[ 'custom_label' ], $form, $entry ); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | |
135 | 135 | $width = NULL; |
136 | 136 | |
137 | - if( !empty( $field['width'] ) ) { |
|
138 | - $width = absint( $field['width'] ); |
|
137 | + if ( ! empty( $field[ 'width' ] ) ) { |
|
138 | + $width = absint( $field[ 'width' ] ); |
|
139 | 139 | |
140 | 140 | // If using percentages, limit to 100% |
141 | - if( '%d%%' === $format && $width > 100 ) { |
|
141 | + if ( '%d%%' === $format && $width > 100 ) { |
|
142 | 142 | $width = 100; |
143 | 143 | } |
144 | 144 | |
@@ -159,42 +159,42 @@ discard block |
||
159 | 159 | public static function field_class( $field, $form = NULL, $entry = NULL ) { |
160 | 160 | $classes = array(); |
161 | 161 | |
162 | - if( !empty( $field['custom_class'] ) ) { |
|
162 | + if ( ! empty( $field[ 'custom_class' ] ) ) { |
|
163 | 163 | |
164 | - $custom_class = $field['custom_class']; |
|
164 | + $custom_class = $field[ 'custom_class' ]; |
|
165 | 165 | |
166 | - if( !empty( $entry ) ) { |
|
166 | + if ( ! empty( $entry ) ) { |
|
167 | 167 | |
168 | 168 | // We want the merge tag to be formatted as a class. The merge tag may be |
169 | 169 | // replaced by a multiple-word value that should be output as a single class. |
170 | 170 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
171 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
171 | + add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
172 | 172 | |
173 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
173 | + $custom_class = self::replace_variables( $custom_class, $form, $entry ); |
|
174 | 174 | |
175 | 175 | // And then we want life to return to normal |
176 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
176 | + remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | // And now we want the spaces to be handled nicely. |
180 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
180 | + $classes[ ] = gravityview_sanitize_html_class( $custom_class ); |
|
181 | 181 | |
182 | 182 | } |
183 | 183 | |
184 | - if(!empty($field['id'])) { |
|
185 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
186 | - $form_id = '-'.$form['id']; |
|
184 | + if ( ! empty( $field[ 'id' ] ) ) { |
|
185 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
186 | + $form_id = '-' . $form[ 'id' ]; |
|
187 | 187 | } else { |
188 | 188 | // @deprecated path. Form should always be given. |
189 | 189 | gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' ); |
190 | 190 | $gravityview_view = GravityView_View::getInstance(); |
191 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
191 | + $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
192 | 192 | } |
193 | 193 | |
194 | - $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
|
194 | + $classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
195 | 195 | } |
196 | 196 | |
197 | - return esc_attr(implode(' ', $classes)); |
|
197 | + return esc_attr( implode( ' ', $classes ) ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | * @return string Sanitized unique HTML `id` attribute for the field |
211 | 211 | */ |
212 | 212 | public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
213 | - $id = $field['id']; |
|
213 | + $id = $field[ 'id' ]; |
|
214 | 214 | |
215 | 215 | if ( ! empty( $id ) ) { |
216 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
217 | - $form_id = '-' . $form['id']; |
|
216 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
217 | + $form_id = '-' . $form[ 'id' ]; |
|
218 | 218 | } else { |
219 | 219 | // @deprecated path. Form should always be given. |
220 | 220 | gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' ); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
223 | 223 | } |
224 | 224 | |
225 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
225 | + $id = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | return esc_attr( $id ); |
@@ -262,14 +262,14 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array(), $base_id = null ) { |
264 | 264 | |
265 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
265 | + if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) { |
|
266 | 266 | gravityview()->log->debug( 'Entry not defined; returning null', array( 'data' => $entry ) ); |
267 | 267 | return NULL; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $href = self::entry_link( $entry, $base_id ); |
271 | 271 | |
272 | - if( '' === $href ) { |
|
272 | + if ( '' === $href ) { |
|
273 | 273 | return NULL; |
274 | 274 | } |
275 | 275 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } else { |
307 | 307 | $gravityview_view = GravityView_View::getInstance(); |
308 | 308 | |
309 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
309 | + if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
310 | 310 | $is_search = true; |
311 | 311 | } |
312 | 312 | } |
@@ -403,9 +403,9 @@ discard block |
||
403 | 403 | |
404 | 404 | // If we've saved the permalink in memory, use it |
405 | 405 | // @since 1.3 |
406 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
406 | + $link = wp_cache_get( 'gv_directory_link_' . $post_id ); |
|
407 | 407 | |
408 | - if ( (int) $post_id === (int) get_option( 'page_on_front' ) ) { |
|
408 | + if ( (int)$post_id === (int)get_option( 'page_on_front' ) ) { |
|
409 | 409 | $link = home_url(); |
410 | 410 | } |
411 | 411 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | |
415 | 415 | // If not yet saved, cache the permalink. |
416 | 416 | // @since 1.3 |
417 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
417 | + wp_cache_set( 'gv_directory_link_' . $post_id, $link ); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | // Deal with returning to proper pagination for embedded views |
@@ -422,13 +422,13 @@ discard block |
||
422 | 422 | |
423 | 423 | $args = array(); |
424 | 424 | |
425 | - if( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) { |
|
426 | - $args['pagenum'] = intval( $pagenum ); |
|
425 | + if ( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) { |
|
426 | + $args[ 'pagenum' ] = intval( $pagenum ); |
|
427 | 427 | } |
428 | 428 | |
429 | - if( $sort = \GV\Utils::_GET( 'sort' ) ) { |
|
430 | - $args['sort'] = $sort; |
|
431 | - $args['dir'] = \GV\Utils::_GET( 'dir' ); |
|
429 | + if ( $sort = \GV\Utils::_GET( 'sort' ) ) { |
|
430 | + $args[ 'sort' ] = $sort; |
|
431 | + $args[ 'dir' ] = \GV\Utils::_GET( 'dir' ); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | $link = add_query_arg( $args, $link ); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | private static function get_custom_entry_slug( $id, $entry = array() ) { |
466 | 466 | |
467 | 467 | // Generate an unique hash to use as the default value |
468 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
468 | + $slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 ); |
|
469 | 469 | |
470 | 470 | /** |
471 | 471 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
477 | 477 | |
478 | 478 | // Make sure we have something - use the original ID as backup. |
479 | - if( empty( $slug ) ) { |
|
479 | + if ( empty( $slug ) ) { |
|
480 | 480 | $slug = $id; |
481 | 481 | } |
482 | 482 | |
@@ -570,15 +570,15 @@ discard block |
||
570 | 570 | * @param boolean $custom Should we process the custom entry slug? |
571 | 571 | */ |
572 | 572 | $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
573 | - if( $custom ) { |
|
573 | + if ( $custom ) { |
|
574 | 574 | // create the gravityview_unique_id and save it |
575 | 575 | |
576 | 576 | // Get the entry hash |
577 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
577 | + $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry ); |
|
578 | 578 | |
579 | - gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry['id'], 'hash' => $hash ) ); |
|
579 | + gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry[ 'id' ], 'hash' => $hash ) ); |
|
580 | 580 | |
581 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) ); |
|
581 | + gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) ); |
|
582 | 582 | |
583 | 583 | } |
584 | 584 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | |
598 | 598 | if ( ! empty( $entry ) && ! is_array( $entry ) ) { |
599 | 599 | $entry = GVCommon::get_entry( $entry ); |
600 | - } else if( empty( $entry ) ) { |
|
600 | + } else if ( empty( $entry ) ) { |
|
601 | 601 | // @deprecated path |
602 | 602 | $entry = GravityView_frontend::getInstance()->getEntry(); |
603 | 603 | } |
@@ -617,9 +617,9 @@ discard block |
||
617 | 617 | |
618 | 618 | $query_arg_name = \GV\Entry::get_endpoint_name(); |
619 | 619 | |
620 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
620 | + $entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry ); |
|
621 | 621 | |
622 | - if ( get_option('permalink_structure') && !is_preview() ) { |
|
622 | + if ( get_option( 'permalink_structure' ) && ! is_preview() ) { |
|
623 | 623 | |
624 | 624 | $args = array(); |
625 | 625 | |
@@ -629,9 +629,9 @@ discard block |
||
629 | 629 | */ |
630 | 630 | $link_parts = explode( '?', $directory_link ); |
631 | 631 | |
632 | - $query = !empty( $link_parts[1] ) ? '?'.$link_parts[1] : ''; |
|
632 | + $query = ! empty( $link_parts[ 1 ] ) ? '?' . $link_parts[ 1 ] : ''; |
|
633 | 633 | |
634 | - $directory_link = trailingslashit( $link_parts[0] ) . $query_arg_name . '/'. $entry_slug .'/' . $query; |
|
634 | + $directory_link = trailingslashit( $link_parts[ 0 ] ) . $query_arg_name . '/' . $entry_slug . '/' . $query; |
|
635 | 635 | |
636 | 636 | } else { |
637 | 637 | |
@@ -643,21 +643,21 @@ discard block |
||
643 | 643 | */ |
644 | 644 | if ( $add_directory_args ) { |
645 | 645 | |
646 | - if ( ! empty( $_GET['pagenum'] ) ) { |
|
647 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
646 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
647 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | /** |
651 | 651 | * @since 1.7 |
652 | 652 | */ |
653 | 653 | if ( $sort = \GV\Utils::_GET( 'sort' ) ) { |
654 | - $args['sort'] = $sort; |
|
655 | - $args['dir'] = \GV\Utils::_GET( 'dir' ); |
|
654 | + $args[ 'sort' ] = $sort; |
|
655 | + $args[ 'dir' ] = \GV\Utils::_GET( 'dir' ); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | } |
659 | 659 | |
660 | - if( $post_id ) { |
|
660 | + if ( $post_id ) { |
|
661 | 661 | $passed_post = get_post( $post_id ); |
662 | 662 | $views = \GV\View_Collection::from_post( $passed_post ); |
663 | 663 | $has_multiple_views = $views->count() > 1; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | } |
667 | 667 | |
668 | 668 | if ( $has_multiple_views ) { |
669 | - $args['gvid'] = gravityview_get_view_id(); |
|
669 | + $args[ 'gvid' ] = gravityview_get_view_id(); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | return add_query_arg( $args, $directory_link ); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | } |
688 | 688 | |
689 | 689 | function gv_class( $field, $form = NULL, $entry = array() ) { |
690 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
690 | + return GravityView_API::field_class( $field, $form, $entry ); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | $view_id = 0; |
711 | 711 | if ( $context->view ) { |
712 | 712 | $view_id = $context->view->ID; |
713 | - if( $context->view->settings->get( 'hide_until_searched' ) ) { |
|
713 | + if ( $context->view->settings->get( 'hide_until_searched' ) ) { |
|
714 | 714 | $hide_until_searched = ( empty( $context->entry ) && ! $context->request->is_search() ); |
715 | 715 | } |
716 | 716 | } |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | $default_css_class .= ' gv-container-no-results'; |
739 | 739 | } |
740 | 740 | |
741 | - $css_class = trim( $passed_css_class . ' '. $default_css_class ); |
|
741 | + $css_class = trim( $passed_css_class . ' ' . $default_css_class ); |
|
742 | 742 | |
743 | 743 | /** |
744 | 744 | * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | |
766 | 766 | $value = GravityView_API::field_value( $entry, $field ); |
767 | 767 | |
768 | - if( $value === '' ) { |
|
768 | + if ( $value === '' ) { |
|
769 | 769 | /** |
770 | 770 | * @filter `gravityview_empty_value` What to display when a field is empty |
771 | 771 | * @param string $value (empty string) |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | */ |
879 | 879 | function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
880 | 880 | |
881 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
881 | + if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
882 | 882 | |
883 | 883 | // For the complete field value as generated by Gravity Forms |
884 | 884 | return $display_value; |
@@ -912,16 +912,16 @@ discard block |
||
912 | 912 | $terms = explode( ', ', $value ); |
913 | 913 | } |
914 | 914 | |
915 | - foreach ($terms as $term_name ) { |
|
915 | + foreach ( $terms as $term_name ) { |
|
916 | 916 | |
917 | 917 | // If we're processing a category, |
918 | - if( $taxonomy === 'category' ) { |
|
918 | + if ( $taxonomy === 'category' ) { |
|
919 | 919 | |
920 | 920 | // Use rgexplode to prevent errors if : doesn't exist |
921 | 921 | list( $term_name, $term_id ) = rgexplode( ':', $term_name, 2 ); |
922 | 922 | |
923 | 923 | // The explode was succesful; we have the category ID |
924 | - if( !empty( $term_id )) { |
|
924 | + if ( ! empty( $term_id ) ) { |
|
925 | 925 | $term = get_term_by( 'id', $term_id, $taxonomy ); |
926 | 926 | } else { |
927 | 927 | // We have to fall back to the name |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | } |
935 | 935 | |
936 | 936 | // There's still a tag/category here. |
937 | - if( $term ) { |
|
937 | + if ( $term ) { |
|
938 | 938 | |
939 | 939 | $term_link = get_term_link( $term, $taxonomy ); |
940 | 940 | |
@@ -943,11 +943,11 @@ discard block |
||
943 | 943 | continue; |
944 | 944 | } |
945 | 945 | |
946 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
946 | + $output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | |
950 | - return implode(', ', $output ); |
|
950 | + return implode( ', ', $output ); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | /** |
@@ -961,8 +961,8 @@ discard block |
||
961 | 961 | |
962 | 962 | $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
963 | 963 | |
964 | - if( empty( $link ) ) { |
|
965 | - return strip_tags( $output); |
|
964 | + if ( empty( $link ) ) { |
|
965 | + return strip_tags( $output ); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | return $output; |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | $fe = GravityView_frontend::getInstance(); |
982 | 982 | |
983 | 983 | // Solve problem when loading content via admin-ajax.php |
984 | - if( ! $fe->getGvOutputData() ) { |
|
984 | + if ( ! $fe->getGvOutputData() ) { |
|
985 | 985 | |
986 | 986 | gravityview()->log->debug( 'gv_output_data not defined; parsing content.' ); |
987 | 987 | |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | } |
990 | 990 | |
991 | 991 | // Make 100% sure that we're dealing with a properly called situation |
992 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
992 | + if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
993 | 993 | |
994 | 994 | gravityview()->log->debug( 'gv_output_data not an object or get_view not callable.', array( 'data' => $fe->getGvOutputData() ) ); |
995 | 995 | |
@@ -1211,12 +1211,12 @@ discard block |
||
1211 | 1211 | function gravityview_get_files_array( $value, $gv_class = '', $context = null ) { |
1212 | 1212 | /** @define "GRAVITYVIEW_DIR" "../" */ |
1213 | 1213 | |
1214 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
1215 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
1214 | + if ( ! class_exists( 'GravityView_Field' ) ) { |
|
1215 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1219 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field-fileupload.php' ); |
|
1218 | + if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1219 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field-fileupload.php' ); |
|
1220 | 1220 | } |
1221 | 1221 | |
1222 | 1222 | if ( is_null( $context ) ) { |
@@ -1319,21 +1319,21 @@ discard block |
||
1319 | 1319 | } else { |
1320 | 1320 | // @deprecated path |
1321 | 1321 | // Required fields. |
1322 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
1322 | + if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) { |
|
1323 | 1323 | gravityview()->log->error( 'Field or form are empty.', array( 'data' => $args ) ); |
1324 | 1324 | return ''; |
1325 | 1325 | } |
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | if ( $context instanceof \GV\Template_Context ) { |
1329 | - $entry = $args['entry'] ? : ( $context->entry ? $context->entry->as_entry() : array() ); |
|
1330 | - $field = $args['field'] ? : ( $context->field ? $context->field->as_configuration() : array() ); |
|
1331 | - $form = $args['form'] ? : ( $context->view->form ? $context->view->form->form : array() ); |
|
1329 | + $entry = $args[ 'entry' ] ?: ( $context->entry ? $context->entry->as_entry() : array() ); |
|
1330 | + $field = $args[ 'field' ] ?: ( $context->field ? $context->field->as_configuration() : array() ); |
|
1331 | + $form = $args[ 'form' ] ?: ( $context->view->form ? $context->view->form->form : array() ); |
|
1332 | 1332 | } else { |
1333 | 1333 | // @deprecated path |
1334 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
1335 | - $field = $args['field']; |
|
1336 | - $form = $args['form']; |
|
1334 | + $entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ]; |
|
1335 | + $field = $args[ 'field' ]; |
|
1336 | + $form = $args[ 'form' ]; |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | /** |
@@ -1353,43 +1353,43 @@ discard block |
||
1353 | 1353 | ); |
1354 | 1354 | |
1355 | 1355 | if ( $context instanceof \GV\Template_Context ) { |
1356 | - $placeholders['value'] = \GV\Utils::get( $args, 'value', '' ); |
|
1356 | + $placeholders[ 'value' ] = \GV\Utils::get( $args, 'value', '' ); |
|
1357 | 1357 | } else { |
1358 | 1358 | // @deprecated path |
1359 | - $placeholders['value'] = gv_value( $entry, $field ); |
|
1359 | + $placeholders[ 'value' ] = gv_value( $entry, $field ); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | // If the value is empty and we're hiding empty, return empty. |
1363 | - if ( $placeholders['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
1363 | + if ( $placeholders[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) { |
|
1364 | 1364 | return ''; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | - if ( $placeholders['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
1368 | - $placeholders['value'] = wpautop( $placeholders['value'] ); |
|
1367 | + if ( $placeholders[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) { |
|
1368 | + $placeholders[ 'value' ] = wpautop( $placeholders[ 'value' ] ); |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | // Get width setting, if exists |
1372 | - $placeholders['width'] = GravityView_API::field_width( $field ); |
|
1372 | + $placeholders[ 'width' ] = GravityView_API::field_width( $field ); |
|
1373 | 1373 | |
1374 | 1374 | // If replacing with CSS inline formatting, let's do it. |
1375 | - $placeholders['width:style'] = GravityView_API::field_width( $field, 'width:' . $placeholders['width'] . '%;' ); |
|
1375 | + $placeholders[ 'width:style' ] = GravityView_API::field_width( $field, 'width:' . $placeholders[ 'width' ] . '%;' ); |
|
1376 | 1376 | |
1377 | 1377 | // Grab the Class using `gv_class` |
1378 | - $placeholders['class'] = gv_class( $field, $form, $entry ); |
|
1379 | - $placeholders['field_id'] = GravityView_API::field_html_attr_id( $field, $form, $entry ); |
|
1378 | + $placeholders[ 'class' ] = gv_class( $field, $form, $entry ); |
|
1379 | + $placeholders[ 'field_id' ] = GravityView_API::field_html_attr_id( $field, $form, $entry ); |
|
1380 | 1380 | |
1381 | 1381 | if ( $context instanceof \GV\Template_Context ) { |
1382 | - $placeholders['label_value'] = \GV\Utils::get( $args, 'label' ); |
|
1382 | + $placeholders[ 'label_value' ] = \GV\Utils::get( $args, 'label' ); |
|
1383 | 1383 | } else { |
1384 | 1384 | // Default Label value |
1385 | - $placeholders['label_value'] = gv_label( $field, $entry ); |
|
1385 | + $placeholders[ 'label_value' ] = gv_label( $field, $entry ); |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | - $placeholders['label_value:data-label'] = trim( esc_attr( strip_tags( str_replace( '> ', '>', $placeholders['label_value'] ) ) ) ); |
|
1389 | - $placeholders['label_value:esc_attr'] = esc_attr( $placeholders['label_value'] ); |
|
1388 | + $placeholders[ 'label_value:data-label' ] = trim( esc_attr( strip_tags( str_replace( '> ', '>', $placeholders[ 'label_value' ] ) ) ) ); |
|
1389 | + $placeholders[ 'label_value:esc_attr' ] = esc_attr( $placeholders[ 'label_value' ] ); |
|
1390 | 1390 | |
1391 | - if ( empty( $placeholders['label'] ) && ! empty( $placeholders['label_value'] ) ){ |
|
1392 | - $placeholders['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1391 | + if ( empty( $placeholders[ 'label' ] ) && ! empty( $placeholders[ 'label_value' ] ) ) { |
|
1392 | + $placeholders[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | /** |
@@ -1400,7 +1400,7 @@ discard block |
||
1400 | 1400 | * @since 2.0 |
1401 | 1401 | * @param \GV\Template_Context $context The context. |
1402 | 1402 | */ |
1403 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args, $context ); |
|
1403 | + $html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args, $context ); |
|
1404 | 1404 | |
1405 | 1405 | /** |
1406 | 1406 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | foreach ( $placeholders as $tag => $value ) { |
1428 | 1428 | |
1429 | 1429 | // If the tag doesn't exist just skip it |
1430 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
1430 | + if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) { |
|
1431 | 1431 | continue; |
1432 | 1432 | } |
1433 | 1433 |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | |
105 | 105 | /** Call all lazy callbacks. */ |
106 | 106 | foreach ( $this->callbacks as $callback ) { |
107 | - if ( $callback[0] != 'count' ) { |
|
107 | + if ( $callback[ 0 ] != 'count' ) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - $total += $callback[1]( $this->filters ); |
|
111 | + $total += $callback[ 1 ]( $this->filters ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if ( ! $total ) { |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | |
186 | 186 | /** Call all lazy callbacks. */ |
187 | 187 | foreach ( $this->callbacks as $i => $callback ) { |
188 | - if ( $callback[0] != 'fetch' ) { |
|
188 | + if ( $callback[ 0 ] != 'fetch' ) { |
|
189 | 189 | continue; |
190 | 190 | } |
191 | 191 | |
192 | - $this->merge( $callback[1]( $this->filters, $this->sorts, $offset ) ); |
|
192 | + $this->merge( $callback[ 1 ]( $this->filters, $this->sorts, $offset ) ); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | $this->fetched = parent::count(); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - $this->callbacks []= array( $type, $callback ); |
|
348 | + $this->callbacks [ ] = array( $type, $callback ); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | |
126 | 126 | $form = false; |
127 | 127 | |
128 | - if( $entry ) { |
|
129 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
128 | + if ( $entry ) { |
|
129 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return $form; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - return (bool) $has_transaction_data; |
|
205 | + return (bool)$has_transaction_data; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
242 | 242 | |
243 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
243 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
244 | 244 | |
245 | 245 | return $result; |
246 | 246 | } |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
259 | 259 | */ |
260 | - public static function get_forms( $active = true, $trash = false ) { |
|
260 | + public static function get_forms( $active = true, $trash = false ) { |
|
261 | 261 | $forms = array(); |
262 | 262 | if ( class_exists( 'GFAPI' ) ) { |
263 | - if( 'any' === $active ) { |
|
263 | + if ( 'any' === $active ) { |
|
264 | 264 | $active_forms = GFAPI::get_forms( true, $trash ); |
265 | 265 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
266 | 266 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | $has_post_fields = false; |
292 | 292 | |
293 | 293 | if ( $form ) { |
294 | - foreach ( $form['fields'] as $field ) { |
|
295 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
296 | - $fields["{$field['id']}"] = array( |
|
294 | + foreach ( $form[ 'fields' ] as $field ) { |
|
295 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
296 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
297 | 297 | 'label' => \GV\Utils::get( $field, 'label' ), |
298 | 298 | 'parent' => null, |
299 | 299 | 'type' => \GV\Utils::get( $field, 'type' ), |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | ); |
303 | 303 | } |
304 | 304 | |
305 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
306 | - foreach ( $field['inputs'] as $input ) { |
|
305 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
306 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
307 | 307 | |
308 | - if( ! empty( $input['isHidden'] ) ) { |
|
308 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
309 | 309 | continue; |
310 | 310 | } |
311 | 311 | |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | * @hack |
314 | 314 | * In case of email/email confirmation, the input for email has the same id as the parent field |
315 | 315 | */ |
316 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
316 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
317 | 317 | continue; |
318 | 318 | } |
319 | - $fields["{$input['id']}"] = array( |
|
319 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
320 | 320 | 'label' => \GV\Utils::get( $input, 'label' ), |
321 | 321 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
322 | 322 | 'parent' => $field, |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | |
331 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
331 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
332 | 332 | $has_product_fields = true; |
333 | 333 | } |
334 | 334 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @since 1.7 |
343 | 343 | */ |
344 | 344 | if ( $has_post_fields ) { |
345 | - $fields['post_id'] = array( |
|
345 | + $fields[ 'post_id' ] = array( |
|
346 | 346 | 'label' => __( 'Post ID', 'gravityview' ), |
347 | 347 | 'type' => 'post_id', |
348 | 348 | ); |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | foreach ( $payment_fields as $payment_field ) { |
356 | 356 | |
357 | 357 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
358 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
358 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
359 | 359 | continue; |
360 | 360 | } |
361 | 361 | |
362 | - $fields["{$payment_field->name}"] = array( |
|
362 | + $fields[ "{$payment_field->name}" ] = array( |
|
363 | 363 | 'label' => $payment_field->label, |
364 | 364 | 'desc' => $payment_field->description, |
365 | 365 | 'type' => $payment_field->name, |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | |
392 | 392 | $fields = array(); |
393 | 393 | |
394 | - foreach ( $extra_fields as $key => $field ){ |
|
395 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
396 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
394 | + foreach ( $extra_fields as $key => $field ) { |
|
395 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
396 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
@@ -433,33 +433,33 @@ discard block |
||
433 | 433 | 'search_criteria' => null, |
434 | 434 | 'sorting' => null, |
435 | 435 | 'paging' => null, |
436 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
436 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
437 | 437 | 'context_view_id' => null, |
438 | 438 | ); |
439 | 439 | |
440 | 440 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
441 | 441 | |
442 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
443 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
442 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
443 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
444 | 444 | |
445 | 445 | if ( ! is_array( $filter ) ) { |
446 | 446 | continue; |
447 | 447 | } |
448 | 448 | |
449 | 449 | // By default, we want searches to be wildcard for each field. |
450 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
450 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
451 | 451 | |
452 | 452 | /** |
453 | 453 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
454 | 454 | * @param string $operator Existing search operator |
455 | 455 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
456 | 456 | */ |
457 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
457 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | // don't send just the [mode] without any field filter. |
461 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
462 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
461 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
462 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | } |
@@ -470,33 +470,33 @@ discard block |
||
470 | 470 | * Prepare date formats to be in Gravity Forms DB format; |
471 | 471 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
472 | 472 | */ |
473 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
473 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
474 | 474 | |
475 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
475 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
476 | 476 | |
477 | 477 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
478 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
478 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
479 | 479 | |
480 | 480 | if ( $date ) { |
481 | 481 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
482 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
482 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
483 | 483 | } else { |
484 | - gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) ); |
|
484 | + gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) ); |
|
485 | 485 | |
486 | 486 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
487 | - unset( $criteria['search_criteria'][ $key ] ); |
|
487 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | - if ( empty( $criteria['context_view_id'] ) ) { |
|
492 | + if ( empty( $criteria[ 'context_view_id' ] ) ) { |
|
493 | 493 | // Calculate the context view id and send it to the advanced filter |
494 | 494 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
495 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
495 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
496 | 496 | } else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
497 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
497 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
498 | 498 | } else if ( 'delete' === GFForms::get( 'action' ) ) { |
499 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
499 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @param array $form_ids Forms to search |
507 | 507 | * @param int $view_id ID of the view being used to search |
508 | 508 | */ |
509 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
509 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
510 | 510 | |
511 | 511 | return (array)$criteria; |
512 | 512 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | /** Reduce # of database calls */ |
542 | 542 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
543 | 543 | |
544 | - if ( ! empty( $criteria['cache'] ) ) { |
|
544 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
545 | 545 | |
546 | 546 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
547 | 547 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | |
550 | 550 | // Still update the total count when using cached results |
551 | 551 | if ( ! is_null( $total ) ) { |
552 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
552 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | $return = $entries; |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | $entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) ); |
572 | 572 | |
573 | 573 | // No entries returned from gravityview_before_get_entries |
574 | - if( is_null( $entries ) ) { |
|
574 | + if ( is_null( $entries ) ) { |
|
575 | 575 | |
576 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
576 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
577 | 577 | |
578 | 578 | if ( is_wp_error( $entries ) ) { |
579 | 579 | gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) ); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
587 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
588 | 588 | |
589 | 589 | // Cache results |
590 | 590 | $Cache->set( $entries, 'entries' ); |
@@ -693,12 +693,12 @@ discard block |
||
693 | 693 | */ |
694 | 694 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
695 | 695 | |
696 | - if( $check_entry_display ) { |
|
696 | + if ( $check_entry_display ) { |
|
697 | 697 | // Is the entry allowed |
698 | 698 | $entry = self::check_entry_display( $entry ); |
699 | 699 | } |
700 | 700 | |
701 | - if( is_wp_error( $entry ) ) { |
|
701 | + if ( is_wp_error( $entry ) ) { |
|
702 | 702 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
703 | 703 | return false; |
704 | 704 | } |
@@ -732,12 +732,12 @@ discard block |
||
732 | 732 | |
733 | 733 | $value = false; |
734 | 734 | |
735 | - if( 'context' === $val1 ) { |
|
735 | + if ( 'context' === $val1 ) { |
|
736 | 736 | |
737 | 737 | $matching_contexts = array( $val2 ); |
738 | 738 | |
739 | 739 | // We allow for non-standard contexts. |
740 | - switch( $val2 ) { |
|
740 | + switch ( $val2 ) { |
|
741 | 741 | // Check for either single or edit |
742 | 742 | case 'singular': |
743 | 743 | $matching_contexts = array( 'single', 'edit' ); |
@@ -780,18 +780,18 @@ discard block |
||
780 | 780 | $json_val_1 = json_decode( $val1, true ); |
781 | 781 | $json_val_2 = json_decode( $val2, true ); |
782 | 782 | |
783 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
783 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
784 | 784 | |
785 | 785 | $json_in = false; |
786 | - $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 ); |
|
787 | - $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 ); |
|
786 | + $json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 ); |
|
787 | + $json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 ); |
|
788 | 788 | |
789 | 789 | // For JSON, we want to compare as "in" or "not in" rather than "contains" |
790 | 790 | foreach ( $json_val_1 as $item_1 ) { |
791 | 791 | foreach ( $json_val_2 as $item_2 ) { |
792 | 792 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
793 | 793 | |
794 | - if( $json_in ) { |
|
794 | + if ( $json_in ) { |
|
795 | 795 | break 2; |
796 | 796 | } |
797 | 797 | } |
@@ -843,10 +843,10 @@ discard block |
||
843 | 843 | public static function check_entry_display( $entry, $view = null ) { |
844 | 844 | |
845 | 845 | if ( ! $entry || is_wp_error( $entry ) ) { |
846 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
846 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
847 | 847 | } |
848 | 848 | |
849 | - if ( empty( $entry['form_id'] ) ) { |
|
849 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
850 | 850 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
851 | 851 | } |
852 | 852 | |
@@ -855,15 +855,15 @@ discard block |
||
855 | 855 | * Check whether the entry is in the entries subset by running a modified query. |
856 | 856 | */ |
857 | 857 | add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry ) { |
858 | - $_tmp_query = new \GF_Query( $view->form->ID, array( 'field_filters' => array( 'mode' => 'all', array( 'key' => 'id', 'operation' => 'is', 'value' => $entry['id'] ) ) ) ); |
|
858 | + $_tmp_query = new \GF_Query( $view->form->ID, array( 'field_filters' => array( 'mode' => 'all', array( 'key' => 'id', 'operation' => 'is', 'value' => $entry[ 'id' ] ) ) ) ); |
|
859 | 859 | $_tmp_query_parts = $_tmp_query->_introspect(); |
860 | 860 | |
861 | 861 | $query_parts = $query->_introspect(); |
862 | 862 | |
863 | - $query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) ); |
|
863 | + $query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) ); |
|
864 | 864 | }, 10, 3 ); |
865 | 865 | |
866 | - if ( ( ! $entries = $view->get_entries()->all() ) || $entries[0]->ID !== $entry['id'] ) { |
|
866 | + if ( ( ! $entries = $view->get_entries()->all() ) || $entries[ 0 ]->ID !== $entry[ 'id' ] ) { |
|
867 | 867 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
868 | 868 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
869 | 869 | } |
@@ -876,59 +876,59 @@ discard block |
||
876 | 876 | 'context_view_id' => $view ? $view->ID : null, |
877 | 877 | ) ); |
878 | 878 | |
879 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
879 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
880 | 880 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No search criteria found:', array( 'data' => $criteria ) ); |
881 | 881 | return $entry; |
882 | 882 | } |
883 | 883 | |
884 | 884 | // Make sure the current View is connected to the same form as the Entry |
885 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
886 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
885 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
886 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
887 | 887 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
888 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
889 | - return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
888 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
889 | + return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
890 | 890 | } |
891 | 891 | } |
892 | 892 | |
893 | - $search_criteria = $criteria['search_criteria']; |
|
893 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
894 | 894 | |
895 | 895 | // check entry status |
896 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
897 | - return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
896 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
897 | + return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | // check entry date |
901 | 901 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
902 | 902 | |
903 | 903 | // field_filters |
904 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
904 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
905 | 905 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No field filters criteria found:', array( 'data' => $search_criteria ) ); |
906 | 906 | return $entry; |
907 | 907 | } |
908 | 908 | |
909 | - $filters = $search_criteria['field_filters']; |
|
909 | + $filters = $search_criteria[ 'field_filters' ]; |
|
910 | 910 | |
911 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
911 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
912 | 912 | |
913 | - $mode = $mode ? : 'all'; // If mode is an empty string, assume it's 'all' |
|
913 | + $mode = $mode ?: 'all'; // If mode is an empty string, assume it's 'all' |
|
914 | 914 | |
915 | 915 | // Prevent the mode from being processed below |
916 | - unset( $filters['mode'] ); |
|
916 | + unset( $filters[ 'mode' ] ); |
|
917 | 917 | |
918 | - $form = self::get_form( $entry['form_id'] ); |
|
918 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
919 | 919 | |
920 | 920 | foreach ( $filters as $filter ) { |
921 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
921 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
922 | 922 | |
923 | - if ( ! isset( $filter['key'] ) ) { |
|
923 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
924 | 924 | gravityview()->log->debug( '[apply_filters_to_entry] Filter key not set, any field mode', array( 'filter' => $filter ) ); |
925 | 925 | /** |
926 | 926 | * This is a cross-field search. Let's start digging'. |
927 | 927 | */ |
928 | 928 | foreach ( \GV\Utils::get( $form, 'fields', array() ) as $field ) { |
929 | 929 | $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
930 | - if ( $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ) ) { |
|
931 | - if ( 'any' === $mode) { |
|
930 | + if ( $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ) ) { |
|
931 | + if ( 'any' === $mode ) { |
|
932 | 932 | return $entry; // All good here |
933 | 933 | } // mode === 'all' |
934 | 934 | continue 2; // Next filter |
@@ -937,13 +937,13 @@ discard block |
||
937 | 937 | } |
938 | 938 | |
939 | 939 | if ( 'all' === $mode ) { |
940 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a subcriterium for any field in ALL mode', $filter ); |
|
940 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a subcriterium for any field in ALL mode', $filter ); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | continue; |
944 | 944 | } |
945 | 945 | |
946 | - $k = $filter['key']; |
|
946 | + $k = $filter[ 'key' ]; |
|
947 | 947 | |
948 | 948 | $field = self::get_field( $form, $k ); |
949 | 949 | |
@@ -951,12 +951,12 @@ discard block |
||
951 | 951 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
952 | 952 | $field = $k; |
953 | 953 | } else { |
954 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
954 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
955 | 955 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
956 | 956 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? \GV\Utils::get( $field_value, $k ) : $field_value; |
957 | 957 | } |
958 | 958 | |
959 | - $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
959 | + $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
960 | 960 | |
961 | 961 | // Any match is all we need to know |
962 | 962 | if ( $is_value_match && 'any' === $mode ) { |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | |
966 | 966 | // Any failed match is a total fail |
967 | 967 | if ( ! $is_value_match && 'all' === $mode ) { |
968 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
968 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
969 | 969 | } |
970 | 970 | } |
971 | 971 | |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
976 | 976 | return $entry; |
977 | 977 | } else { |
978 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
978 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | } |
@@ -1016,18 +1016,18 @@ discard block |
||
1016 | 1016 | * Gravity Forms code to adjust date to locally-configured Time Zone |
1017 | 1017 | * @see GFCommon::format_date() for original code |
1018 | 1018 | */ |
1019 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
1019 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
1020 | 1020 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
1021 | 1021 | |
1022 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
1023 | - $is_human = ! empty( $atts['human'] ); |
|
1024 | - $is_diff = ! empty( $atts['diff'] ); |
|
1025 | - $is_raw = ! empty( $atts['raw'] ); |
|
1026 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
1027 | - $include_time = ! empty( $atts['time'] ); |
|
1022 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
1023 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
1024 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
1025 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
1026 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
1027 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
1028 | 1028 | |
1029 | 1029 | // If we're using time diff, we want to have a different default format |
1030 | - if( empty( $format ) ) { |
|
1030 | + if ( empty( $format ) ) { |
|
1031 | 1031 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
1032 | 1032 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
1033 | 1033 | } |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | // If raw was specified, don't modify the stored value |
1036 | 1036 | if ( $is_raw ) { |
1037 | 1037 | $formatted_date = $date_string; |
1038 | - } elseif( $is_timestamp ) { |
|
1038 | + } elseif ( $is_timestamp ) { |
|
1039 | 1039 | $formatted_date = $date_local_timestamp; |
1040 | 1040 | } elseif ( $is_diff ) { |
1041 | 1041 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | |
1070 | 1070 | $label = \GV\Utils::get( $field, 'label' ); |
1071 | 1071 | |
1072 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1072 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1073 | 1073 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
1074 | 1074 | } |
1075 | 1075 | |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $form = GFAPI::get_form( $form ); |
1098 | 1098 | } |
1099 | 1099 | |
1100 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
1100 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
1101 | 1101 | return GFFormsModel::get_field( $form, $field_id ); |
1102 | 1102 | } else { |
1103 | 1103 | return null; |
@@ -1144,19 +1144,19 @@ discard block |
||
1144 | 1144 | $shortcodes = array(); |
1145 | 1145 | |
1146 | 1146 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1147 | - if ( empty( $matches ) ){ |
|
1147 | + if ( empty( $matches ) ) { |
|
1148 | 1148 | return false; |
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | foreach ( $matches as $shortcode ) { |
1152 | - if ( $tag === $shortcode[2] ) { |
|
1152 | + if ( $tag === $shortcode[ 2 ] ) { |
|
1153 | 1153 | |
1154 | 1154 | // Changed this to $shortcode instead of true so we get the parsed atts. |
1155 | - $shortcodes[] = $shortcode; |
|
1155 | + $shortcodes[ ] = $shortcode; |
|
1156 | 1156 | |
1157 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
1158 | - foreach( $results as $result ) { |
|
1159 | - $shortcodes[] = $result; |
|
1157 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
1158 | + foreach ( $results as $result ) { |
|
1159 | + $shortcodes[ ] = $result; |
|
1160 | 1160 | } |
1161 | 1161 | } |
1162 | 1162 | } |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | 'post_type' => 'gravityview', |
1189 | 1189 | 'posts_per_page' => 100, |
1190 | 1190 | 'meta_key' => '_gravityview_form_id', |
1191 | - 'meta_value' => (int) $form_id, |
|
1191 | + 'meta_value' => (int)$form_id, |
|
1192 | 1192 | ); |
1193 | 1193 | $args = wp_parse_args( $args, $defaults ); |
1194 | 1194 | $views = get_posts( $args ); |
@@ -1200,21 +1200,21 @@ discard block |
||
1200 | 1200 | |
1201 | 1201 | $data = unserialize( $view->meta_value ); |
1202 | 1202 | |
1203 | - if( ! $data || ! is_array( $data ) ) { |
|
1203 | + if ( ! $data || ! is_array( $data ) ) { |
|
1204 | 1204 | continue; |
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | foreach ( $data as $datum ) { |
1208 | - if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) { |
|
1209 | - $joined_forms[] = $view->post_id; |
|
1208 | + if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) { |
|
1209 | + $joined_forms[ ] = $view->post_id; |
|
1210 | 1210 | } |
1211 | 1211 | } |
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | if ( $joined_forms ) { |
1215 | - $joined_args = array( |
|
1215 | + $joined_args = array( |
|
1216 | 1216 | 'post_type' => 'gravityview', |
1217 | - 'posts_per_page' => $args['posts_per_page'], |
|
1217 | + 'posts_per_page' => $args[ 'posts_per_page' ], |
|
1218 | 1218 | 'post__in' => $joined_forms, |
1219 | 1219 | ); |
1220 | 1220 | $views = array_merge( $views, get_posts( $joined_args ) ); |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | |
1371 | 1371 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
1372 | 1372 | |
1373 | - if( $json_decode ) { |
|
1373 | + if ( $json_decode ) { |
|
1374 | 1374 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
1375 | 1375 | } |
1376 | 1376 | |
@@ -1386,7 +1386,7 @@ discard block |
||
1386 | 1386 | * @return string html |
1387 | 1387 | */ |
1388 | 1388 | public static function get_sortable_fields( $formid, $current = '' ) { |
1389 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1389 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1390 | 1390 | |
1391 | 1391 | if ( empty( $formid ) ) { |
1392 | 1392 | return $output; |
@@ -1399,11 +1399,11 @@ discard block |
||
1399 | 1399 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1400 | 1400 | |
1401 | 1401 | foreach ( $fields as $id => $field ) { |
1402 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1402 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1403 | 1403 | continue; |
1404 | 1404 | } |
1405 | 1405 | |
1406 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1406 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1407 | 1407 | } |
1408 | 1408 | } |
1409 | 1409 | |
@@ -1438,9 +1438,9 @@ discard block |
||
1438 | 1438 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1439 | 1439 | |
1440 | 1440 | // TODO: Convert to using array_filter |
1441 | - foreach( $fields as $id => $field ) { |
|
1441 | + foreach ( $fields as $id => $field ) { |
|
1442 | 1442 | |
1443 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1443 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1444 | 1444 | unset( $fields[ $id ] ); |
1445 | 1445 | } |
1446 | 1446 | } |
@@ -1481,14 +1481,14 @@ discard block |
||
1481 | 1481 | * @param int|array $field field key or field array |
1482 | 1482 | * @return boolean |
1483 | 1483 | */ |
1484 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1484 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1485 | 1485 | |
1486 | 1486 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1487 | 1487 | $form = self::get_form( $form ); |
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | // If entry meta, it's a string. Otherwise, numeric |
1491 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1491 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1492 | 1492 | $type = $field; |
1493 | 1493 | } else { |
1494 | 1494 | $type = self::get_field_type( $form, $field ); |
@@ -1502,9 +1502,9 @@ discard block |
||
1502 | 1502 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1503 | 1503 | |
1504 | 1504 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1505 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1506 | - if( true === $gv_field->is_numeric ) { |
|
1507 | - $numeric_types[] = $gv_field->is_numeric; |
|
1505 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1506 | + if ( true === $gv_field->is_numeric ) { |
|
1507 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1508 | 1508 | } |
1509 | 1509 | } |
1510 | 1510 | |
@@ -1654,18 +1654,18 @@ discard block |
||
1654 | 1654 | $final_atts = array_filter( $final_atts ); |
1655 | 1655 | |
1656 | 1656 | // If the href wasn't passed as an attribute, use the value passed to the function |
1657 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1658 | - $final_atts['href'] = $href; |
|
1657 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1658 | + $final_atts[ 'href' ] = $href; |
|
1659 | 1659 | } |
1660 | 1660 | |
1661 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1661 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1662 | 1662 | |
1663 | 1663 | /** |
1664 | 1664 | * Fix potential security issue with target=_blank |
1665 | 1665 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1666 | 1666 | */ |
1667 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1668 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1667 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1668 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | // Sort the attributes alphabetically, to help testing |
@@ -1677,7 +1677,7 @@ discard block |
||
1677 | 1677 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1678 | 1678 | } |
1679 | 1679 | |
1680 | - if( '' !== $output ) { |
|
1680 | + if ( '' !== $output ) { |
|
1681 | 1681 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1682 | 1682 | } |
1683 | 1683 | |
@@ -1704,7 +1704,7 @@ discard block |
||
1704 | 1704 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1705 | 1705 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1706 | 1706 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1707 | - $merged[] = $value; |
|
1707 | + $merged[ ] = $value; |
|
1708 | 1708 | } else { |
1709 | 1709 | $merged[ $key ] = $value; |
1710 | 1710 | } |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1738 | 1738 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1739 | 1739 | */ |
1740 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1740 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1741 | 1741 | |
1742 | 1742 | return get_users( $get_users_settings ); |
1743 | 1743 | } |
@@ -1757,11 +1757,11 @@ discard block |
||
1757 | 1757 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
1758 | 1758 | |
1759 | 1759 | // If $cap is defined, only show notice if user has capability |
1760 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1760 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1761 | 1761 | return ''; |
1762 | 1762 | } |
1763 | 1763 | |
1764 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1764 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1765 | 1765 | } |
1766 | 1766 | |
1767 | 1767 | /** |
@@ -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 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * Viewing a single entry. |
314 | 314 | */ |
315 | 315 | } else if ( $entry = $request->is_entry( $view->form ? $view->form->ID : 0 ) ) { |
316 | - if ( $entry['status'] != 'active' ) { |
|
316 | + if ( $entry[ 'status' ] != 'active' ) { |
|
317 | 317 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
318 | 318 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
319 | 319 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
327 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
327 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
328 | 328 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
329 | 329 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
330 | 330 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column ); |
499 | 499 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column ); |
500 | 500 | |
501 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
501 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | return $joins; |
@@ -540,10 +540,10 @@ discard block |
||
540 | 540 | |
541 | 541 | list( $join, $join_column, $join_on, $join_on_column ) = $meta; |
542 | 542 | |
543 | - $forms_ids [] = GF_Form::by_id( $join_on ); |
|
543 | + $forms_ids [ ] = GF_Form::by_id( $join_on ); |
|
544 | 544 | } |
545 | 545 | |
546 | - return ( !empty( $forms_ids) ) ? $forms_ids : null; |
|
546 | + return ( ! empty( $forms_ids ) ) ? $forms_ids : null; |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | if ( ! $view->form ) { |
582 | 582 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
583 | 583 | 'view_id' => $view->ID, |
584 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
584 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
585 | 585 | ) ); |
586 | 586 | } |
587 | 587 | |
@@ -816,11 +816,11 @@ discard block |
||
816 | 816 | * Remove multiple sorting before calling legacy filters. |
817 | 817 | * This allows us to fake it till we make it. |
818 | 818 | */ |
819 | - if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
819 | + if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
820 | 820 | $has_multisort = true; |
821 | - $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
822 | - if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
823 | - $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
821 | + $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
822 | + if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
823 | + $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
824 | 824 | } |
825 | 825 | } |
826 | 826 | |
@@ -828,34 +828,33 @@ discard block |
||
828 | 828 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
829 | 829 | */ |
830 | 830 | $parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID ); |
831 | - $parameters['context_view_id'] = $this->ID; |
|
831 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
832 | 832 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
833 | 833 | |
834 | 834 | if ( $request instanceof REST\Request ) { |
835 | 835 | $atts = $this->settings->as_atts(); |
836 | 836 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
837 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
837 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
838 | 838 | ) ); |
839 | - $parameters['paging'] = $paging_parameters['paging']; |
|
839 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
840 | 840 | } |
841 | 841 | |
842 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
843 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
842 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
844 | 843 | |
845 | 844 | /** |
846 | 845 | * Cleanup duplicate field_filter parameters to simplify the query. |
847 | 846 | */ |
848 | 847 | $unique_field_filters = array(); |
849 | - foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
848 | + foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
850 | 849 | if ( 'mode' === $key ) { |
851 | - $unique_field_filters['mode'] = $filter; |
|
850 | + $unique_field_filters[ 'mode' ] = $filter; |
|
852 | 851 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
853 | - $unique_field_filters[] = $filter; |
|
852 | + $unique_field_filters[ ] = $filter; |
|
854 | 853 | } |
855 | 854 | } |
856 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
855 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
857 | 856 | |
858 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
857 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
859 | 858 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
860 | 859 | } |
861 | 860 | |
@@ -863,7 +862,7 @@ discard block |
||
863 | 862 | /** |
864 | 863 | * New \GF_Query stuff :) |
865 | 864 | */ |
866 | - $query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
865 | + $query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
867 | 866 | |
868 | 867 | /** |
869 | 868 | * Apply multisort. |
@@ -896,8 +895,8 @@ discard block |
||
896 | 895 | } |
897 | 896 | } |
898 | 897 | |
899 | - $query->limit( $parameters['paging']['page_size'] ) |
|
900 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
898 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
899 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
901 | 900 | |
902 | 901 | /** |
903 | 902 | * Any joins? |
@@ -939,15 +938,15 @@ discard block |
||
939 | 938 | } ); |
940 | 939 | } else { |
941 | 940 | $entries = $this->form->entries |
942 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
941 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
943 | 942 | ->offset( $this->settings->get( 'offset' ) ) |
944 | - ->limit( $parameters['paging']['page_size'] ) |
|
943 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
945 | 944 | ->page( $page ); |
946 | 945 | |
947 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
946 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
948 | 947 | $field = new \GV\Field(); |
949 | - $field->ID = $parameters['sorting']['key']; |
|
950 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
948 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
949 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
951 | 950 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
952 | 951 | } |
953 | 952 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | private function __construct() {} |
86 | 86 | |
87 | 87 | private function initialize() { |
88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
91 | 91 | |
92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | |
237 | 237 | $this->context_view_id = $view_id; |
238 | 238 | |
239 | - } elseif ( isset( $_GET['gvid'] ) && $multiple_views ) { |
|
239 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $multiple_views ) { |
|
240 | 240 | /** |
241 | 241 | * used on a has_multiple_views context |
242 | 242 | * @see GravityView_API::entry_link |
243 | 243 | */ |
244 | - $this->context_view_id = $_GET['gvid']; |
|
244 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
245 | 245 | |
246 | 246 | } elseif ( ! $multiple_views ) { |
247 | 247 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | global $wp_rewrite; |
279 | 279 | |
280 | 280 | $is_front_page = ( $query->is_home || $query->is_page ); |
281 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
282 | - $front_page_id = get_option('page_on_front'); |
|
281 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
282 | + $front_page_id = get_option( 'page_on_front' ); |
|
283 | 283 | |
284 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
284 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
285 | 285 | |
286 | 286 | // Force to be an array, potentially a query string ( entry=16 ) |
287 | 287 | $_query = wp_parse_args( $query->query ); |
288 | 288 | |
289 | 289 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
290 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
291 | - unset( $_query['pagename'] ); |
|
290 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
291 | + unset( $_query[ 'pagename' ] ); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // this is where will break from core wordpress |
295 | 295 | /** @internal Don't use this filter; it will be unnecessary soon - it's just a patch for specific use case */ |
296 | 296 | $ignore = apply_filters( 'gravityview/internal/ignored_endpoints', array( 'preview', 'page', 'paged', 'cpage' ), $query ); |
297 | 297 | $endpoints = \GV\Utils::get( $wp_rewrite, 'endpoints' ); |
298 | - foreach ( (array) $endpoints as $endpoint ) { |
|
299 | - $ignore[] = $endpoint[1]; |
|
298 | + foreach ( (array)$endpoints as $endpoint ) { |
|
299 | + $ignore[ ] = $endpoint[ 1 ]; |
|
300 | 300 | } |
301 | 301 | unset( $endpoints ); |
302 | 302 | |
@@ -306,21 +306,21 @@ discard block |
||
306 | 306 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
307 | 307 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
308 | 308 | |
309 | - $qv =& $query->query_vars; |
|
309 | + $qv = & $query->query_vars; |
|
310 | 310 | |
311 | 311 | // Prevent redirect when on the single entry endpoint |
312 | - if( self::is_single_entry() ) { |
|
312 | + if ( self::is_single_entry() ) { |
|
313 | 313 | add_filter( 'redirect_canonical', '__return_false' ); |
314 | 314 | } |
315 | 315 | |
316 | 316 | $query->is_page = true; |
317 | 317 | $query->is_home = false; |
318 | - $qv['page_id'] = $front_page_id; |
|
318 | + $qv[ 'page_id' ] = $front_page_id; |
|
319 | 319 | |
320 | 320 | // Correct <!--nextpage--> for page_on_front |
321 | - if ( ! empty( $qv['paged'] ) ) { |
|
322 | - $qv['page'] = $qv['paged']; |
|
323 | - unset( $qv['paged'] ); |
|
321 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
322 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
323 | + unset( $qv[ 'paged' ] ); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
352 | 352 | |
353 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
353 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
354 | 354 | $this->setPostId( $post_id ); |
355 | 355 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
356 | 356 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
388 | 388 | |
389 | - if( 'post' === $search_method ) { |
|
389 | + if ( 'post' === $search_method ) { |
|
390 | 390 | $get = $_POST; |
391 | 391 | } else { |
392 | 392 | $get = $_GET; |
@@ -443,20 +443,20 @@ discard block |
||
443 | 443 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
444 | 444 | * @param array $entry Current entry |
445 | 445 | */ |
446 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
446 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
447 | 447 | |
448 | 448 | if ( ! $apply_outside_loop ) { |
449 | 449 | return $title; |
450 | 450 | } |
451 | 451 | |
452 | 452 | // User reported WooCommerce doesn't pass two args. |
453 | - if ( empty( $passed_post_id ) ) { |
|
453 | + if ( empty( $passed_post_id ) ) { |
|
454 | 454 | return $title; |
455 | 455 | } |
456 | 456 | |
457 | 457 | // Don't modify the title for anything other than the current view/post. |
458 | 458 | // This is true for embedded shortcodes and Views. |
459 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
459 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
460 | 460 | return $title; |
461 | 461 | } |
462 | 462 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
469 | 469 | } else { |
470 | 470 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
471 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
471 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
472 | 472 | $view_meta = $view_data; |
473 | 473 | break; |
474 | 474 | } |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | /** Deprecated stuff in the future. See the branch above. */ |
479 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
479 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
480 | 480 | |
481 | - $title = $view_meta['atts']['single_title']; |
|
481 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
482 | 482 | |
483 | 483 | // We are allowing HTML in the fields, so no escaping the output |
484 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
484 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
485 | 485 | |
486 | 486 | $title = do_shortcode( $title ); |
487 | 487 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | $context = GravityView_View::getInstance()->getContext(); |
554 | 554 | |
555 | - switch( $context ) { |
|
555 | + switch ( $context ) { |
|
556 | 556 | case 'directory': |
557 | 557 | $tab = __( 'Multiple Entries', 'gravityview' ); |
558 | 558 | break; |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | |
569 | - $title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
569 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
570 | 570 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
571 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
571 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
572 | 572 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
573 | 573 | |
574 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url(plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
574 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
575 | 575 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
576 | 576 | |
577 | 577 | echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id ); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view->ID ); |
620 | 620 | $embed_only = $view->settings->get( 'embed_only' ); |
621 | 621 | |
622 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
622 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
623 | 623 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
624 | 624 | } |
625 | 625 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $datetime_format = 'Y-m-d H:i:s'; |
667 | 667 | $search_is_outside_view_bounds = false; |
668 | 668 | |
669 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
669 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
670 | 670 | |
671 | 671 | $search_date = strtotime( $search_criteria[ $key ] ); |
672 | 672 | |
@@ -694,14 +694,14 @@ discard block |
||
694 | 694 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
695 | 695 | |
696 | 696 | // Then we override the search and re-set the start date |
697 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
697 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
701 | 701 | |
702 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
702 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
703 | 703 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
704 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
704 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
705 | 705 | gravityview()->log->error( 'Invalid search: the start date is after the end date.', array( 'data' => $return_search_criteria ) ); |
706 | 706 | } |
707 | 707 | } |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | public static function process_search_only_approved( $args, $search_criteria ) { |
721 | 721 | |
722 | 722 | /** @since 1.19 */ |
723 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
723 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
724 | 724 | gravityview()->log->debug( 'User can moderate entries; showing all approval statuses' ); |
725 | 725 | return $search_criteria; |
726 | 726 | } |
727 | 727 | |
728 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
728 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
729 | 729 | |
730 | - $search_criteria['field_filters'][] = array( |
|
730 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
731 | 731 | 'key' => GravityView_Entry_Approval::meta_key, |
732 | 732 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
733 | 733 | ); |
734 | 734 | |
735 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
735 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
736 | 736 | |
737 | 737 | gravityview()->log->debug( '[process_search_only_approved] Search Criteria if show only approved: ', array( 'data' => $search_criteria ) ); |
738 | 738 | } |
@@ -759,18 +759,18 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public static function is_entry_approved( $entry, $args = array() ) { |
761 | 761 | |
762 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
762 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
763 | 763 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
764 | 764 | return true; |
765 | 765 | } |
766 | 766 | |
767 | 767 | /** @since 1.19 */ |
768 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
768 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
769 | 769 | gravityview()->log->debug( 'User can moderate entries, so entry is approved for viewing' ); |
770 | 770 | return true; |
771 | 771 | } |
772 | 772 | |
773 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
773 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
774 | 774 | |
775 | 775 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
776 | 776 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * Compatibility with filters hooking in `gravityview_search_criteria` instead of `gravityview_fe_search_criteria`. |
795 | 795 | */ |
796 | 796 | $criteria = apply_filters( 'gravityview_search_criteria', array(), array( $form_id ), \GV\Utils::get( $args, 'id' ) ); |
797 | - $search_criteria = isset( $criteria['search_criteria'] ) ? $criteria['search_criteria'] : array( 'field_filters' => array() ); |
|
797 | + $search_criteria = isset( $criteria[ 'search_criteria' ] ) ? $criteria[ 'search_criteria' ] : array( 'field_filters' => array() ); |
|
798 | 798 | |
799 | 799 | /** |
800 | 800 | * @filter `gravityview_fe_search_criteria` Modify the search criteria |
@@ -810,29 +810,29 @@ discard block |
||
810 | 810 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', array( 'data' =>$search_criteria ) ); |
811 | 811 | |
812 | 812 | // implicity search |
813 | - if ( ! empty( $args['search_value'] ) ) { |
|
813 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
814 | 814 | |
815 | 815 | // Search operator options. Options: `is` or `contains` |
816 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
816 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
817 | 817 | |
818 | - $search_criteria['field_filters'][] = array( |
|
818 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
819 | 819 | 'key' => \GV\Utils::_GET( 'search_field', \GV\Utils::get( $args, 'search_field' ) ), // The field ID to search |
820 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
820 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
821 | 821 | 'operator' => $operator, |
822 | 822 | ); |
823 | 823 | |
824 | 824 | // Lock search mode to "all" with implicit presearch filter. |
825 | - $search_criteria['field_filters']['mode'] = 'all'; |
|
825 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; |
|
826 | 826 | } |
827 | 827 | |
828 | - if( $search_criteria !== $original_search_criteria ) { |
|
828 | + if ( $search_criteria !== $original_search_criteria ) { |
|
829 | 829 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after implicity search: ', array( 'data' => $search_criteria ) ); |
830 | 830 | } |
831 | 831 | |
832 | 832 | // Handle setting date range |
833 | 833 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
834 | 834 | |
835 | - if( $search_criteria !== $original_search_criteria ) { |
|
835 | + if ( $search_criteria !== $original_search_criteria ) { |
|
836 | 836 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after date params: ', array( 'data' => $search_criteria ) ); |
837 | 837 | } |
838 | 838 | |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
844 | 844 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
845 | 845 | */ |
846 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
846 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
847 | 847 | |
848 | 848 | return $search_criteria; |
849 | 849 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | 'search_criteria' => $search_criteria, |
957 | 957 | 'sorting' => self::updateViewSorting( $args, $form_id ), |
958 | 958 | 'paging' => $paging, |
959 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
959 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
960 | 960 | ); |
961 | 961 | |
962 | 962 | /** |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
982 | 982 | * @param array $args View configuration args. |
983 | 983 | */ |
984 | - $parameters = apply_filters( 'gravityview_get_entries_'.\GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
984 | + $parameters = apply_filters( 'gravityview_get_entries_' . \GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
985 | 985 | |
986 | 986 | gravityview()->log->debug( '$parameters passed to gravityview_get_entries(): ', array( 'data' => $parameters ) ); |
987 | 987 | |
@@ -1006,17 +1006,17 @@ discard block |
||
1006 | 1006 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
1007 | 1007 | |
1008 | 1008 | // Paging & offset |
1009 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
1009 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size; |
|
1010 | 1010 | |
1011 | 1011 | if ( -1 === $page_size ) { |
1012 | 1012 | $page_size = PHP_INT_MAX; |
1013 | 1013 | } |
1014 | 1014 | |
1015 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1015 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
1016 | 1016 | $offset = ( $curr_page - 1 ) * $page_size; |
1017 | 1017 | |
1018 | - if ( ! empty( $args['offset'] ) ) { |
|
1019 | - $offset += intval( $args['offset'] ); |
|
1018 | + if ( ! empty( $args[ 'offset' ] ) ) { |
|
1019 | + $offset += intval( $args[ 'offset' ] ); |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | $paging = array( |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | */ |
1041 | 1041 | public static function updateViewSorting( $args, $form_id ) { |
1042 | 1042 | $sorting = array(); |
1043 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : \GV\Utils::get( $args, 'sort_field' ); |
|
1044 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1043 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : \GV\Utils::get( $args, 'sort_field' ); |
|
1044 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1045 | 1045 | |
1046 | 1046 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
1047 | 1047 | |
@@ -1058,12 +1058,12 @@ discard block |
||
1058 | 1058 | $form = GFAPI::get_form( $form_id ); |
1059 | 1059 | |
1060 | 1060 | // Get the first GF_Field field ID, set as the key for entry randomization |
1061 | - if( ! empty( $form['fields'] ) ) { |
|
1061 | + if ( ! empty( $form[ 'fields' ] ) ) { |
|
1062 | 1062 | |
1063 | 1063 | /** @var GF_Field $field */ |
1064 | - foreach ( $form['fields'] as $field ) { |
|
1064 | + foreach ( $form[ 'fields' ] as $field ) { |
|
1065 | 1065 | |
1066 | - if( ! is_a( $field, 'GF_Field' ) ) { |
|
1066 | + if ( ! is_a( $field, 'GF_Field' ) ) { |
|
1067 | 1067 | continue; |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1107,11 +1107,11 @@ discard block |
||
1107 | 1107 | |
1108 | 1108 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
1109 | 1109 | |
1110 | - if( ! $sort_field ) { |
|
1110 | + if ( ! $sort_field ) { |
|
1111 | 1111 | return $sort_field_id; |
1112 | 1112 | } |
1113 | 1113 | |
1114 | - switch ( $sort_field['type'] ) { |
|
1114 | + switch ( $sort_field[ 'type' ] ) { |
|
1115 | 1115 | |
1116 | 1116 | case 'address': |
1117 | 1117 | // Sorting by full address |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | */ |
1129 | 1129 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1130 | 1130 | |
1131 | - switch( strtolower( $address_part ) ){ |
|
1131 | + switch ( strtolower( $address_part ) ) { |
|
1132 | 1132 | case 'street': |
1133 | 1133 | $sort_field_id .= '.1'; |
1134 | 1134 | break; |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1210 | 1210 | |
1211 | - if ( empty( $single_entry ) ){ |
|
1211 | + if ( empty( $single_entry ) ) { |
|
1212 | 1212 | return false; |
1213 | 1213 | } else { |
1214 | 1214 | return $single_entry; |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | $views = $this->getGvOutputData()->get_views(); |
1231 | 1231 | |
1232 | 1232 | foreach ( $views as $view_id => $data ) { |
1233 | - $view = \GV\View::by_id( $data['id'] ); |
|
1233 | + $view = \GV\View::by_id( $data[ 'id' ] ); |
|
1234 | 1234 | $view_id = $view->ID; |
1235 | 1235 | $template_id = gravityview_get_template_id( $view->ID ); |
1236 | 1236 | $data = $view->as_data(); |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1240 | 1240 | * @since 1.15 |
1241 | 1241 | */ |
1242 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1242 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1243 | 1243 | continue; |
1244 | 1244 | } |
1245 | 1245 | |
@@ -1256,13 +1256,13 @@ discard block |
||
1256 | 1256 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
1257 | 1257 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
1258 | 1258 | */ |
1259 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1259 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1260 | 1260 | |
1261 | 1261 | /** |
1262 | 1262 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
1263 | 1263 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
1264 | 1264 | */ |
1265 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1265 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | /** |
@@ -1270,19 +1270,19 @@ discard block |
||
1270 | 1270 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1271 | 1271 | * @since 1.15 |
1272 | 1272 | */ |
1273 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1274 | - $css_dependencies[] = 'dashicons'; |
|
1273 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
1274 | + $css_dependencies[ ] = 'dashicons'; |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
1278 | 1278 | |
1279 | 1279 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
1280 | 1280 | |
1281 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
1281 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
1282 | 1282 | |
1283 | 1283 | wp_enqueue_script( 'gravityview-fe-view' ); |
1284 | 1284 | |
1285 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1285 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
1286 | 1286 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
1287 | 1287 | } |
1288 | 1288 | |
@@ -1345,7 +1345,7 @@ discard block |
||
1345 | 1345 | public static function add_style( $template_id ) { |
1346 | 1346 | |
1347 | 1347 | if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) { |
1348 | - gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1348 | + gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1349 | 1349 | wp_enqueue_style( 'gravityview_style_' . $template_id ); |
1350 | 1350 | } elseif ( empty( $template_id ) ) { |
1351 | 1351 | gravityview()->log->error( 'Cannot add template style; template_id is empty' ); |
@@ -1376,11 +1376,11 @@ discard block |
||
1376 | 1376 | * Not a table-based template; don't add sort icons |
1377 | 1377 | * @since 1.12 |
1378 | 1378 | */ |
1379 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1379 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1380 | 1380 | return $label; |
1381 | 1381 | } |
1382 | 1382 | |
1383 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1383 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
1384 | 1384 | return $label; |
1385 | 1385 | } |
1386 | 1386 | |
@@ -1388,29 +1388,29 @@ discard block |
||
1388 | 1388 | |
1389 | 1389 | $class = 'gv-sort'; |
1390 | 1390 | |
1391 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1391 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
1392 | 1392 | |
1393 | 1393 | $sort_args = array( |
1394 | - 'sort' => $field['id'], |
|
1394 | + 'sort' => $field[ 'id' ], |
|
1395 | 1395 | 'dir' => 'asc', |
1396 | 1396 | ); |
1397 | 1397 | |
1398 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1398 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
1399 | 1399 | //toggle sorting direction. |
1400 | - if ( 'asc' === $sorting['direction'] ) { |
|
1401 | - $sort_args['dir'] = 'desc'; |
|
1400 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
1401 | + $sort_args[ 'dir' ] = 'desc'; |
|
1402 | 1402 | $class .= ' gv-icon-sort-desc'; |
1403 | 1403 | } else { |
1404 | - $sort_args['dir'] = 'asc'; |
|
1404 | + $sort_args[ 'dir' ] = 'asc'; |
|
1405 | 1405 | $class .= ' gv-icon-sort-asc'; |
1406 | 1406 | } |
1407 | 1407 | } else { |
1408 | 1408 | $class .= ' gv-icon-caret-up-down'; |
1409 | 1409 | } |
1410 | 1410 | |
1411 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1411 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
1412 | 1412 | |
1413 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1413 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
1414 | 1414 | |
1415 | 1415 | } |
1416 | 1416 | |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | |
1429 | 1429 | $field_type = $field_id; |
1430 | 1430 | |
1431 | - if( is_numeric( $field_id ) ) { |
|
1431 | + if ( is_numeric( $field_id ) ) { |
|
1432 | 1432 | $field = GFFormsModel::get_field( $form, $field_id ); |
1433 | 1433 | $field_type = $field ? $field->type : $field_id; |
1434 | 1434 | } |
@@ -1451,7 +1451,7 @@ discard block |
||
1451 | 1451 | return false; |
1452 | 1452 | } |
1453 | 1453 | |
1454 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1454 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1455 | 1455 | |
1456 | 1456 | } |
1457 | 1457 |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | function load() { |
116 | 116 | |
117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
119 | 119 | |
120 | 120 | // Don't display an embedded form when editing an entry |
121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
123 | 123 | |
124 | 124 | // Stop Gravity Forms processing what is ours! |
125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
126 | 126 | |
127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
128 | 128 | |
129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
136 | 136 | |
137 | 137 | // Add fields expected by GFFormDisplay::validate() |
138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
139 | 139 | |
140 | 140 | // Fix multiselect value for GF 2.2 |
141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | public function prevent_render_form() { |
155 | - if( $this->is_edit_entry() ) { |
|
156 | - if( 'wp_head' === current_filter() ) { |
|
155 | + if ( $this->is_edit_entry() ) { |
|
156 | + if ( 'wp_head' === current_filter() ) { |
|
157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
158 | 158 | } else { |
159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | - if( ! empty( $_POST ) ) { |
|
171 | + if ( ! empty( $_POST ) ) { |
|
172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
173 | 173 | } |
174 | 174 | |
175 | - if( $this->is_edit_entry_submission() ) { |
|
176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
175 | + if ( $this->is_edit_entry_submission() ) { |
|
176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function is_edit_entry() { |
186 | 186 | |
187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
188 | 188 | |
189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return boolean |
196 | 196 | */ |
197 | 197 | public function is_edit_entry_submission() { |
198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[ 0 ]; |
|
212 | + $this->entry = $entries[ 0 ]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
219 | 219 | |
220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | private function print_scripts() { |
269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
270 | 270 | |
271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
272 | 272 | |
273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
274 | 274 | |
275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
276 | 276 | |
@@ -286,19 +286,19 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function process_save( $gv_data ) { |
288 | 288 | |
289 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
289 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
290 | 290 | return; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Make sure the entry, view, and form IDs are all correct |
294 | 294 | $valid = $this->verify_nonce(); |
295 | 295 | |
296 | - if ( !$valid ) { |
|
296 | + if ( ! $valid ) { |
|
297 | 297 | gravityview()->log->error( 'Nonce validation failed.' ); |
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
301 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
301 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
302 | 302 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
303 | 303 | return; |
304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | $this->validate(); |
311 | 311 | |
312 | - if( $this->is_valid ) { |
|
312 | + if ( $this->is_valid ) { |
|
313 | 313 | |
314 | 314 | gravityview()->log->debug( 'Submission is valid.' ); |
315 | 315 | |
@@ -321,22 +321,22 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
323 | 323 | */ |
324 | - unset( $_GET['page'] ); |
|
324 | + unset( $_GET[ 'page' ] ); |
|
325 | 325 | |
326 | - $date_created = $this->entry['date_created']; |
|
326 | + $date_created = $this->entry[ 'date_created' ]; |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
330 | 330 | * @since 1.17.2 |
331 | 331 | */ |
332 | - unset( $this->entry['date_created'] ); |
|
332 | + unset( $this->entry[ 'date_created' ] ); |
|
333 | 333 | |
334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
335 | 335 | |
336 | 336 | // Delete the values for hidden inputs |
337 | 337 | $this->unset_hidden_field_values(); |
338 | 338 | |
339 | - $this->entry['date_created'] = $date_created; |
|
339 | + $this->entry[ 'date_created' ] = $date_created; |
|
340 | 340 | |
341 | 341 | // Process calculation fields |
342 | 342 | $this->update_calculation_fields(); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param GravityView_Edit_Entry_Render $this This object |
359 | 359 | * @param GravityView_View_Data $gv_data The View data |
360 | 360 | */ |
361 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
361 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
362 | 362 | |
363 | 363 | } else { |
364 | 364 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -386,16 +386,16 @@ discard block |
||
386 | 386 | */ |
387 | 387 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
388 | 388 | |
389 | - if( ! $unset_hidden_field_values ) { |
|
389 | + if ( ! $unset_hidden_field_values ) { |
|
390 | 390 | return; |
391 | 391 | } |
392 | 392 | |
393 | 393 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
394 | 394 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
395 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
395 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
396 | 396 | } else { |
397 | 397 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
398 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
398 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | /** No file is being uploaded. */ |
479 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
479 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
480 | 480 | /** So return the original upload */ |
481 | 481 | return $entry[ $input_id ]; |
482 | 482 | } |
@@ -494,11 +494,11 @@ discard block |
||
494 | 494 | * @return mixed |
495 | 495 | */ |
496 | 496 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
497 | - if( ! $this->is_edit_entry() ) { |
|
497 | + if ( ! $this->is_edit_entry() ) { |
|
498 | 498 | return $plupload_init; |
499 | 499 | } |
500 | 500 | |
501 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
501 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
502 | 502 | |
503 | 503 | return $plupload_init; |
504 | 504 | } |
@@ -513,27 +513,27 @@ discard block |
||
513 | 513 | $form = $this->form; |
514 | 514 | |
515 | 515 | /** @var GF_Field $field */ |
516 | - foreach( $form['fields'] as $k => &$field ) { |
|
516 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
517 | 517 | |
518 | 518 | /** |
519 | 519 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
520 | 520 | * @since 1.16.3 |
521 | 521 | * @var GF_Field $field |
522 | 522 | */ |
523 | - if( $field->has_calculation() ) { |
|
524 | - unset( $form['fields'][ $k ] ); |
|
523 | + if ( $field->has_calculation() ) { |
|
524 | + unset( $form[ 'fields' ][ $k ] ); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | $field->adminOnly = false; |
528 | 528 | |
529 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
530 | - foreach( $field->inputs as $key => $input ) { |
|
531 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
529 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
530 | + foreach ( $field->inputs as $key => $input ) { |
|
531 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
536 | - $form['fields'] = array_values( $form['fields'] ); |
|
536 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
537 | 537 | |
538 | 538 | return $form; |
539 | 539 | } |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | $update = false; |
546 | 546 | |
547 | 547 | // get the most up to date entry values |
548 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
548 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
549 | 549 | |
550 | 550 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
551 | 551 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
552 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, meta_key FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
552 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, meta_key FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
553 | 553 | } else { |
554 | 554 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
555 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
555 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | if ( ! empty( $this->fields_with_calculation ) ) { |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | $inputs = $field->get_entry_inputs(); |
562 | 562 | if ( is_array( $inputs ) ) { |
563 | 563 | foreach ( $inputs as $input ) { |
564 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
564 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
565 | 565 | } |
566 | 566 | } else { |
567 | 567 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $field->id ); |
@@ -597,19 +597,19 @@ discard block |
||
597 | 597 | |
598 | 598 | $input_name = 'input_' . $field_id; |
599 | 599 | |
600 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
600 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
601 | 601 | |
602 | 602 | // We have a new image |
603 | 603 | |
604 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
604 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
605 | 605 | |
606 | 606 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
607 | 607 | $ary = stripslashes_deep( $ary ); |
608 | 608 | $img_url = \GV\Utils::get( $ary, 0 ); |
609 | 609 | |
610 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
611 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
612 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
610 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
611 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
612 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
613 | 613 | |
614 | 614 | $image_meta = array( |
615 | 615 | 'post_excerpt' => $img_caption, |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
620 | 620 | if ( ! empty( $img_title ) ) { |
621 | - $image_meta['post_title'] = $img_title; |
|
621 | + $image_meta[ 'post_title' ] = $img_title; |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -676,15 +676,15 @@ discard block |
||
676 | 676 | */ |
677 | 677 | private function maybe_update_post_fields( $form ) { |
678 | 678 | |
679 | - if( empty( $this->entry['post_id'] ) ) { |
|
679 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
680 | 680 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
681 | 681 | return; |
682 | 682 | } |
683 | 683 | |
684 | - $post_id = $this->entry['post_id']; |
|
684 | + $post_id = $this->entry[ 'post_id' ]; |
|
685 | 685 | |
686 | 686 | // Security check |
687 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
687 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
688 | 688 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
689 | 689 | return; |
690 | 690 | } |
@@ -697,25 +697,25 @@ discard block |
||
697 | 697 | |
698 | 698 | $field = RGFormsModel::get_field( $form, $field_id ); |
699 | 699 | |
700 | - if( ! $field ) { |
|
700 | + if ( ! $field ) { |
|
701 | 701 | continue; |
702 | 702 | } |
703 | 703 | |
704 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
704 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
705 | 705 | |
706 | 706 | // Get the value of the field, including $_POSTed value |
707 | 707 | $value = RGFormsModel::get_field_value( $field ); |
708 | 708 | |
709 | 709 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
710 | 710 | $entry_tmp = $this->entry; |
711 | - $entry_tmp["{$field_id}"] = $value; |
|
711 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
712 | 712 | |
713 | - switch( $field->type ) { |
|
713 | + switch ( $field->type ) { |
|
714 | 714 | |
715 | 715 | case 'post_title': |
716 | 716 | $post_title = $value; |
717 | 717 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
718 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
718 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
719 | 719 | } |
720 | 720 | $updated_post->post_title = $post_title; |
721 | 721 | $updated_post->post_name = $post_title; |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | case 'post_content': |
726 | 726 | $post_content = $value; |
727 | 727 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
728 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
728 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
729 | 729 | } |
730 | 730 | $updated_post->post_content = $post_content; |
731 | 731 | unset( $post_content ); |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | $value = $value[ $field_id ]; |
744 | 744 | } |
745 | 745 | |
746 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
746 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
747 | 747 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
748 | 748 | } |
749 | 749 | |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | } |
762 | 762 | |
763 | 763 | // update entry after |
764 | - $this->entry["{$field_id}"] = $value; |
|
764 | + $this->entry[ "{$field_id}" ] = $value; |
|
765 | 765 | |
766 | 766 | $update_entry = true; |
767 | 767 | |
@@ -770,11 +770,11 @@ discard block |
||
770 | 770 | |
771 | 771 | } |
772 | 772 | |
773 | - if( $update_entry ) { |
|
773 | + if ( $update_entry ) { |
|
774 | 774 | |
775 | 775 | $return_entry = GFAPI::update_entry( $this->entry ); |
776 | 776 | |
777 | - if( is_wp_error( $return_entry ) ) { |
|
777 | + if ( is_wp_error( $return_entry ) ) { |
|
778 | 778 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
779 | 779 | } else { |
780 | 780 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | |
785 | 785 | $return_post = wp_update_post( $updated_post, true ); |
786 | 786 | |
787 | - if( is_wp_error( $return_post ) ) { |
|
787 | + if ( is_wp_error( $return_post ) ) { |
|
788 | 788 | $return_post->add_data( $updated_post, '$updated_post' ); |
789 | 789 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
790 | 790 | } else { |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | $input_type = RGFormsModel::get_input_type( $field ); |
807 | 807 | |
808 | 808 | // Only certain custom field types are supported |
809 | - switch( $input_type ) { |
|
809 | + switch ( $input_type ) { |
|
810 | 810 | case 'fileupload': |
811 | 811 | case 'list': |
812 | 812 | case 'multiselect': |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
844 | 844 | |
845 | 845 | // replace conditional shortcodes |
846 | - if( $do_shortcode ) { |
|
846 | + if ( $do_shortcode ) { |
|
847 | 847 | $output = do_shortcode( $output ); |
848 | 848 | } |
849 | 849 | |
@@ -862,19 +862,19 @@ discard block |
||
862 | 862 | */ |
863 | 863 | private function after_update() { |
864 | 864 | |
865 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
866 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
865 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
866 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
867 | 867 | |
868 | 868 | // Re-define the entry now that we've updated it. |
869 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
869 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
870 | 870 | |
871 | 871 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
872 | 872 | |
873 | 873 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
874 | 874 | // We need to clear the cache because Gravity Forms caches the field values, which |
875 | 875 | // we have just updated. |
876 | - foreach ($this->form['fields'] as $key => $field) { |
|
877 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
876 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
877 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | |
894 | 894 | <div class="gv-edit-entry-wrapper"><?php |
895 | 895 | |
896 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
896 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
897 | 897 | |
898 | 898 | /** |
899 | 899 | * Fixes weird wpautop() issue |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | * @param string $edit_entry_title Modify the "Edit Entry" title |
910 | 910 | * @param GravityView_Edit_Entry_Render $this This object |
911 | 911 | */ |
912 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
912 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
913 | 913 | |
914 | 914 | echo esc_attr( $edit_entry_title ); |
915 | 915 | ?></span> |
@@ -959,13 +959,13 @@ discard block |
||
959 | 959 | |
960 | 960 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
961 | 961 | |
962 | - if( ! $this->is_valid ){ |
|
962 | + if ( ! $this->is_valid ) { |
|
963 | 963 | |
964 | 964 | // Keeping this compatible with Gravity Forms. |
965 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
966 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
965 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
966 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
967 | 967 | |
968 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
968 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
969 | 969 | |
970 | 970 | } else { |
971 | 971 | $view = \GV\View::by_id( $this->view_id ); |
@@ -976,23 +976,23 @@ discard block |
||
976 | 976 | |
977 | 977 | case '0': |
978 | 978 | $redirect_url = $back_link; |
979 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturning to Entry%s', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
979 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturning to Entry%s', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
980 | 980 | break; |
981 | 981 | |
982 | 982 | case '1': |
983 | 983 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
984 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturning to %s%s', 'gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
984 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturning to %s%s', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
985 | 985 | break; |
986 | 986 | |
987 | 987 | case '2': |
988 | 988 | $redirect_url = $edit_redirect_url; |
989 | 989 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
990 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sRedirecting to %s%s', 'gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
990 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sRedirecting to %s%s', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
991 | 991 | break; |
992 | 992 | |
993 | 993 | case '': |
994 | 994 | default: |
995 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
995 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
996 | 996 | break; |
997 | 997 | } |
998 | 998 | |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | * @param array $entry Gravity Forms entry array |
1009 | 1009 | * @param string $back_link URL to return to the original entry. @since 1.6 |
1010 | 1010 | */ |
1011 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
1011 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
1012 | 1012 | |
1013 | 1013 | echo GVCommon::generate_notice( $message ); |
1014 | 1014 | } |
@@ -1032,21 +1032,21 @@ discard block |
||
1032 | 1032 | */ |
1033 | 1033 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1034 | 1034 | |
1035 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1036 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1035 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1036 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1037 | 1037 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
1038 | 1038 | |
1039 | 1039 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
1040 | 1040 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1041 | 1041 | |
1042 | 1042 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1043 | - unset( $_GET['page'] ); |
|
1043 | + unset( $_GET[ 'page' ] ); |
|
1044 | 1044 | |
1045 | 1045 | // TODO: Verify multiple-page forms |
1046 | 1046 | |
1047 | 1047 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1048 | 1048 | |
1049 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1049 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1050 | 1050 | |
1051 | 1051 | ob_get_clean(); |
1052 | 1052 | |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | * @return string |
1073 | 1073 | */ |
1074 | 1074 | public function render_form_buttons() { |
1075 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1075 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | |
@@ -1092,10 +1092,10 @@ discard block |
||
1092 | 1092 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1093 | 1093 | |
1094 | 1094 | // In case we have validated the form, use it to inject the validation results into the form render |
1095 | - if( isset( $this->form_after_validation ) ) { |
|
1095 | + if ( isset( $this->form_after_validation ) ) { |
|
1096 | 1096 | $form = $this->form_after_validation; |
1097 | 1097 | } else { |
1098 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1098 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | $form = $this->filter_conditional_logic( $form ); |
@@ -1103,8 +1103,8 @@ discard block |
||
1103 | 1103 | $form = $this->prefill_conditional_logic( $form ); |
1104 | 1104 | |
1105 | 1105 | // for now we don't support Save and Continue feature. |
1106 | - if( ! self::$supports_save_and_continue ) { |
|
1107 | - unset( $form['save'] ); |
|
1106 | + if ( ! self::$supports_save_and_continue ) { |
|
1107 | + unset( $form[ 'save' ] ); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | $form = $this->unselect_default_values( $form ); |
@@ -1127,31 +1127,31 @@ discard block |
||
1127 | 1127 | */ |
1128 | 1128 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1129 | 1129 | |
1130 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
1130 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
1131 | 1131 | return $field_content; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | $message = null; |
1135 | 1135 | |
1136 | 1136 | // First, make sure they have the capability to edit the post. |
1137 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1137 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1138 | 1138 | |
1139 | 1139 | /** |
1140 | 1140 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1141 | 1141 | * @param string $message The existing "You don't have permission..." text |
1142 | 1142 | */ |
1143 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1143 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1144 | 1144 | |
1145 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1145 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1146 | 1146 | /** |
1147 | 1147 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1148 | 1148 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1149 | 1149 | */ |
1150 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1150 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | - if( $message ) { |
|
1154 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1153 | + if ( $message ) { |
|
1154 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | return $field_content; |
@@ -1175,8 +1175,8 @@ discard block |
||
1175 | 1175 | |
1176 | 1176 | // If the form has been submitted, then we don't need to pre-fill the values, |
1177 | 1177 | // Except for fileupload type and when a field input is overridden- run always!! |
1178 | - if( |
|
1179 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1178 | + if ( |
|
1179 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1180 | 1180 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1181 | 1181 | && ! GFCommon::is_product_field( $field->type ) |
1182 | 1182 | || ! empty( $field_content ) |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | $return = null; |
1197 | 1197 | |
1198 | 1198 | /** @var GravityView_Field $gv_field */ |
1199 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1199 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1200 | 1200 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1201 | 1201 | } else { |
1202 | 1202 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1205,7 +1205,7 @@ discard block |
||
1205 | 1205 | // If there was output, it's an error |
1206 | 1206 | $warnings = ob_get_clean(); |
1207 | 1207 | |
1208 | - if( !empty( $warnings ) ) { |
|
1208 | + if ( ! empty( $warnings ) ) { |
|
1209 | 1209 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1231 | 1231 | |
1232 | 1232 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1233 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1233 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1234 | 1234 | |
1235 | 1235 | $field_value = array(); |
1236 | 1236 | |
@@ -1239,10 +1239,10 @@ discard block |
||
1239 | 1239 | |
1240 | 1240 | foreach ( (array)$field->inputs as $input ) { |
1241 | 1241 | |
1242 | - $input_id = strval( $input['id'] ); |
|
1242 | + $input_id = strval( $input[ 'id' ] ); |
|
1243 | 1243 | |
1244 | 1244 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1245 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1245 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1246 | 1246 | $allow_pre_populated = false; |
1247 | 1247 | } |
1248 | 1248 | |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | |
1251 | 1251 | $pre_value = $field->get_value_submission( array(), false ); |
1252 | 1252 | |
1253 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1253 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1254 | 1254 | |
1255 | 1255 | } else { |
1256 | 1256 | |
@@ -1261,13 +1261,13 @@ discard block |
||
1261 | 1261 | |
1262 | 1262 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1263 | 1263 | // or pre-populated value if not empty and set to override saved value |
1264 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1264 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1265 | 1265 | |
1266 | 1266 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1267 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1267 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1268 | 1268 | $categories = array(); |
1269 | 1269 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1270 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1270 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1271 | 1271 | } |
1272 | 1272 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1273 | 1273 | } |
@@ -1295,7 +1295,7 @@ discard block |
||
1295 | 1295 | * @param GF_Field $field Gravity Forms field object |
1296 | 1296 | * @param GravityView_Edit_Entry_Render $this Current object |
1297 | 1297 | */ |
1298 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1298 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1299 | 1299 | |
1300 | 1300 | return $field_value; |
1301 | 1301 | } |
@@ -1312,12 +1312,12 @@ discard block |
||
1312 | 1312 | */ |
1313 | 1313 | public function gform_pre_validation( $form ) { |
1314 | 1314 | |
1315 | - if( ! $this->verify_nonce() ) { |
|
1315 | + if ( ! $this->verify_nonce() ) { |
|
1316 | 1316 | return $form; |
1317 | 1317 | } |
1318 | 1318 | |
1319 | 1319 | // Fix PHP warning regarding undefined index. |
1320 | - foreach ( $form['fields'] as &$field) { |
|
1320 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1321 | 1321 | |
1322 | 1322 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1323 | 1323 | // expects certain field array items to be set. |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1326 | 1326 | } |
1327 | 1327 | |
1328 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1328 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1329 | 1329 | |
1330 | 1330 | /** |
1331 | 1331 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1339,26 +1339,26 @@ discard block |
||
1339 | 1339 | // Set the previous value |
1340 | 1340 | $entry = $this->get_entry(); |
1341 | 1341 | |
1342 | - $input_name = 'input_'.$field->id; |
|
1343 | - $form_id = $form['id']; |
|
1342 | + $input_name = 'input_' . $field->id; |
|
1343 | + $form_id = $form[ 'id' ]; |
|
1344 | 1344 | |
1345 | 1345 | $value = NULL; |
1346 | 1346 | |
1347 | 1347 | // Use the previous entry value as the default. |
1348 | - if( isset( $entry[ $field->id ] ) ) { |
|
1348 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1349 | 1349 | $value = $entry[ $field->id ]; |
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | // If this is a single upload file |
1353 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1354 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1355 | - $value = $file_path['url']; |
|
1353 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1354 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1355 | + $value = $file_path[ 'url' ]; |
|
1356 | 1356 | |
1357 | 1357 | } else { |
1358 | 1358 | |
1359 | 1359 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1360 | 1360 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1361 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1361 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1362 | 1362 | |
1363 | 1363 | } |
1364 | 1364 | |
@@ -1366,10 +1366,10 @@ discard block |
||
1366 | 1366 | |
1367 | 1367 | // If there are fresh uploads, process and merge them. |
1368 | 1368 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1369 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1369 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1370 | 1370 | $value = empty( $value ) ? '[]' : $value; |
1371 | 1371 | $value = stripslashes_deep( $value ); |
1372 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1372 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | } else { |
@@ -1387,8 +1387,8 @@ discard block |
||
1387 | 1387 | |
1388 | 1388 | case 'number': |
1389 | 1389 | // Fix "undefined index" issue at line 1286 in form_display.php |
1390 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1391 | - $_POST['input_'.$field->id ] = NULL; |
|
1390 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1391 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1392 | 1392 | } |
1393 | 1393 | break; |
1394 | 1394 | } |
@@ -1425,7 +1425,7 @@ discard block |
||
1425 | 1425 | * You can enter whatever you want! |
1426 | 1426 | * We try validating, and customize the results using `self::custom_validation()` |
1427 | 1427 | */ |
1428 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1428 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1429 | 1429 | |
1430 | 1430 | // Needed by the validate funtion |
1431 | 1431 | $failed_validation_page = NULL; |
@@ -1433,14 +1433,14 @@ discard block |
||
1433 | 1433 | |
1434 | 1434 | // Prevent entry limit from running when editing an entry, also |
1435 | 1435 | // prevent form scheduling from preventing editing |
1436 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1436 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1437 | 1437 | |
1438 | 1438 | // Hide fields depending on Edit Entry settings |
1439 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1439 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1440 | 1440 | |
1441 | 1441 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1442 | 1442 | |
1443 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1443 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | |
1464 | 1464 | $gv_valid = true; |
1465 | 1465 | |
1466 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1466 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1467 | 1467 | |
1468 | 1468 | $value = RGFormsModel::get_field_value( $field ); |
1469 | 1469 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1476,35 +1476,35 @@ discard block |
||
1476 | 1476 | case 'post_image': |
1477 | 1477 | |
1478 | 1478 | // in case nothing is uploaded but there are already files saved |
1479 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1479 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1480 | 1480 | $field->failed_validation = false; |
1481 | 1481 | unset( $field->validation_message ); |
1482 | 1482 | } |
1483 | 1483 | |
1484 | 1484 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1485 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1485 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1486 | 1486 | |
1487 | 1487 | $input_name = 'input_' . $field->id; |
1488 | 1488 | //uploaded |
1489 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1489 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1490 | 1490 | |
1491 | 1491 | //existent |
1492 | 1492 | $entry = $this->get_entry(); |
1493 | 1493 | $value = NULL; |
1494 | - if( isset( $entry[ $field->id ] ) ) { |
|
1494 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1495 | 1495 | $value = json_decode( $entry[ $field->id ], true ); |
1496 | 1496 | } |
1497 | 1497 | |
1498 | 1498 | // count uploaded files and existent entry files |
1499 | 1499 | $count_files = count( $file_names ) + count( $value ); |
1500 | 1500 | |
1501 | - if( $count_files > $field->maxFiles ) { |
|
1501 | + if ( $count_files > $field->maxFiles ) { |
|
1502 | 1502 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1503 | 1503 | $field->failed_validation = 1; |
1504 | 1504 | $gv_valid = false; |
1505 | 1505 | |
1506 | 1506 | // in case of error make sure the newest upload files are removed from the upload input |
1507 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1507 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | } |
@@ -1515,7 +1515,7 @@ discard block |
||
1515 | 1515 | } |
1516 | 1516 | |
1517 | 1517 | // This field has failed validation. |
1518 | - if( !empty( $field->failed_validation ) ) { |
|
1518 | + if ( ! empty( $field->failed_validation ) ) { |
|
1519 | 1519 | |
1520 | 1520 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1521 | 1521 | |
@@ -1533,19 +1533,19 @@ discard block |
||
1533 | 1533 | } |
1534 | 1534 | |
1535 | 1535 | // You can't continue inside a switch, so we do it after. |
1536 | - if( empty( $field->failed_validation ) ) { |
|
1536 | + if ( empty( $field->failed_validation ) ) { |
|
1537 | 1537 | continue; |
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | // checks if the No Duplicates option is not validating entry against itself, since |
1541 | 1541 | // we're editing a stored entry, it would also assume it's a duplicate. |
1542 | - if( !empty( $field->noDuplicates ) ) { |
|
1542 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1543 | 1543 | |
1544 | 1544 | $entry = $this->get_entry(); |
1545 | 1545 | |
1546 | 1546 | // If the value of the entry is the same as the stored value |
1547 | 1547 | // Then we can assume it's not a duplicate, it's the same. |
1548 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1548 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1549 | 1549 | //if value submitted was not changed, then don't validate |
1550 | 1550 | $field->failed_validation = false; |
1551 | 1551 | |
@@ -1558,7 +1558,7 @@ discard block |
||
1558 | 1558 | } |
1559 | 1559 | |
1560 | 1560 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1561 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1561 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1562 | 1562 | unset( $field->validation_message ); |
1563 | 1563 | $field->validation_message = false; |
1564 | 1564 | continue; |
@@ -1570,12 +1570,12 @@ discard block |
||
1570 | 1570 | |
1571 | 1571 | } |
1572 | 1572 | |
1573 | - $validation_results['is_valid'] = $gv_valid; |
|
1573 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1574 | 1574 | |
1575 | 1575 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1576 | 1576 | |
1577 | 1577 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1578 | - $this->form_after_validation = $validation_results['form']; |
|
1578 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1579 | 1579 | |
1580 | 1580 | return $validation_results; |
1581 | 1581 | } |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | */ |
1589 | 1589 | public function get_entry() { |
1590 | 1590 | |
1591 | - if( empty( $this->entry ) ) { |
|
1591 | + if ( empty( $this->entry ) ) { |
|
1592 | 1592 | // Get the database value of the entry that's being edited |
1593 | 1593 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1594 | 1594 | } |
@@ -1620,10 +1620,10 @@ discard block |
||
1620 | 1620 | } |
1621 | 1621 | |
1622 | 1622 | // If edit tab not yet configured, show all fields |
1623 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1623 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1624 | 1624 | |
1625 | 1625 | // Hide fields depending on admin settings |
1626 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1626 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1627 | 1627 | |
1628 | 1628 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1629 | 1629 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1655,7 +1655,7 @@ discard block |
||
1655 | 1655 | */ |
1656 | 1656 | private function filter_fields( $fields, $configured_fields ) { |
1657 | 1657 | |
1658 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1658 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1659 | 1659 | return $fields; |
1660 | 1660 | } |
1661 | 1661 | |
@@ -1668,18 +1668,18 @@ discard block |
||
1668 | 1668 | |
1669 | 1669 | // Remove the fields that have calculation properties and keep them to be used later |
1670 | 1670 | // @since 1.16.2 |
1671 | - if( $field->has_calculation() ) { |
|
1672 | - $this->fields_with_calculation[] = $field; |
|
1671 | + if ( $field->has_calculation() ) { |
|
1672 | + $this->fields_with_calculation[ ] = $field; |
|
1673 | 1673 | // don't remove the calculation fields on form render. |
1674 | 1674 | } |
1675 | 1675 | |
1676 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1676 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1677 | 1677 | unset( $fields[ $key ] ); |
1678 | 1678 | } |
1679 | 1679 | } |
1680 | 1680 | |
1681 | 1681 | // The Edit tab has not been configured, so we return all fields by default. |
1682 | - if( empty( $configured_fields ) ) { |
|
1682 | + if ( empty( $configured_fields ) ) { |
|
1683 | 1683 | return array_values( $fields ); |
1684 | 1684 | } |
1685 | 1685 | |
@@ -1688,8 +1688,8 @@ discard block |
||
1688 | 1688 | |
1689 | 1689 | /** @var GF_Field $field */ |
1690 | 1690 | foreach ( $fields as $field ) { |
1691 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1692 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1691 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1692 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1693 | 1693 | break; |
1694 | 1694 | } |
1695 | 1695 | |
@@ -1712,14 +1712,14 @@ discard block |
||
1712 | 1712 | |
1713 | 1713 | $return_field = $field; |
1714 | 1714 | |
1715 | - if( empty( $field_setting['show_label'] ) ) { |
|
1715 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1716 | 1716 | $return_field->label = ''; |
1717 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1718 | - $return_field->label = $field_setting['custom_label']; |
|
1717 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1718 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1719 | 1719 | } |
1720 | 1720 | |
1721 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1722 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1721 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1722 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | /** |
@@ -1757,16 +1757,16 @@ discard block |
||
1757 | 1757 | */ |
1758 | 1758 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1759 | 1759 | |
1760 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1761 | - foreach( $fields as $k => $field ) { |
|
1762 | - if( $field->adminOnly ) { |
|
1760 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1761 | + foreach ( $fields as $k => $field ) { |
|
1762 | + if ( $field->adminOnly ) { |
|
1763 | 1763 | unset( $fields[ $k ] ); |
1764 | 1764 | } |
1765 | 1765 | } |
1766 | 1766 | return array_values( $fields ); |
1767 | 1767 | } |
1768 | 1768 | |
1769 | - foreach( $fields as &$field ) { |
|
1769 | + foreach ( $fields as &$field ) { |
|
1770 | 1770 | $field->adminOnly = false; |
1771 | 1771 | } |
1772 | 1772 | |
@@ -1787,7 +1787,7 @@ discard block |
||
1787 | 1787 | */ |
1788 | 1788 | private function unselect_default_values( $form ) { |
1789 | 1789 | |
1790 | - foreach ( $form['fields'] as &$field ) { |
|
1790 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1791 | 1791 | |
1792 | 1792 | if ( empty( $field->choices ) ) { |
1793 | 1793 | continue; |
@@ -1795,7 +1795,7 @@ discard block |
||
1795 | 1795 | |
1796 | 1796 | foreach ( $field->choices as &$choice ) { |
1797 | 1797 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1798 | - $choice['isSelected'] = false; |
|
1798 | + $choice[ 'isSelected' ] = false; |
|
1799 | 1799 | } |
1800 | 1800 | } |
1801 | 1801 | } |
@@ -1820,22 +1820,22 @@ discard block |
||
1820 | 1820 | */ |
1821 | 1821 | function prefill_conditional_logic( $form ) { |
1822 | 1822 | |
1823 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1823 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1824 | 1824 | return $form; |
1825 | 1825 | } |
1826 | 1826 | |
1827 | 1827 | // Have Conditional Logic pre-fill fields as if the data were default values |
1828 | 1828 | /** @var GF_Field $field */ |
1829 | - foreach ( $form['fields'] as &$field ) { |
|
1829 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1830 | 1830 | |
1831 | - if( 'checkbox' === $field->type ) { |
|
1831 | + if ( 'checkbox' === $field->type ) { |
|
1832 | 1832 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1833 | - $input_id = $input['id']; |
|
1833 | + $input_id = $input[ 'id' ]; |
|
1834 | 1834 | $choice = $field->choices[ $key ]; |
1835 | 1835 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1836 | 1836 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1837 | - if( $match ) { |
|
1838 | - $field->choices[ $key ]['isSelected'] = true; |
|
1837 | + if ( $match ) { |
|
1838 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1839 | 1839 | } |
1840 | 1840 | } |
1841 | 1841 | } else { |
@@ -1843,15 +1843,15 @@ discard block |
||
1843 | 1843 | // We need to run through each field to set the default values |
1844 | 1844 | foreach ( $this->entry as $field_id => $field_value ) { |
1845 | 1845 | |
1846 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1846 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1847 | 1847 | |
1848 | - if( 'list' === $field->type ) { |
|
1848 | + if ( 'list' === $field->type ) { |
|
1849 | 1849 | $list_rows = maybe_unserialize( $field_value ); |
1850 | 1850 | |
1851 | 1851 | $list_field_value = array(); |
1852 | - foreach ( (array) $list_rows as $row ) { |
|
1853 | - foreach ( (array) $row as $column ) { |
|
1854 | - $list_field_value[] = $column; |
|
1852 | + foreach ( (array)$list_rows as $row ) { |
|
1853 | + foreach ( (array)$row as $column ) { |
|
1854 | + $list_field_value[ ] = $column; |
|
1855 | 1855 | } |
1856 | 1856 | } |
1857 | 1857 | |
@@ -1886,16 +1886,16 @@ discard block |
||
1886 | 1886 | */ |
1887 | 1887 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1888 | 1888 | |
1889 | - if( $use_conditional_logic ) { |
|
1889 | + if ( $use_conditional_logic ) { |
|
1890 | 1890 | return $form; |
1891 | 1891 | } |
1892 | 1892 | |
1893 | - foreach( $form['fields'] as &$field ) { |
|
1893 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1894 | 1894 | /* @var GF_Field $field */ |
1895 | 1895 | $field->conditionalLogic = null; |
1896 | 1896 | } |
1897 | 1897 | |
1898 | - unset( $form['button']['conditionalLogic'] ); |
|
1898 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1899 | 1899 | |
1900 | 1900 | return $form; |
1901 | 1901 | |
@@ -1912,7 +1912,7 @@ discard block |
||
1912 | 1912 | */ |
1913 | 1913 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1914 | 1914 | |
1915 | - if( ! $this->is_edit_entry() ) { |
|
1915 | + if ( ! $this->is_edit_entry() ) { |
|
1916 | 1916 | return $has_conditional_logic; |
1917 | 1917 | } |
1918 | 1918 | |
@@ -1944,44 +1944,44 @@ discard block |
||
1944 | 1944 | * 2. There are two entries embedded using oEmbed |
1945 | 1945 | * 3. One of the entries has just been saved |
1946 | 1946 | */ |
1947 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1947 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1948 | 1948 | |
1949 | 1949 | $error = true; |
1950 | 1950 | |
1951 | 1951 | } |
1952 | 1952 | |
1953 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1953 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1954 | 1954 | |
1955 | 1955 | $error = true; |
1956 | 1956 | |
1957 | - } elseif( ! $this->verify_nonce() ) { |
|
1957 | + } elseif ( ! $this->verify_nonce() ) { |
|
1958 | 1958 | |
1959 | 1959 | /** |
1960 | 1960 | * If the Entry is embedded, there may be two entries on the same page. |
1961 | 1961 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1962 | 1962 | */ |
1963 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1963 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1964 | 1964 | $error = true; |
1965 | 1965 | } else { |
1966 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1966 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1967 | 1967 | } |
1968 | 1968 | |
1969 | 1969 | } |
1970 | 1970 | |
1971 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1972 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1971 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1972 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1973 | 1973 | } |
1974 | 1974 | |
1975 | - if( $this->entry['status'] === 'trash' ) { |
|
1976 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1975 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1976 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1977 | 1977 | } |
1978 | 1978 | |
1979 | 1979 | // No errors; everything's fine here! |
1980 | - if( empty( $error ) ) { |
|
1980 | + if ( empty( $error ) ) { |
|
1981 | 1981 | return true; |
1982 | 1982 | } |
1983 | 1983 | |
1984 | - if( $echo && $error !== true ) { |
|
1984 | + if ( $echo && $error !== true ) { |
|
1985 | 1985 | |
1986 | 1986 | $error = esc_html( $error ); |
1987 | 1987 | |
@@ -1989,10 +1989,10 @@ discard block |
||
1989 | 1989 | * @since 1.9 |
1990 | 1990 | */ |
1991 | 1991 | if ( ! empty( $this->entry ) ) { |
1992 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1992 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1993 | 1993 | } |
1994 | 1994 | |
1995 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1995 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1996 | 1996 | } |
1997 | 1997 | |
1998 | 1998 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2012,17 +2012,17 @@ discard block |
||
2012 | 2012 | |
2013 | 2013 | $error = NULL; |
2014 | 2014 | |
2015 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2016 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
2015 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2016 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
2017 | 2017 | } |
2018 | 2018 | |
2019 | 2019 | // No errors; everything's fine here! |
2020 | - if( empty( $error ) ) { |
|
2020 | + if ( empty( $error ) ) { |
|
2021 | 2021 | return true; |
2022 | 2022 | } |
2023 | 2023 | |
2024 | - if( $echo ) { |
|
2025 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
2024 | + if ( $echo ) { |
|
2025 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2026 | 2026 | } |
2027 | 2027 | |
2028 | 2028 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2043,14 +2043,14 @@ discard block |
||
2043 | 2043 | private function check_user_cap_edit_field( $field ) { |
2044 | 2044 | |
2045 | 2045 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
2046 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2046 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2047 | 2047 | return true; |
2048 | 2048 | } |
2049 | 2049 | |
2050 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
2050 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2051 | 2051 | |
2052 | - if( $field_cap ) { |
|
2053 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
2052 | + if ( $field_cap ) { |
|
2053 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2054 | 2054 | } |
2055 | 2055 | |
2056 | 2056 | return false; |
@@ -2064,17 +2064,17 @@ discard block |
||
2064 | 2064 | public function verify_nonce() { |
2065 | 2065 | |
2066 | 2066 | // Verify form submitted for editing single |
2067 | - if( $this->is_edit_entry_submission() ) { |
|
2067 | + if ( $this->is_edit_entry_submission() ) { |
|
2068 | 2068 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2069 | 2069 | } |
2070 | 2070 | |
2071 | 2071 | // Verify |
2072 | - else if( ! $this->is_edit_entry() ) { |
|
2072 | + else if ( ! $this->is_edit_entry() ) { |
|
2073 | 2073 | $valid = false; |
2074 | 2074 | } |
2075 | 2075 | |
2076 | 2076 | else { |
2077 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2077 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2078 | 2078 | } |
2079 | 2079 | |
2080 | 2080 | /** |
@@ -28,11 +28,11 @@ |
||
28 | 28 | |
29 | 29 | $sort_fields_input = '<select name="template_settings[sort_field][]" id="gravityview_sort_field">%s</select>'; |
30 | 30 | |
31 | - if ( is_array( $current_settings['sort_field'] ) ) { |
|
32 | - $primary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'][0] ); |
|
33 | - $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'][1] ); |
|
31 | + if ( is_array( $current_settings[ 'sort_field' ] ) ) { |
|
32 | + $primary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings[ 'sort_field' ][ 0 ] ); |
|
33 | + $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings[ 'sort_field' ][ 1 ] ); |
|
34 | 34 | } else { |
35 | - $primary_sort_fields = $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'] ); |
|
35 | + $primary_sort_fields = $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings[ 'sort_field' ] ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 |