@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public function __construct() { |
27 | 27 | $this->label = esc_html__( 'Other Entries', 'gravityview' ); |
28 | - $this->description = esc_html__('Display other entries created by the entry creator.', 'gravityview'); |
|
28 | + $this->description = esc_html__( 'Display other entries created by the entry creator.', 'gravityview' ); |
|
29 | 29 | parent::__construct(); |
30 | 30 | } |
31 | 31 | |
@@ -35,32 +35,32 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
37 | 37 | |
38 | - if( 'edit' === $context ) { |
|
38 | + if ( 'edit' === $context ) { |
|
39 | 39 | return $field_options; |
40 | 40 | } |
41 | 41 | |
42 | 42 | // No "Link to single entry"; all the items will be links to entries! |
43 | - unset( $field_options['show_as_link'] ); |
|
43 | + unset( $field_options[ 'show_as_link' ] ); |
|
44 | 44 | |
45 | 45 | $new_options = array(); |
46 | 46 | |
47 | - $new_options['link_format'] = array( |
|
47 | + $new_options[ 'link_format' ] = array( |
|
48 | 48 | 'type' => 'text', |
49 | 49 | 'label' => __( 'Entry link text (required)', 'gravityview' ), |
50 | - 'value' => __('Entry #{entry_id}', 'gravityview'), |
|
50 | + 'value' => __( 'Entry #{entry_id}', 'gravityview' ), |
|
51 | 51 | 'merge_tags' => 'force', |
52 | 52 | ); |
53 | 53 | |
54 | - $new_options['after_link'] = array( |
|
54 | + $new_options[ 'after_link' ] = array( |
|
55 | 55 | 'type' => 'textarea', |
56 | 56 | 'label' => __( 'Text or HTML to display after the link (optional)', 'gravityview' ), |
57 | - 'desc' => __('This content will be displayed below each entry link.', 'gravityview'), |
|
57 | + 'desc' => __( 'This content will be displayed below each entry link.', 'gravityview' ), |
|
58 | 58 | 'value' => '', |
59 | 59 | 'merge_tags' => 'force', |
60 | 60 | 'class' => 'widefat code', |
61 | 61 | ); |
62 | 62 | |
63 | - $new_options['page_size'] = array( |
|
63 | + $new_options[ 'page_size' ] = array( |
|
64 | 64 | 'type' => 'number', |
65 | 65 | 'label' => __( 'Entries to Display', 'gravityview' ), |
66 | 66 | 'desc' => __( 'What is the maximum number of entries that should be shown?', 'gravityview' ), |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | 'merge_tags' => false, |
69 | 69 | ); |
70 | 70 | |
71 | - $new_options['no_entries_hide'] = array( |
|
71 | + $new_options[ 'no_entries_hide' ] = array( |
|
72 | 72 | 'type' => 'checkbox', |
73 | 73 | 'label' => __( 'Hide if no entries', 'gravityview' ), |
74 | 74 | 'desc' => __( 'Don\'t display this field if the entry creator has no other entries', 'gravityview' ), |
75 | 75 | 'value' => false, |
76 | 76 | ); |
77 | 77 | |
78 | - $new_options['no_entries_text'] = array( |
|
78 | + $new_options[ 'no_entries_text' ] = array( |
|
79 | 79 | 'type' => 'text', |
80 | 80 | 'label' => __( 'No Entries Text', 'gravityview' ), |
81 | 81 | 'desc' => __( 'The text that is shown if the entry creator has no other entries (and "Hide if no entries" is disabled).', 'gravityview' ), |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | foreach ( $filters as $filter ) { |
108 | 108 | foreach ( $wp_filter[ $filter ] as $priority => $callbacks ) { |
109 | 109 | foreach ( $callbacks as $id => $callback ) { |
110 | - if ( ! is_array( $callback['function'] ) ) { |
|
110 | + if ( ! is_array( $callback[ 'function' ] ) ) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | - if ( $callback['function'][0] instanceof \GV\Widget ) { |
|
114 | - $remove[] = array( $filter, $priority, $id ); |
|
113 | + if ( $callback[ 'function' ][ 0 ] instanceof \GV\Widget ) { |
|
114 | + $remove[ ] = array( $filter, $priority, $id ); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | foreach ( $remove as $r ) { |
121 | 121 | list( $filter, $priority, $id ) = $r; |
122 | - $removed[] = array( $filter, $priority, $id, $wp_filter[ $filter ]->callbacks[ $priority ][ $id ] ); |
|
122 | + $removed[ ] = array( $filter, $priority, $id, $wp_filter[ $filter ]->callbacks[ $priority ][ $id ] ); |
|
123 | 123 | unset( $wp_filter[ $filter ]->callbacks[ $priority ][ $id ] ); |
124 | 124 | } |
125 | 125 | |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | public function filter_entries( $search_criteria, $form_id = null, $args = array(), $force_search_criteria = false ) { |
144 | 144 | $context = $this->context; |
145 | 145 | |
146 | - $created_by = $context->entry['created_by']; |
|
146 | + $created_by = $context->entry[ 'created_by' ]; |
|
147 | 147 | |
148 | 148 | /** Filter entries by approved and created_by. */ |
149 | - $search_criteria['field_filters'][] = array( |
|
149 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
150 | 150 | 'key' => 'created_by', |
151 | 151 | 'value' => $created_by, |
152 | 152 | 'operator' => 'is' |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | $criteria = apply_filters( 'gravityview/field/other_entries/criteria', $search_criteria, $context->view->settings->as_atts(), $context->view->form->ID, $context ); |
167 | 167 | |
168 | 168 | /** Force mode all and filter out our own entry. */ |
169 | - $search_criteria['field_filters']['mode'] = 'all'; |
|
170 | - $search_criteria['field_filters'][] = array( |
|
169 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; |
|
170 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
171 | 171 | 'key' => 'id', |
172 | 172 | 'value' => $context->entry->ID, |
173 | 173 | 'operator' => 'isnot' |
174 | 174 | ); |
175 | 175 | |
176 | - $search_criteria['paging']['page_size'] = $context->field->page_size ? : 10; |
|
176 | + $search_criteria[ 'paging' ][ 'page_size' ] = $context->field->page_size ?: 10; |
|
177 | 177 | |
178 | 178 | return $search_criteria; |
179 | 179 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'type' => 'radio', |
65 | 65 | 'full_width' => true, |
66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
68 | 68 | 'value' => 'any', |
69 | 69 | 'class' => 'hide-if-js', |
70 | 70 | 'options' => array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
88 | 88 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
89 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
89 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
90 | 90 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
91 | 91 | |
92 | 92 | // ajax - get the searchable fields |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
230 | 230 | $script_source = empty( $script_min ) ? '/source' : ''; |
231 | 231 | |
232 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
232 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
233 | 233 | |
234 | 234 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
235 | 235 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
252 | 252 | */ |
253 | 253 | public function register_no_conflict( $allowed ) { |
254 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
254 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
255 | 255 | return $allowed; |
256 | 256 | } |
257 | 257 | |
@@ -264,24 +264,24 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public static function get_searchable_fields() { |
266 | 266 | |
267 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
267 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
268 | 268 | exit( '0' ); |
269 | 269 | } |
270 | 270 | |
271 | 271 | $form = ''; |
272 | 272 | |
273 | 273 | // Fetch the form for the current View |
274 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
274 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
275 | 275 | |
276 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
276 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
277 | 277 | |
278 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
278 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
279 | 279 | |
280 | - $form = (int) $_POST['formid']; |
|
280 | + $form = (int)$_POST[ 'formid' ]; |
|
281 | 281 | |
282 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
282 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
283 | 283 | |
284 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
284 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | ); |
332 | 332 | |
333 | 333 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
334 | - $custom_fields['is_approved'] = array( |
|
334 | + $custom_fields[ 'is_approved' ] = array( |
|
335 | 335 | 'text' => esc_html__( 'Approval Status', 'gravityview' ), |
336 | 336 | 'type' => 'multi', |
337 | 337 | ); |
338 | 338 | } |
339 | 339 | |
340 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
341 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
340 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
341 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | // Get fields with sub-inputs and no parent |
@@ -360,13 +360,13 @@ discard block |
||
360 | 360 | |
361 | 361 | foreach ( $fields as $id => $field ) { |
362 | 362 | |
363 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
363 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
364 | 364 | continue; |
365 | 365 | } |
366 | 366 | |
367 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
367 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
368 | 368 | |
369 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
369 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
390 | 390 | |
391 | 391 | // @todo - This needs to be improved - many fields have . including products and addresses |
392 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
392 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
393 | 393 | $input_type = 'boolean'; // on/off checkbox |
394 | 394 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
395 | 395 | $input_type = 'multi'; //multiselect |
@@ -433,19 +433,19 @@ discard block |
||
433 | 433 | $post_id = 0; |
434 | 434 | |
435 | 435 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
436 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
437 | - $post_id = absint( $widget_args['post_id'] ); |
|
436 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
437 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
438 | 438 | } |
439 | 439 | // We're in the WordPress Widget context, and the base View ID should be used |
440 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
441 | - $post_id = absint( $widget_args['view_id'] ); |
|
440 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
441 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | $args = gravityview_get_permalink_query_args( $post_id ); |
445 | 445 | |
446 | 446 | // Add hidden fields to the search form |
447 | 447 | foreach ( $args as $key => $value ) { |
448 | - $search_fields[] = array( |
|
448 | + $search_fields[ ] = array( |
|
449 | 449 | 'name' => $key, |
450 | 450 | 'input' => 'hidden', |
451 | 451 | 'value' => $value, |
@@ -484,28 +484,28 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * Include the sidebar Widgets. |
486 | 486 | */ |
487 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
487 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
488 | 488 | |
489 | 489 | foreach ( $widgets as $widget ) { |
490 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
491 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
490 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
491 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
492 | 492 | foreach ( $_fields as $field ) { |
493 | - if ( empty( $field['form_id'] ) ) { |
|
494 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
493 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
494 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
495 | 495 | } |
496 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
496 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | 502 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
503 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
503 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
504 | 504 | foreach ( $_fields as $field ) { |
505 | - if ( empty( $field['form_id'] ) ) { |
|
506 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
505 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
506 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
507 | 507 | } |
508 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
508 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
509 | 509 | } |
510 | 510 | } |
511 | 511 | } |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
536 | 536 | } |
537 | 537 | |
538 | - if( 'post' === $this->search_method ) { |
|
538 | + if ( 'post' === $this->search_method ) { |
|
539 | 539 | $get = $_POST; |
540 | 540 | } else { |
541 | 541 | $get = $_GET; |
@@ -554,15 +554,15 @@ discard block |
||
554 | 554 | $get = gv_map_deep( $get, 'rawurldecode' ); |
555 | 555 | |
556 | 556 | // Make sure array key is set up |
557 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
557 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
558 | 558 | |
559 | 559 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
560 | 560 | $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); |
561 | 561 | |
562 | 562 | // add free search |
563 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
563 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
564 | 564 | |
565 | - $search_all_value = trim( $get['gv_search'] ); |
|
565 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
566 | 566 | |
567 | 567 | /** |
568 | 568 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | } |
588 | 588 | |
589 | 589 | foreach ( $words as $word ) { |
590 | - $search_criteria['field_filters'][] = array( |
|
590 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
591 | 591 | 'key' => null, // The field ID to search |
592 | 592 | 'value' => $word, // The value to search |
593 | 593 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -600,14 +600,14 @@ discard block |
||
600 | 600 | /** |
601 | 601 | * Get and normalize the dates according to the input format. |
602 | 602 | */ |
603 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
604 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
603 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
604 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
605 | 605 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
609 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
610 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
609 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
610 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
611 | 611 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
612 | 612 | } |
613 | 613 | } |
@@ -642,22 +642,22 @@ discard block |
||
642 | 642 | */ |
643 | 643 | if ( ! empty( $curr_start ) ) { |
644 | 644 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
645 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
645 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | if ( ! empty( $curr_end ) ) { |
649 | 649 | // Fast-forward 24 hour on the end time |
650 | 650 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
651 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
652 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
653 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
651 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
652 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
653 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
658 | 658 | // search for a specific entry ID |
659 | 659 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
660 | - $search_criteria['field_filters'][] = array( |
|
660 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
661 | 661 | 'key' => 'id', |
662 | 662 | 'value' => absint( $get[ 'gv_id' ] ), |
663 | 663 | 'operator' => '=', |
@@ -666,20 +666,20 @@ discard block |
||
666 | 666 | |
667 | 667 | // search for a specific Created_by ID |
668 | 668 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
669 | - $search_criteria['field_filters'][] = array( |
|
669 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
670 | 670 | 'key' => 'created_by', |
671 | - 'value' => $get['gv_by'], |
|
671 | + 'value' => $get[ 'gv_by' ], |
|
672 | 672 | 'operator' => '=', |
673 | 673 | ); |
674 | 674 | } |
675 | 675 | |
676 | 676 | // Get search mode passed in URL |
677 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
677 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
678 | 678 | |
679 | 679 | // get the other search filters |
680 | 680 | foreach ( $get as $key => $value ) { |
681 | 681 | |
682 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
682 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
683 | 683 | continue; |
684 | 684 | } |
685 | 685 | |
@@ -689,15 +689,15 @@ discard block |
||
689 | 689 | continue; |
690 | 690 | } |
691 | 691 | |
692 | - if ( isset( $filter[0]['value'] ) ) { |
|
693 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
692 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
693 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
694 | 694 | |
695 | 695 | // if date range type, set search mode to ALL |
696 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
696 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
697 | 697 | $mode = 'all'; |
698 | 698 | } |
699 | - } elseif( !empty( $filter ) ) { |
|
700 | - $search_criteria['field_filters'][] = $filter; |
|
699 | + } elseif ( ! empty( $filter ) ) { |
|
700 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | * @since 1.5.1 |
707 | 707 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
708 | 708 | */ |
709 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
709 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
710 | 710 | |
711 | 711 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
712 | 712 | |
@@ -740,19 +740,19 @@ discard block |
||
740 | 740 | |
741 | 741 | $query_class = $view->get_query_class(); |
742 | 742 | |
743 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
743 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
744 | 744 | return; |
745 | 745 | } |
746 | 746 | |
747 | 747 | $widgets = $view->widgets->by_id( $this->widget_id ); |
748 | 748 | if ( $widgets->count() ) { |
749 | 749 | $widgets = $widgets->all(); |
750 | - $widget = $widgets[0]; |
|
750 | + $widget = $widgets[ 0 ]; |
|
751 | 751 | |
752 | 752 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
753 | 753 | |
754 | - foreach ( (array) $search_fields as $search_field ) { |
|
755 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
754 | + foreach ( (array)$search_fields as $search_field ) { |
|
755 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
756 | 756 | $created_by_text_mode = true; |
757 | 757 | } |
758 | 758 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $extra_conditions = array(); |
762 | 762 | $mode = 'any'; |
763 | 763 | |
764 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
764 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
765 | 765 | if ( ! is_array( $filter ) ) { |
766 | 766 | if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) { |
767 | 767 | $mode = $filter; |
@@ -770,13 +770,13 @@ discard block |
||
770 | 770 | } |
771 | 771 | |
772 | 772 | // Construct a manual query for unapproved statuses |
773 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
774 | - $_tmp_query = new $query_class( $view->form->ID, array( |
|
773 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
774 | + $_tmp_query = new $query_class( $view->form->ID, array( |
|
775 | 775 | 'field_filters' => array( |
776 | 776 | array( |
777 | 777 | 'operator' => 'in', |
778 | 778 | 'key' => 'is_approved', |
779 | - 'value' => (array) $filter['value'], |
|
779 | + 'value' => (array)$filter[ 'value' ], |
|
780 | 780 | ), |
781 | 781 | array( |
782 | 782 | 'operator' => 'is', |
@@ -788,30 +788,30 @@ discard block |
||
788 | 788 | ) ); |
789 | 789 | $_tmp_query_parts = $_tmp_query->_introspect(); |
790 | 790 | |
791 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
791 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
792 | 792 | |
793 | 793 | $filter = false; |
794 | 794 | continue; |
795 | 795 | } |
796 | 796 | |
797 | 797 | // Construct manual query for text mode creator search |
798 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
799 | - $extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
798 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
799 | + $extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
800 | 800 | $filter = false; |
801 | 801 | continue; |
802 | 802 | } |
803 | 803 | |
804 | 804 | // By default, we want searches to be wildcard for each field. |
805 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
805 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
806 | 806 | |
807 | 807 | // For multichoice, let's have an in (OR) search. |
808 | - if ( is_array( $filter['value'] ) ) { |
|
809 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
808 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
809 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | // Default form with joins functionality |
813 | - if ( empty( $filter['form_id'] ) ) { |
|
814 | - $filter['form_id'] = $view->form ? $view->form->ID : 0; |
|
813 | + if ( empty( $filter[ 'form_id' ] ) ) { |
|
814 | + $filter[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | /** |
@@ -821,28 +821,28 @@ discard block |
||
821 | 821 | * @since develop |
822 | 822 | * @param \GV\View $view The View we're operating on. |
823 | 823 | */ |
824 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view ); |
|
824 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view ); |
|
825 | 825 | } |
826 | 826 | |
827 | - if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) { |
|
827 | + if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) { |
|
828 | 828 | $date_criteria = array(); |
829 | 829 | |
830 | - if ( isset( $search_criteria['start_date'] ) ) { |
|
831 | - $date_criteria['start_date'] = $search_criteria['start_date']; |
|
830 | + if ( isset( $search_criteria[ 'start_date' ] ) ) { |
|
831 | + $date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ]; |
|
832 | 832 | } |
833 | 833 | |
834 | - if ( isset( $search_criteria['end_date'] ) ) { |
|
835 | - $date_criteria['end_date'] = $search_criteria['end_date']; |
|
834 | + if ( isset( $search_criteria[ 'end_date' ] ) ) { |
|
835 | + $date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ]; |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | $_tmp_query = new $query_class( $view->form->ID, $date_criteria ); |
839 | 839 | $_tmp_query_parts = $_tmp_query->_introspect(); |
840 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
840 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | $search_conditions = array(); |
844 | 844 | |
845 | - if ( $filters = array_filter( $search_criteria['field_filters'] ) ) { |
|
845 | + if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) { |
|
846 | 846 | |
847 | 847 | foreach ( $filters as $filter ) { |
848 | 848 | if ( ! is_array( $filter ) ) { |
@@ -855,22 +855,22 @@ discard block |
||
855 | 855 | * code by reusing what's inside GF_Query already as they |
856 | 856 | * take care of many small things like forcing numeric, etc. |
857 | 857 | */ |
858 | - $_tmp_query = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
858 | + $_tmp_query = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
859 | 859 | $_tmp_query_parts = $_tmp_query->_introspect(); |
860 | - $search_condition = $_tmp_query_parts['where']; |
|
860 | + $search_condition = $_tmp_query_parts[ 'where' ]; |
|
861 | 861 | |
862 | - if ( empty( $filter['key'] ) && $search_condition->expressions ) { |
|
862 | + if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) { |
|
863 | 863 | foreach ( $search_condition->expressions as $condition ) { |
864 | - $search_conditions[] = new GravityView_Widget_Search_All_GF_Query_Condition( $condition, $view ); |
|
864 | + $search_conditions[ ] = new GravityView_Widget_Search_All_GF_Query_Condition( $condition, $view ); |
|
865 | 865 | } |
866 | 866 | } else { |
867 | 867 | $left = $search_condition->left; |
868 | 868 | $alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' ); |
869 | 869 | |
870 | 870 | if ( $view->joins && $left->field_id == GF_Query_Column::META ) { |
871 | - $search_conditions[] = new GravityView_Widget_Search_All_GF_Query_Condition( $search_condition, $view ); |
|
871 | + $search_conditions[ ] = new GravityView_Widget_Search_All_GF_Query_Condition( $search_condition, $view ); |
|
872 | 872 | } else { |
873 | - $search_conditions[] = new GF_Query_Condition( |
|
873 | + $search_conditions[ ] = new GF_Query_Condition( |
|
874 | 874 | new GF_Query_Column( $left->field_id, $left->source, $alias ), |
875 | 875 | $search_condition->operator, |
876 | 876 | $search_condition->right |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | /** |
893 | 893 | * Combine the parts as a new WHERE clause. |
894 | 894 | */ |
895 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) ); |
|
895 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) ); |
|
896 | 896 | $query->where( $where ); |
897 | 897 | } |
898 | 898 | |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | $field_id = str_replace( 'filter_', '', $key ); |
916 | 916 | |
917 | 917 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
918 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
918 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
919 | 919 | $field_id = str_replace( '_', '.', $field_id ); |
920 | 920 | } |
921 | 921 | |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | // form is in searchable fields |
968 | 968 | $found = false; |
969 | 969 | foreach ( $searchable_fields as $field ) { |
970 | - if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) { |
|
970 | + if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) { |
|
971 | 971 | $found = true; |
972 | 972 | break; |
973 | 973 | } |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | |
1004 | 1004 | case 'select': |
1005 | 1005 | case 'radio': |
1006 | - $filter['operator'] = 'is'; |
|
1006 | + $filter[ 'operator' ] = 'is'; |
|
1007 | 1007 | break; |
1008 | 1008 | |
1009 | 1009 | case 'post_category': |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | |
1018 | 1018 | foreach ( $value as $val ) { |
1019 | 1019 | $cat = get_term( $val, 'category' ); |
1020 | - $filter[] = array( |
|
1020 | + $filter[ ] = array( |
|
1021 | 1021 | 'key' => $field_id, |
1022 | 1022 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
1023 | 1023 | 'operator' => 'is', |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | $filter = array(); |
1037 | 1037 | |
1038 | 1038 | foreach ( $value as $val ) { |
1039 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
1039 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | break; |
@@ -1045,9 +1045,9 @@ discard block |
||
1045 | 1045 | // convert checkbox on/off into the correct search filter |
1046 | 1046 | if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
1047 | 1047 | foreach ( $form_field->inputs as $k => $input ) { |
1048 | - if ( $input['id'] == $field_id ) { |
|
1049 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
1050 | - $filter['operator'] = 'is'; |
|
1048 | + if ( $input[ 'id' ] == $field_id ) { |
|
1049 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
1050 | + $filter[ 'operator' ] = 'is'; |
|
1051 | 1051 | break; |
1052 | 1052 | } |
1053 | 1053 | } |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | $filter = array(); |
1058 | 1058 | |
1059 | 1059 | foreach ( $value as $val ) { |
1060 | - $filter[] = array( |
|
1060 | + $filter[ ] = array( |
|
1061 | 1061 | 'key' => $field_id, |
1062 | 1062 | 'value' => $val, |
1063 | 1063 | 'operator' => 'is', |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | foreach ( $words as $word ) { |
1079 | 1079 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
1080 | 1080 | // Keep the same key for each filter |
1081 | - $filter['value'] = $word; |
|
1081 | + $filter[ 'value' ] = $word; |
|
1082 | 1082 | // Add a search for the value |
1083 | - $filters[] = $filter; |
|
1083 | + $filters[ ] = $filter; |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1094,19 +1094,19 @@ discard block |
||
1094 | 1094 | |
1095 | 1095 | foreach ( $searchable_fields as $searchable_field ) { |
1096 | 1096 | |
1097 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
1097 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
1098 | 1098 | continue; |
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | // Only exact-match dropdowns, not text search |
1102 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
1102 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
1103 | 1103 | continue; |
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
1107 | 1107 | |
1108 | 1108 | if ( 4 === $input_id ) { |
1109 | - $filter['operator'] = 'is'; |
|
1109 | + $filter[ 'operator' ] = 'is'; |
|
1110 | 1110 | }; |
1111 | 1111 | } |
1112 | 1112 | } |
@@ -1133,12 +1133,12 @@ discard block |
||
1133 | 1133 | * @since 1.16.3 |
1134 | 1134 | * Safeguard until GF implements '<=' operator |
1135 | 1135 | */ |
1136 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1136 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1137 | 1137 | $operator = '<'; |
1138 | 1138 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1139 | 1139 | } |
1140 | 1140 | |
1141 | - $filter[] = array( |
|
1141 | + $filter[ ] = array( |
|
1142 | 1142 | 'key' => $field_id, |
1143 | 1143 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1144 | 1144 | 'operator' => $operator, |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | } |
1147 | 1147 | } else { |
1148 | 1148 | $date = $value; |
1149 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1149 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | break; |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | 'ymd_dot' => 'Y.m.d', |
1178 | 1178 | ); |
1179 | 1179 | |
1180 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1180 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1181 | 1181 | $format = $datepicker[ $field->dateFormat ]; |
1182 | 1182 | } |
1183 | 1183 | |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | public function add_template_path( $file_paths ) { |
1215 | 1215 | |
1216 | 1216 | // Index 100 is the default GravityView template path. |
1217 | - $file_paths[102] = self::$file . 'templates/'; |
|
1217 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1218 | 1218 | |
1219 | 1219 | return $file_paths; |
1220 | 1220 | } |
@@ -1233,7 +1233,7 @@ discard block |
||
1233 | 1233 | $has_date = false; |
1234 | 1234 | |
1235 | 1235 | foreach ( $search_fields as $k => $field ) { |
1236 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1236 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1237 | 1237 | $has_date = true; |
1238 | 1238 | break; |
1239 | 1239 | } |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | // get configured search fields |
1263 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1263 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1264 | 1264 | |
1265 | 1265 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1266 | 1266 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1275,40 +1275,40 @@ discard block |
||
1275 | 1275 | |
1276 | 1276 | $updated_field = $this->get_search_filter_details( $updated_field ); |
1277 | 1277 | |
1278 | - switch ( $field['field'] ) { |
|
1278 | + switch ( $field[ 'field' ] ) { |
|
1279 | 1279 | |
1280 | 1280 | case 'search_all': |
1281 | - $updated_field['key'] = 'search_all'; |
|
1282 | - $updated_field['input'] = 'search_all'; |
|
1283 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1281 | + $updated_field[ 'key' ] = 'search_all'; |
|
1282 | + $updated_field[ 'input' ] = 'search_all'; |
|
1283 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1284 | 1284 | break; |
1285 | 1285 | |
1286 | 1286 | case 'entry_date': |
1287 | - $updated_field['key'] = 'entry_date'; |
|
1288 | - $updated_field['input'] = 'entry_date'; |
|
1289 | - $updated_field['value'] = array( |
|
1287 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1288 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1289 | + $updated_field[ 'value' ] = array( |
|
1290 | 1290 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1291 | 1291 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1292 | 1292 | ); |
1293 | 1293 | break; |
1294 | 1294 | |
1295 | 1295 | case 'entry_id': |
1296 | - $updated_field['key'] = 'entry_id'; |
|
1297 | - $updated_field['input'] = 'entry_id'; |
|
1298 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1296 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1297 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1298 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1299 | 1299 | break; |
1300 | 1300 | |
1301 | 1301 | case 'created_by': |
1302 | - $updated_field['key'] = 'created_by'; |
|
1303 | - $updated_field['name'] = 'gv_by'; |
|
1304 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1305 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
1302 | + $updated_field[ 'key' ] = 'created_by'; |
|
1303 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1304 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1305 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
1306 | 1306 | break; |
1307 | 1307 | |
1308 | 1308 | case 'is_approved': |
1309 | - $updated_field['key'] = 'is_approved'; |
|
1310 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1311 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1309 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1310 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1311 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1312 | 1312 | break; |
1313 | 1313 | } |
1314 | 1314 | |
@@ -1327,16 +1327,16 @@ discard block |
||
1327 | 1327 | */ |
1328 | 1328 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1329 | 1329 | |
1330 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1330 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1331 | 1331 | |
1332 | 1332 | /** @since 1.14 */ |
1333 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1333 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1334 | 1334 | |
1335 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1335 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1336 | 1336 | |
1337 | 1337 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1338 | 1338 | |
1339 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1339 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1340 | 1340 | |
1341 | 1341 | if ( $this->has_date_field( $search_fields ) ) { |
1342 | 1342 | // enqueue datepicker stuff only if needed! |
@@ -1358,10 +1358,10 @@ discard block |
||
1358 | 1358 | public static function get_search_class( $custom_class = '' ) { |
1359 | 1359 | $gravityview_view = GravityView_View::getInstance(); |
1360 | 1360 | |
1361 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1361 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1362 | 1362 | |
1363 | - if ( ! empty( $custom_class ) ) { |
|
1364 | - $search_class .= ' '.$custom_class; |
|
1363 | + if ( ! empty( $custom_class ) ) { |
|
1364 | + $search_class .= ' ' . $custom_class; |
|
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | /** |
@@ -1405,9 +1405,9 @@ discard block |
||
1405 | 1405 | |
1406 | 1406 | if ( ! $label ) { |
1407 | 1407 | |
1408 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1408 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1409 | 1409 | |
1410 | - switch( $field['field'] ) { |
|
1410 | + switch ( $field[ 'field' ] ) { |
|
1411 | 1411 | case 'search_all': |
1412 | 1412 | $label = __( 'Search Entries:', 'gravityview' ); |
1413 | 1413 | break; |
@@ -1419,10 +1419,10 @@ discard block |
||
1419 | 1419 | break; |
1420 | 1420 | default: |
1421 | 1421 | // If this is a field input, not a field |
1422 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1422 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1423 | 1423 | |
1424 | 1424 | // Get the label for the field in question, which returns an array |
1425 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1425 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1426 | 1426 | |
1427 | 1427 | // Get the item with the `label` key |
1428 | 1428 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1461,32 +1461,32 @@ discard block |
||
1461 | 1461 | $form = $gravityview_view->getForm(); |
1462 | 1462 | |
1463 | 1463 | // for advanced field ids (eg, first name / last name ) |
1464 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1464 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1465 | 1465 | |
1466 | 1466 | // get searched value from $_GET/$_POST (string or array) |
1467 | 1467 | $value = $this->rgget_or_rgpost( $name ); |
1468 | 1468 | |
1469 | 1469 | // get form field details |
1470 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1470 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1471 | 1471 | |
1472 | 1472 | $filter = array( |
1473 | - 'key' => $field['field'], |
|
1473 | + 'key' => $field[ 'field' ], |
|
1474 | 1474 | 'name' => $name, |
1475 | 1475 | 'label' => self::get_field_label( $field, $form_field ), |
1476 | - 'input' => $field['input'], |
|
1476 | + 'input' => $field[ 'input' ], |
|
1477 | 1477 | 'value' => $value, |
1478 | - 'type' => $form_field['type'], |
|
1478 | + 'type' => $form_field[ 'type' ], |
|
1479 | 1479 | ); |
1480 | 1480 | |
1481 | 1481 | // collect choices |
1482 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1483 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1484 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1485 | - $filter['choices'] = $form_field['choices']; |
|
1482 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1483 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1484 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1485 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1486 | 1486 | } |
1487 | 1487 | |
1488 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1489 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1488 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1489 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | return $filter; |
@@ -1510,7 +1510,7 @@ discard block |
||
1510 | 1510 | |
1511 | 1511 | $choices = array(); |
1512 | 1512 | foreach ( $users as $user ) { |
1513 | - $choices[] = array( |
|
1513 | + $choices[ ] = array( |
|
1514 | 1514 | 'value' => $user->ID, |
1515 | 1515 | 'text' => $user->display_name, |
1516 | 1516 | ); |
@@ -1530,9 +1530,9 @@ discard block |
||
1530 | 1530 | |
1531 | 1531 | $choices = array(); |
1532 | 1532 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1533 | - $choices[] = array( |
|
1534 | - 'value' => $status['value'], |
|
1535 | - 'text' => $status['label'], |
|
1533 | + $choices[ ] = array( |
|
1534 | + 'value' => $status[ 'value' ], |
|
1535 | + 'text' => $status[ 'label' ], |
|
1536 | 1536 | ); |
1537 | 1537 | } |
1538 | 1538 | |
@@ -1584,7 +1584,7 @@ discard block |
||
1584 | 1584 | */ |
1585 | 1585 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1586 | 1586 | |
1587 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1587 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1588 | 1588 | |
1589 | 1589 | return $js_dependencies; |
1590 | 1590 | } |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | 'isRTL' => is_rtl(), |
1629 | 1629 | ), $view_data ); |
1630 | 1630 | |
1631 | - $localizations['datepicker'] = $datepicker_settings; |
|
1631 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1632 | 1632 | |
1633 | 1633 | return $localizations; |
1634 | 1634 | |
@@ -1655,7 +1655,7 @@ discard block |
||
1655 | 1655 | * @return void |
1656 | 1656 | */ |
1657 | 1657 | private function maybe_enqueue_flexibility() { |
1658 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1658 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1659 | 1659 | wp_enqueue_script( 'gv-flexibility' ); |
1660 | 1660 | } |
1661 | 1661 | } |
@@ -1677,7 +1677,7 @@ discard block |
||
1677 | 1677 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1678 | 1678 | |
1679 | 1679 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1680 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1680 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1681 | 1681 | |
1682 | 1682 | /** |
1683 | 1683 | * @filter `gravityview_search_datepicker_class` |
@@ -1756,7 +1756,7 @@ discard block |
||
1756 | 1756 | public function add_preview_inputs() { |
1757 | 1757 | global $wp; |
1758 | 1758 | |
1759 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
1759 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
1760 | 1760 | return; |
1761 | 1761 | } |
1762 | 1762 | |
@@ -1781,7 +1781,7 @@ discard block |
||
1781 | 1781 | */ |
1782 | 1782 | class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition { |
1783 | 1783 | public function __construct( $filter, $view ) { |
1784 | - $this->value = $filter['value']; |
|
1784 | + $this->value = $filter[ 'value' ]; |
|
1785 | 1785 | $this->view = $view; |
1786 | 1786 | } |
1787 | 1787 | |
@@ -1813,11 +1813,11 @@ discard block |
||
1813 | 1813 | $conditions = array(); |
1814 | 1814 | |
1815 | 1815 | foreach ( $user_fields as $user_field ) { |
1816 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1816 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1817 | 1817 | } |
1818 | 1818 | |
1819 | 1819 | foreach ( $user_meta_fields as $meta_field ) { |
1820 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1820 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |
@@ -1846,9 +1846,9 @@ discard block |
||
1846 | 1846 | |
1847 | 1847 | $conditions = array(); |
1848 | 1848 | |
1849 | - foreach ( $parameters['aliases'] as $key => $alias ) { |
|
1850 | - if ( 'm' == $alias[0] && preg_match( '#\d+_\d+#', $key ) ) { |
|
1851 | - $conditions[] = sprintf( "EXISTS(SELECT * FROM `$table` WHERE `meta_value` %s %s AND `entry_id` = `%s`.`entry_id`)", |
|
1849 | + foreach ( $parameters[ 'aliases' ] as $key => $alias ) { |
|
1850 | + if ( 'm' == $alias[ 0 ] && preg_match( '#\d+_\d+#', $key ) ) { |
|
1851 | + $conditions[ ] = sprintf( "EXISTS(SELECT * FROM `$table` WHERE `meta_value` %s %s AND `entry_id` = `%s`.`entry_id`)", |
|
1852 | 1852 | $this->search_condition->operator, $this->search_condition->right->sql( $query ), $alias ); |
1853 | 1853 | } |
1854 | 1854 | } |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | // If there's an overriding CSS file in the current template folder, use it. |
33 | 33 | $template_css_path = trailingslashit( get_stylesheet_directory() ) . 'gravityview/css/' . $css_file; |
34 | 34 | |
35 | - if( file_exists( $template_css_path ) ) { |
|
35 | + if ( file_exists( $template_css_path ) ) { |
|
36 | 36 | $path = trailingslashit( get_stylesheet_directory_uri() ) . 'gravityview/css/' . $css_file; |
37 | 37 | gravityview()->log->debug( 'Stylesheet override ({css_file})', array( 'css_file' => esc_attr( $css_file ) ) ); |
38 | 38 | } else { |
39 | 39 | // Default: use GravityView CSS file |
40 | 40 | |
41 | 41 | // If no path is provided, assume default plugin templates CSS folder |
42 | - if( '' === $dir_path ) { |
|
42 | + if ( '' === $dir_path ) { |
|
43 | 43 | $dir_path = GRAVITYVIEW_DIR . 'templates/css/'; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // plugins_url() expects a path to a file, not directory. We append a file to be stripped. |
47 | - $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); |
|
47 | + $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return $path; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | |
83 | 83 | $parsed_permalink = parse_url( get_permalink( $id ) ); |
84 | 84 | |
85 | - $permalink_args = isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false; |
|
85 | + $permalink_args = isset( $parsed_permalink[ 'query' ] ) ? $parsed_permalink[ 'query' ] : false; |
|
86 | 86 | |
87 | - if( empty( $permalink_args ) ) { |
|
87 | + if ( empty( $permalink_args ) ) { |
|
88 | 88 | return array(); |
89 | 89 | } |
90 | 90 | |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | function gv_selected( $value, $current, $echo = true, $type = 'selected' ) { |
110 | 110 | |
111 | 111 | $output = ''; |
112 | - if( is_array( $current ) ) { |
|
113 | - if( in_array( $value, $current ) ) { |
|
112 | + if ( is_array( $current ) ) { |
|
113 | + if ( in_array( $value, $current ) ) { |
|
114 | 114 | $output = __checked_selected_helper( true, true, false, $type ); |
115 | 115 | } |
116 | 116 | } else { |
117 | 117 | $output = __checked_selected_helper( $value, $current, false, $type ); |
118 | 118 | } |
119 | 119 | |
120 | - if( $echo ) { |
|
120 | + if ( $echo ) { |
|
121 | 121 | echo $output; |
122 | 122 | } |
123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | |
128 | -if( ! function_exists( 'gravityview_sanitize_html_class' ) ) { |
|
128 | +if ( ! function_exists( 'gravityview_sanitize_html_class' ) ) { |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * sanitize_html_class doesn't handle spaces (multiple classes). We remedy that. |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | function gravityview_strip_whitespace( $string ) { |
173 | 173 | $string = normalize_whitespace( $string ); |
174 | - return preg_replace('/[\r\n\t ]+/', ' ', $string ); |
|
174 | + return preg_replace( '/[\r\n\t ]+/', ' ', $string ); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @return string Included file contents |
186 | 186 | */ |
187 | 187 | function gravityview_ob_include( $file_path, $object = NULL ) { |
188 | - if( ! file_exists( $file_path ) ) { |
|
188 | + if ( ! file_exists( $file_path ) ) { |
|
189 | 189 | gravityview()->log->error( 'File path does not exist. {path}', array( 'path' => $file_path ) ); |
190 | 190 | return ''; |
191 | 191 | } |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | |
210 | 210 | $width = $height * 0.7586206897; |
211 | 211 | |
212 | - if( function_exists('is_rtl') && is_rtl() ) { |
|
213 | - $style = 'margin:10px 10px 10px 0; height='. $height .'px; width: '. $width .'px;'; |
|
212 | + if ( function_exists( 'is_rtl' ) && is_rtl() ) { |
|
213 | + $style = 'margin:10px 10px 10px 0; height=' . $height . 'px; width: ' . $width . 'px;'; |
|
214 | 214 | $css_class = is_string( $css_class ) ? $css_class : 'alignright'; |
215 | 215 | } else { |
216 | - $style = 'margin:10px 10px 10px 0; height='. $height .'px; width: '. $width .'px;'; |
|
216 | + $style = 'margin:10px 10px 10px 0; height=' . $height . 'px; width: ' . $width . 'px;'; |
|
217 | 217 | $css_class = is_string( $css_class ) ? $css_class : 'alignleft'; |
218 | 218 | } |
219 | 219 | |
220 | - return '<img src="'. esc_url( plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) ) .'" class="'. gravityview_sanitize_html_class( $css_class ).'" height="'.intval( $height ).'" width="'.round( $width, 2 ).'" alt="The GravityView Astronaut Says:" style="'.$style.'" />'; |
|
220 | + return '<img src="' . esc_url( plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) ) . '" class="' . gravityview_sanitize_html_class( $css_class ) . '" height="' . intval( $height ) . '" width="' . round( $width, 2 ) . '" alt="The GravityView Astronaut Says:" style="' . $style . '" />'; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | function gravityview_number_format( $number, $decimals = '' ) { |
241 | 241 | global $wp_locale; |
242 | 242 | |
243 | - if( '' === $decimals ) { |
|
243 | + if ( '' === $decimals ) { |
|
244 | 244 | |
245 | - $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.'; |
|
245 | + $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format[ 'decimal_point' ] : '.'; |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Calculate the position of the decimal point in the number |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $parts = parse_url( $value ); |
272 | 272 | |
273 | 273 | // No domain? Strange...show the original text. |
274 | - if( empty( $parts['host'] ) ) { |
|
274 | + if ( empty( $parts[ 'host' ] ) ) { |
|
275 | 275 | return $value; |
276 | 276 | } |
277 | 277 | |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n |
285 | 285 | * If true: `http://example.com => example.com` |
286 | 286 | */ |
287 | - if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) { |
|
287 | + if ( false === apply_filters( 'gravityview_anchor_text_striphttp', true ) ) { |
|
288 | 288 | |
289 | - if( isset( $parts['scheme'] ) ) { |
|
290 | - $return .= $parts['scheme']; |
|
289 | + if ( isset( $parts[ 'scheme' ] ) ) { |
|
290 | + $return .= $parts[ 'scheme' ]; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | 295 | // The domain, which may contain a subdomain |
296 | - $domain = $parts['host']; |
|
296 | + $domain = $parts[ 'host' ]; |
|
297 | 297 | |
298 | 298 | /** |
299 | 299 | * @filter `gravityview_anchor_text_stripwww` Strip www from the domain? |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n |
302 | 302 | * If true: `www.example.com => example.com` |
303 | 303 | */ |
304 | - $strip_www = apply_filters('gravityview_anchor_text_stripwww', true ); |
|
304 | + $strip_www = apply_filters( 'gravityview_anchor_text_stripwww', true ); |
|
305 | 305 | |
306 | - if( $strip_www ) { |
|
307 | - $domain = str_replace('www.', '', $domain ); |
|
306 | + if ( $strip_www ) { |
|
307 | + $domain = str_replace( 'www.', '', $domain ); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | * If true: `http://demo.example.com => example.com` \n |
315 | 315 | * If false: `http://demo.example.com => demo.example.com` |
316 | 316 | */ |
317 | - $strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true); |
|
317 | + $strip_subdomains = apply_filters( 'gravityview_anchor_text_nosubdomain', true ); |
|
318 | 318 | |
319 | - if( $strip_subdomains ) { |
|
319 | + if ( $strip_subdomains ) { |
|
320 | 320 | |
321 | - $domain = _gravityview_strip_subdomain( $parts['host'] ); |
|
321 | + $domain = _gravityview_strip_subdomain( $parts[ 'host' ] ); |
|
322 | 322 | |
323 | 323 | } |
324 | 324 | |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | * If true: `http://example.com/sub/directory/page.html => example.com` \n |
333 | 333 | * If false: `http://example.com/sub/directory/page.html => example.com/sub/directory/page.html` |
334 | 334 | */ |
335 | - $root_only = apply_filters('gravityview_anchor_text_rootonly', true); |
|
335 | + $root_only = apply_filters( 'gravityview_anchor_text_rootonly', true ); |
|
336 | 336 | |
337 | - if( empty( $root_only ) ) { |
|
337 | + if ( empty( $root_only ) ) { |
|
338 | 338 | |
339 | - if( isset( $parts['path'] ) ) { |
|
340 | - $return .= $parts['path']; |
|
339 | + if ( isset( $parts[ 'path' ] ) ) { |
|
340 | + $return .= $parts[ 'path' ]; |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n |
348 | 348 | * If true: `http://example.com/?query=example => example.com` |
349 | 349 | */ |
350 | - $strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true ); |
|
350 | + $strip_query_string = apply_filters( 'gravityview_anchor_text_noquerystring', true ); |
|
351 | 351 | |
352 | - if( empty( $strip_query_string ) ) { |
|
352 | + if ( empty( $strip_query_string ) ) { |
|
353 | 353 | |
354 | - if( isset( $parts['query'] ) ) { |
|
355 | - $return .= '?'.$parts['query']; |
|
354 | + if ( isset( $parts[ 'query' ] ) ) { |
|
355 | + $return .= '?' . $parts[ 'query' ]; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | } |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | */ |
370 | 370 | function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) { |
371 | 371 | |
372 | - if( preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) { |
|
373 | - return $matches['domain']; |
|
372 | + if ( preg_match( "/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) { |
|
373 | + return $matches[ 'domain' ]; |
|
374 | 374 | } else { |
375 | 375 | return $string_maybe_has_subdomain; |
376 | 376 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | |
440 | 440 | if ( in_array( $value, array( 'yes', 'true' ), true ) ) { |
441 | 441 | $value = true; |
442 | - } else if( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
442 | + } else if ( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
443 | 443 | $value = false; |
444 | 444 | } |
445 | 445 | } |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | */ |
469 | 469 | function gv_maybe_json_decode( $value, $assoc = false, $depth = 512, $options = 0 ) { |
470 | 470 | |
471 | - if( ! is_string( $value ) ) { |
|
471 | + if ( ! is_string( $value ) ) { |
|
472 | 472 | return $value; |
473 | 473 | } |
474 | 474 | |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | } |
480 | 480 | |
481 | 481 | // There was a JSON error (PHP 5.3+) |
482 | - if( function_exists('json_last_error') && JSON_ERROR_NONE !== json_last_error() ) { |
|
482 | + if ( function_exists( 'json_last_error' ) && JSON_ERROR_NONE !== json_last_error() ) { |
|
483 | 483 | return $value; |
484 | 484 | } |
485 | 485 | |
486 | 486 | // It wasn't JSON (PHP < 5.3 fallback) |
487 | - if( is_null( $decoded ) ) { |
|
487 | + if ( is_null( $decoded ) ) { |
|
488 | 488 | return $value; |
489 | 489 | } |
490 | 490 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | |
508 | 508 | // Use the original function, if exists. |
509 | 509 | // Requires WP 4.4+ |
510 | - if( function_exists( 'map_deep') ) { |
|
510 | + if ( function_exists( 'map_deep' ) ) { |
|
511 | 511 | return map_deep( $value, $callback ); |
512 | 512 | } |
513 | 513 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | $exploded = explode( '.', "{$field_id}" ); |
574 | 574 | |
575 | - return isset( $exploded[1] ) ? intval( $exploded[1] ) : false; |
|
575 | + return isset( $exploded[ 1 ] ) ? intval( $exploded[ 1 ] ) : false; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -613,13 +613,13 @@ discard block |
||
613 | 613 | */ |
614 | 614 | $args = apply_filters( 'gravityview_get_terms_choices_args', $args ); |
615 | 615 | |
616 | - $terms = get_terms( $args['taxonomy'], $args ); |
|
616 | + $terms = get_terms( $args[ 'taxonomy' ], $args ); |
|
617 | 617 | |
618 | 618 | $choices = array(); |
619 | 619 | |
620 | 620 | if ( is_array( $terms ) ) { |
621 | 621 | foreach ( $terms as $term_id => $term_name ) { |
622 | - $choices[] = array( |
|
622 | + $choices[ ] = array( |
|
623 | 623 | 'text' => $term_name, |
624 | 624 | 'value' => $term_id |
625 | 625 | ); |
@@ -643,21 +643,21 @@ discard block |
||
643 | 643 | function _gravityview_process_posted_fields() { |
644 | 644 | $fields = array(); |
645 | 645 | |
646 | - if( !empty( $_POST['gv_fields'] ) ) { |
|
647 | - if ( ! is_array( $_POST['gv_fields'] ) ) { |
|
646 | + if ( ! empty( $_POST[ 'gv_fields' ] ) ) { |
|
647 | + if ( ! is_array( $_POST[ 'gv_fields' ] ) ) { |
|
648 | 648 | |
649 | 649 | // We are not using parse_str() due to max_input_vars limitation with large View configurations |
650 | 650 | $fields_holder = array(); |
651 | - GVCommon::gv_parse_str( stripslashes( $_POST['gv_fields'] ), $fields_holder ); |
|
651 | + GVCommon::gv_parse_str( stripslashes( $_POST[ 'gv_fields' ] ), $fields_holder ); |
|
652 | 652 | |
653 | - if ( isset( $fields_holder['fields'] ) ) { |
|
654 | - $fields = $fields_holder['fields']; |
|
653 | + if ( isset( $fields_holder[ 'fields' ] ) ) { |
|
654 | + $fields = $fields_holder[ 'fields' ]; |
|
655 | 655 | } else { |
656 | 656 | gravityview()->log->error( 'No `fields` key was found after parsing $fields string', array( 'data' => $fields_holder ) ); |
657 | 657 | } |
658 | 658 | |
659 | 659 | } else { |
660 | - $fields = $_POST['gv_fields']; |
|
660 | + $fields = $_POST[ 'gv_fields' ]; |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 |