@@ -151,11 +151,11 @@ discard block |
||
151 | 151 | do_action( 'gravityview/template/list/body/before', $context ); |
152 | 152 | |
153 | 153 | /** |
154 | - * @action `gravityview_list_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
155 | - * @deprecated Use `gravityview/template/list/body/before` |
|
156 | - * @since 1.0.7 |
|
157 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
158 | - */ |
|
154 | + * @action `gravityview_list_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
155 | + * @deprecated Use `gravityview/template/list/body/before` |
|
156 | + * @since 1.0.7 |
|
157 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
158 | + */ |
|
159 | 159 | do_action( 'gravityview_list_body_before', \GravityView_View::getInstance() /** ugh! */ ); |
160 | 160 | } |
161 | 161 | |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | do_action( 'gravityview/template/list/body/after', $context ); |
178 | 178 | |
179 | 179 | /** |
180 | - * @action `gravityview_list_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
181 | - * @deprecated Use `gravityview/template/list/body/after` |
|
182 | - * @since 1.0.7 |
|
183 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
184 | - */ |
|
180 | + * @action `gravityview_list_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
181 | + * @deprecated Use `gravityview/template/list/body/after` |
|
182 | + * @since 1.0.7 |
|
183 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
184 | + */ |
|
185 | 185 | do_action( 'gravityview_list_body_after', \GravityView_View::getInstance() /** ugh! */ ); |
186 | 186 | } |
187 | 187 | |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | $zone = str_replace( '/', '_', $zone ); |
213 | 213 | |
214 | 214 | /** |
215 | - * @action `gravityview_list_entry_$zone_before` Inside the `entry`, before any rows are rendered. Can be used to insert additional rows. |
|
216 | - * @deprecated Use `gravityview/template/list/entry/$zone/before` |
|
217 | - * @since 1.0.7 |
|
218 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
219 | - */ |
|
215 | + * @action `gravityview_list_entry_$zone_before` Inside the `entry`, before any rows are rendered. Can be used to insert additional rows. |
|
216 | + * @deprecated Use `gravityview/template/list/entry/$zone/before` |
|
217 | + * @since 1.0.7 |
|
218 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
219 | + */ |
|
220 | 220 | do_action( sprintf( 'gravityview_list_entry%sbefore', $zone ), $entry->as_entry(), \GravityView_View::getInstance() /** ugh! */ ); |
221 | 221 | } |
222 | 222 | |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | $zone = str_replace( '/', '_', $zone ); |
248 | 248 | |
249 | 249 | /** |
250 | - * @action `gravityview_list_entry_$zone_after` Inside the `entry`, after any rows are rendered. Can be used to insert additional rows. |
|
251 | - * @deprecated Use `gravityview/template/list/entry/after` |
|
252 | - * @since 1.0.7 |
|
253 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
254 | - */ |
|
250 | + * @action `gravityview_list_entry_$zone_after` Inside the `entry`, after any rows are rendered. Can be used to insert additional rows. |
|
251 | + * @deprecated Use `gravityview/template/list/entry/after` |
|
252 | + * @since 1.0.7 |
|
253 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
254 | + */ |
|
255 | 255 | do_action( sprintf( 'gravityview_list_entry%safter', $zone ), $entry->as_entry(), \GravityView_View::getInstance() /** ugh! */ ); |
256 | 256 | } |
257 | 257 | } |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | public function the_field( \GV\Field $field, \GV\Entry $entry, $extras = null ) { |
30 | 30 | $form = $this->view->form; |
31 | 31 | |
32 | - if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) { |
|
33 | - if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) { |
|
34 | - $field = $this->view->unions[ $entry['form_id'] ][ $field->ID ]; |
|
32 | + if ( isset( $this->view->unions[ $entry[ 'form_id' ] ] ) ) { |
|
33 | + if ( isset( $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ] ) ) { |
|
34 | + $field = $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ]; |
|
35 | 35 | } elseif ( ! $field instanceof Internal_Field ) { |
36 | 36 | $field = Internal_Field::from_configuration( array( 'id' => 'custom' ) ); |
37 | 37 | } |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | $hide_empty = apply_filters( 'gravityview/render/hide-empty-zone', Utils::get( $extras, 'hide_empty', $this->view->settings->get( 'hide_empty', false ) ), $context ); |
82 | 82 | |
83 | 83 | if ( is_numeric( $field->ID ) ) { |
84 | - $extras['field'] = $field->as_configuration(); |
|
84 | + $extras[ 'field' ] = $field->as_configuration(); |
|
85 | 85 | } |
86 | 86 | |
87 | - $extras['entry'] = $entry->as_entry(); |
|
88 | - $extras['hide_empty'] = $hide_empty; |
|
89 | - $extras['label'] = $label; |
|
90 | - $extras['value'] = $value; |
|
87 | + $extras[ 'entry' ] = $entry->as_entry(); |
|
88 | + $extras[ 'hide_empty' ] = $hide_empty; |
|
89 | + $extras[ 'label' ] = $label; |
|
90 | + $extras[ 'value' ] = $value; |
|
91 | 91 | |
92 | 92 | return \gravityview_field_output( $extras, $context ); |
93 | 93 | } |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | private function maybe_add_hooks() { |
111 | 111 | $class_exists = $this->class_name && class_exists( $this->class_name ); |
112 | 112 | $function_exists = $this->function_name && function_exists( $this->function_name ); |
113 | - $constant_defined = $this->constant_name && defined("{$this->constant_name}"); |
|
113 | + $constant_defined = $this->constant_name && defined( "{$this->constant_name}" ); |
|
114 | 114 | |
115 | - if( $class_exists || $function_exists || $constant_defined ) { |
|
115 | + if ( $class_exists || $function_exists || $constant_defined ) { |
|
116 | 116 | $this->add_hooks(); |
117 | 117 | } |
118 | 118 | } |
@@ -124,23 +124,23 @@ discard block |
||
124 | 124 | */ |
125 | 125 | protected function add_hooks() { |
126 | 126 | |
127 | - if( $this->meta_keys ) { |
|
127 | + if ( $this->meta_keys ) { |
|
128 | 128 | add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_meta_keys' ), 10, 2 ); |
129 | 129 | } |
130 | 130 | |
131 | - if( $this->content_meta_keys ) { |
|
131 | + if ( $this->content_meta_keys ) { |
|
132 | 132 | add_filter( 'gravityview/view_collection/from_post/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 3 ); |
133 | 133 | } |
134 | 134 | |
135 | - if( $this->script_handles ) { |
|
135 | + if ( $this->script_handles ) { |
|
136 | 136 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'merge_noconflict_scripts' ) ); |
137 | 137 | } |
138 | 138 | |
139 | - if( $this->style_handles ) { |
|
139 | + if ( $this->style_handles ) { |
|
140 | 140 | add_filter( 'gravityview_noconflict_styles', array( $this, 'merge_noconflict_styles' ) ); |
141 | 141 | } |
142 | 142 | |
143 | - if( $this->post_type_support ) { |
|
143 | + if ( $this->post_type_support ) { |
|
144 | 144 | add_filter( 'gravityview_post_type_support', array( $this, 'merge_post_type_support' ), 10, 2 ); |
145 | 145 | } |
146 | 146 | } |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function merge_content_meta_keys( $meta_keys = array(), $post = null, & $views = null ) { |
41 | 41 | |
42 | - if( empty( $post->panels_data ) || empty( $post->panels_data['widgets'] ) ) { |
|
42 | + if ( empty( $post->panels_data ) || empty( $post->panels_data[ 'widgets' ] ) ) { |
|
43 | 43 | return $meta_keys; |
44 | 44 | } |
45 | 45 | |
46 | - foreach ( (array) $post->panels_data['widgets'] as $widget ) { |
|
46 | + foreach ( (array)$post->panels_data[ 'widgets' ] as $widget ) { |
|
47 | 47 | |
48 | 48 | $views->merge( \GV\View_Collection::from_content( \GV\Utils::get( $widget, 'text' ) ) ); |
49 | 49 | |
50 | - if ( empty( $widget['tabs'] ) || ! is_array( $widget['tabs'] ) ) { |
|
50 | + if ( empty( $widget[ 'tabs' ] ) || ! is_array( $widget[ 'tabs' ] ) ) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
54 | - foreach ( $widget['tabs'] as $tab ) { |
|
54 | + foreach ( $widget[ 'tabs' ] as $tab ) { |
|
55 | 55 | |
56 | 56 | // Livemesh Tabs |
57 | 57 | $backup = \GV\Utils::get( $tab, 'tab_content' ); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // SiteOrigin Tabs |
60 | 60 | $content = \GV\Utils::get( $tab, 'content_text', $backup ); |
61 | 61 | |
62 | - if( $content ) { |
|
62 | + if ( $content ) { |
|
63 | 63 | $views->merge( \GV\View_Collection::from_content( $content ) ); |
64 | 64 | } |
65 | 65 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $acf_keys = get_field_objects( $post->ID, array( 'load_value' => false ) ); |
57 | 57 | |
58 | - if( $acf_keys ) { |
|
58 | + if ( $acf_keys ) { |
|
59 | 59 | return array_merge( array_keys( $acf_keys ), $meta_keys ); |
60 | 60 | } |
61 | 61 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @return void |
71 | 71 | */ |
72 | 72 | private function fix_posted_fields() { |
73 | - if( is_admin() && isset( $_POST['action'] ) && isset( $_POST['post_type'] ) ) { |
|
74 | - if( 'editpost' === $_POST['action'] && 'gravityview' === $_POST['post_type'] ) { |
|
75 | - $_POST['fields'] = _gravityview_process_posted_fields(); |
|
73 | + if ( is_admin() && isset( $_POST[ 'action' ] ) && isset( $_POST[ 'post_type' ] ) ) { |
|
74 | + if ( 'editpost' === $_POST[ 'action' ] && 'gravityview' === $_POST[ 'post_type' ] ) { |
|
75 | + $_POST[ 'fields' ] = _gravityview_process_posted_fields(); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | */ |
30 | 30 | public static function from_configuration( $configuration ) { |
31 | 31 | |
32 | - if ( empty( $configuration['id'] ) || ! is_string( $configuration['id'] ) ) { |
|
32 | + if ( empty( $configuration[ 'id' ] ) || ! is_string( $configuration[ 'id' ] ) ) { |
|
33 | 33 | gravityview()->log->error( 'Invalid configuration[id] supplied.' ); |
34 | 34 | return null; |
35 | 35 | } |
36 | 36 | |
37 | - $field = self::by_id( $configuration['id'] ); |
|
37 | + $field = self::by_id( $configuration[ 'id' ] ); |
|
38 | 38 | |
39 | 39 | $field->update_configuration( $configuration ); |
40 | 40 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function remove_columns_from_searchable_fields( $fields ) { |
61 | 61 | |
62 | 62 | foreach ( $fields as $key => $field ) { |
63 | - if ( isset( $field['parent'] ) && $field['parent'] instanceof \GF_Field_List ) { |
|
63 | + if ( isset( $field[ 'parent' ] ) && $field[ 'parent' ] instanceof \GF_Field_List ) { |
|
64 | 64 | unset( $fields[ $key ] ); |
65 | 65 | } |
66 | 66 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // Add the list columns |
87 | 87 | foreach ( $list_fields as $list_field ) { |
88 | 88 | |
89 | - if( empty( $list_field->enableColumns ) ) { |
|
89 | + if ( empty( $list_field->enableColumns ) ) { |
|
90 | 90 | continue; |
91 | 91 | } |
92 | 92 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | // If there are columns, add them under the parent field |
110 | - if( ! empty( $list_columns ) ) { |
|
110 | + if ( ! empty( $list_columns ) ) { |
|
111 | 111 | |
112 | 112 | $index = array_search( $list_field->id, array_keys( $fields ) ) + 1; |
113 | 113 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * Merge the $list_columns into the $fields array at $index |
116 | 116 | * @see https://stackoverflow.com/a/1783125 |
117 | 117 | */ |
118 | - $fields = array_slice( $fields, 0, $index, true) + $list_columns + array_slice( $fields, $index, null, true); |
|
118 | + $fields = array_slice( $fields, 0, $index, true ) + $list_columns + array_slice( $fields, $index, null, true ); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | unset( $list_columns, $index, $input_id ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | $list_rows = maybe_unserialize( $field_value ); |
144 | 144 | |
145 | - if( ! is_array( $list_rows ) ) { |
|
145 | + if ( ! is_array( $list_rows ) ) { |
|
146 | 146 | gravityview()->log->error( '$field_value did not unserialize', array( 'data' => $field_value ) ); |
147 | 147 | return null; |
148 | 148 | } |
@@ -152,18 +152,18 @@ discard block |
||
152 | 152 | // Each list row |
153 | 153 | foreach ( $list_rows as $list_row ) { |
154 | 154 | $current_column = 0; |
155 | - foreach ( (array) $list_row as $column_key => $column_value ) { |
|
155 | + foreach ( (array)$list_row as $column_key => $column_value ) { |
|
156 | 156 | |
157 | 157 | // If the label of the column matches $column_id, or the numeric key value matches, add the value |
158 | - if( (string)$column_key === (string)$column_id || ( is_numeric( $column_id ) && (int)$column_id === $current_column ) ) { |
|
159 | - $column_values[] = $column_value; |
|
158 | + if ( (string)$column_key === (string)$column_id || ( is_numeric( $column_id ) && (int)$column_id === $current_column ) ) { |
|
159 | + $column_values[ ] = $column_value; |
|
160 | 160 | } |
161 | 161 | $current_column++; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | // Return the array of values |
166 | - if( 'raw' === $format ) { |
|
166 | + if ( 'raw' === $format ) { |
|
167 | 167 | return $column_values; |
168 | 168 | } |
169 | 169 | // Return the Gravity Forms Field output |
@@ -186,22 +186,22 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function _filter_field_label( $label, $field, $form, $entry ) { |
188 | 188 | |
189 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
189 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
190 | 190 | |
191 | 191 | // Not a list field |
192 | - if( ! $field_object || 'list' !== $field_object->type ) { |
|
192 | + if ( ! $field_object || 'list' !== $field_object->type ) { |
|
193 | 193 | return $label; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Custom label is defined, so use it |
197 | - if( ! empty( $field['custom_label'] ) ) { |
|
197 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
198 | 198 | return $label; |
199 | 199 | } |
200 | 200 | |
201 | - $column_id = gravityview_get_input_id_from_id( $field['id'] ); |
|
201 | + $column_id = gravityview_get_input_id_from_id( $field[ 'id' ] ); |
|
202 | 202 | |
203 | 203 | // Parent field, not column field |
204 | - if( false === $column_id ) { |
|
204 | + if ( false === $column_id ) { |
|
205 | 205 | return $label; |
206 | 206 | } |
207 | 207 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public static function get_column_label( GF_Field_List $field, $column_id, $backup_label = '' ) { |
223 | 223 | |
224 | 224 | // Doesn't have columns enabled |
225 | - if( ! isset( $field->choices ) || ! $field->enableColumns ) { |
|
225 | + if ( ! isset( $field->choices ) || ! $field->enableColumns ) { |
|
226 | 226 | return $backup_label; |
227 | 227 | } |
228 | 228 |
@@ -603,7 +603,8 @@ discard block |
||
603 | 603 | // Fast-forward 24 hour on the end time |
604 | 604 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
605 | 605 | $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
606 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
606 | + if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { |
|
607 | +// See https://github.com/gravityview/GravityView/issues/1056 |
|
607 | 608 | $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
608 | 609 | } |
609 | 610 | } |
@@ -874,7 +875,7 @@ discard block |
||
874 | 875 | 'ymd_dot' => 'Y.m.d', |
875 | 876 | ); |
876 | 877 | |
877 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
878 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
878 | 879 | $format = $datepicker[ $field->dateFormat ]; |
879 | 880 | } |
880 | 881 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'search_clear' => array( |
56 | 56 | 'type' => 'checkbox', |
57 | 57 | 'label' => __( 'Show Clear button', 'gk-gravityview' ), |
58 | - 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gk-gravityview'), |
|
58 | + 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gk-gravityview' ), |
|
59 | 59 | 'value' => true, |
60 | 60 | ), |
61 | 61 | 'search_fields' => array( |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'type' => 'radio', |
69 | 69 | 'full_width' => true, |
70 | 70 | 'label' => esc_html__( 'Search Mode', 'gk-gravityview' ), |
71 | - 'desc' => __('Should search results match all search fields, or any?', 'gk-gravityview'), |
|
71 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gk-gravityview' ), |
|
72 | 72 | 'value' => 'any', |
73 | 73 | 'class' => 'hide-if-js', |
74 | 74 | 'options' => array( |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // translators: Do not translate [b], [/b], [link], or [/link]; they are placeholders for HTML and links to documentation. |
84 | 84 | 'desc' => strtr( |
85 | 85 | esc_html__( 'For fields with choices: Instead of showing all choices for each field, show only field choices that exist in submitted form entries.', 'gk-gravityview' ) . |
86 | - '<p><strong>⚠️ ' . esc_html__('This setting affects security.', 'gk-gravityview' ) . '</strong> ' . esc_html__( '[link]Learn about the Pre-Filter Choices setting[/link] before enabling it.', 'gk-gravityview') . '</p>', |
|
86 | + '<p><strong>⚠️ ' . esc_html__( 'This setting affects security.', 'gk-gravityview' ) . '</strong> ' . esc_html__( '[link]Learn about the Pre-Filter Choices setting[/link] before enabling it.', 'gk-gravityview' ) . '</p>', |
|
87 | 87 | array( |
88 | 88 | '[b]' => '<strong>', |
89 | 89 | '[/b]' => '</strong>', |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
111 | 111 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
112 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
112 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
113 | 113 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
114 | 114 | |
115 | 115 | // ajax - get the searchable fields |
@@ -145,19 +145,19 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function add_reserved_args( $args ) { |
147 | 147 | |
148 | - $args[] = 'gv_search'; |
|
149 | - $args[] = 'gv_start'; |
|
150 | - $args[] = 'gv_end'; |
|
151 | - $args[] = 'gv_id'; |
|
152 | - $args[] = 'gv_by'; |
|
153 | - $args[] = 'mode'; |
|
148 | + $args[ ] = 'gv_search'; |
|
149 | + $args[ ] = 'gv_start'; |
|
150 | + $args[ ] = 'gv_end'; |
|
151 | + $args[ ] = 'gv_id'; |
|
152 | + $args[ ] = 'gv_by'; |
|
153 | + $args[ ] = 'mode'; |
|
154 | 154 | |
155 | - $get = (array) $_GET; |
|
155 | + $get = (array)$_GET; |
|
156 | 156 | |
157 | 157 | // If the fields being searched as reserved; not to be considered user-passed variables |
158 | 158 | foreach ( $get as $key => $value ) { |
159 | 159 | if ( $key !== $this->convert_request_key_to_filter_key( $key ) ) { |
160 | - $args[] = $key; |
|
160 | + $args[ ] = $key; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
282 | 282 | $script_source = empty( $script_min ) ? '/source' : ''; |
283 | 283 | |
284 | - 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 ); |
|
284 | + 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 ); |
|
285 | 285 | |
286 | 286 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
287 | 287 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
304 | 304 | */ |
305 | 305 | public function register_no_conflict( $allowed ) { |
306 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
306 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
307 | 307 | return $allowed; |
308 | 308 | } |
309 | 309 | |
@@ -315,24 +315,24 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public static function get_searchable_fields() { |
317 | 317 | |
318 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
318 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
319 | 319 | exit( '0' ); |
320 | 320 | } |
321 | 321 | |
322 | 322 | $form = ''; |
323 | 323 | |
324 | 324 | // Fetch the form for the current View |
325 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
325 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
326 | 326 | |
327 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
327 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
328 | 328 | |
329 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
329 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
330 | 330 | |
331 | - $form = (int) $_POST['formid']; |
|
331 | + $form = (int)$_POST[ 'formid' ]; |
|
332 | 332 | |
333 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
333 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
334 | 334 | |
335 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
335 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
336 | 336 | |
337 | 337 | } |
338 | 338 | |
@@ -382,14 +382,14 @@ discard block |
||
382 | 382 | ); |
383 | 383 | |
384 | 384 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
385 | - $custom_fields['is_approved'] = array( |
|
385 | + $custom_fields[ 'is_approved' ] = array( |
|
386 | 386 | 'text' => esc_html__( 'Approval Status', 'gk-gravityview' ), |
387 | 387 | 'type' => 'multi', |
388 | 388 | ); |
389 | 389 | } |
390 | 390 | |
391 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
392 | - $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'] ); |
|
391 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
392 | + $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' ] ); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | // Get fields with sub-inputs and no parent |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | |
412 | 412 | foreach ( $fields as $id => $field ) { |
413 | 413 | |
414 | - if ( in_array( $field['type'], $blocklist_field_types ) ) { |
|
414 | + if ( in_array( $field[ 'type' ], $blocklist_field_types ) ) { |
|
415 | 415 | continue; |
416 | 416 | } |
417 | 417 | |
418 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
418 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
419 | 419 | |
420 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
420 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
441 | 441 | |
442 | 442 | // @todo - This needs to be improved - many fields have . including products and addresses |
443 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
443 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
444 | 444 | $input_type = 'boolean'; // on/off checkbox |
445 | 445 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
446 | 446 | $input_type = 'multi'; //multiselect |
@@ -486,19 +486,19 @@ discard block |
||
486 | 486 | $post_id = 0; |
487 | 487 | |
488 | 488 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
489 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
490 | - $post_id = absint( $widget_args['post_id'] ); |
|
489 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
490 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
491 | 491 | } |
492 | 492 | // We're in the WordPress Widget context, and the base View ID should be used |
493 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
494 | - $post_id = absint( $widget_args['view_id'] ); |
|
493 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
494 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | $args = gravityview_get_permalink_query_args( $post_id ); |
498 | 498 | |
499 | 499 | // Add hidden fields to the search form |
500 | 500 | foreach ( $args as $key => $value ) { |
501 | - $search_fields[] = array( |
|
501 | + $search_fields[ ] = array( |
|
502 | 502 | 'name' => $key, |
503 | 503 | 'input' => 'hidden', |
504 | 504 | 'value' => $value, |
@@ -537,28 +537,28 @@ discard block |
||
537 | 537 | /** |
538 | 538 | * Include the sidebar Widgets. |
539 | 539 | */ |
540 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
540 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
541 | 541 | |
542 | 542 | foreach ( $widgets as $widget ) { |
543 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
544 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
543 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
544 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
545 | 545 | foreach ( $_fields as $field ) { |
546 | - if ( empty( $field['form_id'] ) ) { |
|
547 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
546 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
547 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
548 | 548 | } |
549 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
549 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
554 | 554 | |
555 | 555 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
556 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
556 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
557 | 557 | foreach ( $_fields as $field ) { |
558 | - if ( empty( $field['form_id'] ) ) { |
|
559 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
558 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
559 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
560 | 560 | } |
561 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
561 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | } |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
605 | 605 | } |
606 | 606 | |
607 | - if( 'post' === $this->search_method ) { |
|
607 | + if ( 'post' === $this->search_method ) { |
|
608 | 608 | $get = $_POST; |
609 | 609 | } else { |
610 | 610 | $get = $_GET; |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | // Make sure array key is set up |
630 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
630 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
631 | 631 | |
632 | 632 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
633 | 633 | $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); |
@@ -647,9 +647,9 @@ discard block |
||
647 | 647 | $trim_search_value = apply_filters( 'gravityview/search-trim-input', true ); |
648 | 648 | |
649 | 649 | // add free search |
650 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
650 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
651 | 651 | |
652 | - $search_all_value = $trim_search_value ? trim( $get['gv_search'] ) : $get['gv_search']; |
|
652 | + $search_all_value = $trim_search_value ? trim( $get[ 'gv_search' ] ) : $get[ 'gv_search' ]; |
|
653 | 653 | |
654 | 654 | if ( $split_words ) { |
655 | 655 | // Search for a piece |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | } |
666 | 666 | |
667 | 667 | foreach ( $words as $word ) { |
668 | - $search_criteria['field_filters'][] = array( |
|
668 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
669 | 669 | 'key' => null, // The field ID to search |
670 | 670 | 'value' => $word, // The value to search |
671 | 671 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | /** |
679 | 679 | * Get and normalize the dates according to the input format. |
680 | 680 | */ |
681 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
682 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
681 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
682 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
683 | 683 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
684 | 684 | } |
685 | 685 | } |
686 | 686 | |
687 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
688 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
687 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
688 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
689 | 689 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
690 | 690 | } |
691 | 691 | } |
@@ -721,22 +721,22 @@ discard block |
||
721 | 721 | */ |
722 | 722 | if ( ! empty( $curr_start ) ) { |
723 | 723 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
724 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
724 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | if ( ! empty( $curr_end ) ) { |
728 | 728 | // Fast-forward 24 hour on the end time |
729 | 729 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
730 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
731 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
732 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
730 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
731 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
732 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | } |
736 | 736 | |
737 | 737 | // search for a specific entry ID |
738 | 738 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
739 | - $search_criteria['field_filters'][] = array( |
|
739 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
740 | 740 | 'key' => 'id', |
741 | 741 | 'value' => absint( $get[ 'gv_id' ] ), |
742 | 742 | 'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ), |
@@ -745,15 +745,15 @@ discard block |
||
745 | 745 | |
746 | 746 | // search for a specific Created_by ID |
747 | 747 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
748 | - $search_criteria['field_filters'][] = array( |
|
748 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
749 | 749 | 'key' => 'created_by', |
750 | - 'value' => $get['gv_by'], |
|
750 | + 'value' => $get[ 'gv_by' ], |
|
751 | 751 | 'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ), |
752 | 752 | ); |
753 | 753 | } |
754 | 754 | |
755 | 755 | // Get search mode passed in URL |
756 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
756 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
757 | 757 | |
758 | 758 | // get the other search filters |
759 | 759 | foreach ( $get as $key => $value ) { |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | $value = is_array( $value ) ? array_map( 'trim', $value ) : trim( $value ); |
772 | 772 | } |
773 | 773 | |
774 | - if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
774 | + if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
775 | 775 | /** |
776 | 776 | * @filter `gravityview/search/ignore-empty-values` Filter to control if empty field values should be ignored or strictly matched (default: true) |
777 | 777 | * @since 2.14.2.1 |
@@ -802,21 +802,21 @@ discard block |
||
802 | 802 | continue; |
803 | 803 | } |
804 | 804 | |
805 | - if ( ! isset( $filter['operator'] ) ) { |
|
806 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
805 | + if ( ! isset( $filter[ 'operator' ] ) ) { |
|
806 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
807 | 807 | } |
808 | 808 | |
809 | - if ( isset( $filter[0]['value'] ) ) { |
|
810 | - $filter[0]['value'] = $trim_search_value ? trim( $filter[0]['value'] ) : $filter[0]['value']; |
|
809 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
810 | + $filter[ 0 ][ 'value' ] = $trim_search_value ? trim( $filter[ 0 ][ 'value' ] ) : $filter[ 0 ][ 'value' ]; |
|
811 | 811 | |
812 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
812 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
813 | 813 | |
814 | 814 | // if date range type, set search mode to ALL |
815 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
815 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
816 | 816 | $mode = 'all'; |
817 | 817 | } |
818 | - } elseif( !empty( $filter ) ) { |
|
819 | - $search_criteria['field_filters'][] = $filter; |
|
818 | + } elseif ( ! empty( $filter ) ) { |
|
819 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
820 | 820 | } |
821 | 821 | } |
822 | 822 | |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | * @since 1.5.1 |
826 | 826 | * @param string $mode Search mode (`any` vs `all`) |
827 | 827 | */ |
828 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
828 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
829 | 829 | |
830 | 830 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
831 | 831 | |
@@ -859,19 +859,19 @@ discard block |
||
859 | 859 | |
860 | 860 | $query_class = $view->get_query_class(); |
861 | 861 | |
862 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
862 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
863 | 863 | return; |
864 | 864 | } |
865 | 865 | |
866 | 866 | $widgets = $view->widgets->by_id( $this->widget_id ); |
867 | 867 | if ( $widgets->count() ) { |
868 | 868 | $widgets = $widgets->all(); |
869 | - $widget = $widgets[0]; |
|
869 | + $widget = $widgets[ 0 ]; |
|
870 | 870 | |
871 | 871 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
872 | 872 | |
873 | - foreach ( (array) $search_fields as $search_field ) { |
|
874 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
873 | + foreach ( (array)$search_fields as $search_field ) { |
|
874 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
875 | 875 | $created_by_text_mode = true; |
876 | 876 | } |
877 | 877 | } |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | $extra_conditions = array(); |
881 | 881 | $mode = 'any'; |
882 | 882 | |
883 | - foreach ( $search_criteria['field_filters'] as $key => &$filter ) { |
|
883 | + foreach ( $search_criteria[ 'field_filters' ] as $key => &$filter ) { |
|
884 | 884 | if ( ! is_array( $filter ) ) { |
885 | 885 | if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) { |
886 | 886 | $mode = $filter; |
@@ -889,13 +889,13 @@ discard block |
||
889 | 889 | } |
890 | 890 | |
891 | 891 | // Construct a manual query for unapproved statuses |
892 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
893 | - $_tmp_query = new $query_class( $view->form->ID, array( |
|
892 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
893 | + $_tmp_query = new $query_class( $view->form->ID, array( |
|
894 | 894 | 'field_filters' => array( |
895 | 895 | array( |
896 | 896 | 'operator' => 'in', |
897 | 897 | 'key' => 'is_approved', |
898 | - 'value' => (array) $filter['value'], |
|
898 | + 'value' => (array)$filter[ 'value' ], |
|
899 | 899 | ), |
900 | 900 | array( |
901 | 901 | 'operator' => 'is', |
@@ -907,30 +907,30 @@ discard block |
||
907 | 907 | ) ); |
908 | 908 | $_tmp_query_parts = $_tmp_query->_introspect(); |
909 | 909 | |
910 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
910 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
911 | 911 | |
912 | 912 | $filter = false; |
913 | 913 | continue; |
914 | 914 | } |
915 | 915 | |
916 | 916 | // Construct manual query for text mode creator search |
917 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
918 | - $extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
917 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
918 | + $extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
919 | 919 | $filter = false; |
920 | 920 | continue; |
921 | 921 | } |
922 | 922 | |
923 | 923 | // By default, we want searches to be wildcard for each field. |
924 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
924 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
925 | 925 | |
926 | 926 | // For multichoice, let's have an in (OR) search. |
927 | - if ( is_array( $filter['value'] ) ) { |
|
928 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
927 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
928 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | // Default form with joins functionality |
932 | - if ( empty( $filter['form_id'] ) ) { |
|
933 | - $filter['form_id'] = $view->form ? $view->form->ID : 0; |
|
932 | + if ( empty( $filter[ 'form_id' ] ) ) { |
|
933 | + $filter[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
@@ -940,32 +940,32 @@ discard block |
||
940 | 940 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
941 | 941 | * @param \GV\View $view The View we're operating on. |
942 | 942 | */ |
943 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view ); |
|
943 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view ); |
|
944 | 944 | |
945 | - if ( 'is' !== $filter['operator'] && '' === $filter['value'] ) { |
|
946 | - unset( $search_criteria['field_filters'][ $key ] ); |
|
945 | + if ( 'is' !== $filter[ 'operator' ] && '' === $filter[ 'value' ] ) { |
|
946 | + unset( $search_criteria[ 'field_filters' ][ $key ] ); |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | |
950 | - if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) { |
|
950 | + if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) { |
|
951 | 951 | $date_criteria = array(); |
952 | 952 | |
953 | - if ( isset( $search_criteria['start_date'] ) ) { |
|
954 | - $date_criteria['start_date'] = $search_criteria['start_date']; |
|
953 | + if ( isset( $search_criteria[ 'start_date' ] ) ) { |
|
954 | + $date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ]; |
|
955 | 955 | } |
956 | 956 | |
957 | - if ( isset( $search_criteria['end_date'] ) ) { |
|
958 | - $date_criteria['end_date'] = $search_criteria['end_date']; |
|
957 | + if ( isset( $search_criteria[ 'end_date' ] ) ) { |
|
958 | + $date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ]; |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | $_tmp_query = new $query_class( $view->form->ID, $date_criteria ); |
962 | 962 | $_tmp_query_parts = $_tmp_query->_introspect(); |
963 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
963 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | $search_conditions = array(); |
967 | 967 | |
968 | - if ( $filters = array_filter( $search_criteria['field_filters'] ) ) { |
|
968 | + if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) { |
|
969 | 969 | foreach ( $filters as &$filter ) { |
970 | 970 | if ( ! is_array( $filter ) ) { |
971 | 971 | continue; |
@@ -977,12 +977,12 @@ discard block |
||
977 | 977 | * code by reusing what's inside GF_Query already as they |
978 | 978 | * take care of many small things like forcing numeric, etc. |
979 | 979 | */ |
980 | - $_tmp_query = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
980 | + $_tmp_query = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
981 | 981 | $_tmp_query_parts = $_tmp_query->_introspect(); |
982 | - $search_condition = $_tmp_query_parts['where']; |
|
982 | + $search_condition = $_tmp_query_parts[ 'where' ]; |
|
983 | 983 | |
984 | - if ( empty( $filter['key'] ) && $search_condition->expressions ) { |
|
985 | - $search_conditions[] = $search_condition; |
|
984 | + if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) { |
|
985 | + $search_conditions[ ] = $search_condition; |
|
986 | 986 | } else { |
987 | 987 | $left = $search_condition->left; |
988 | 988 | |
@@ -994,8 +994,8 @@ discard block |
||
994 | 994 | |
995 | 995 | $value = $reflectionProperty->getValue( $left ); |
996 | 996 | |
997 | - if ( ! empty( $value[0] ) && $value[0] instanceof GF_Query_Column ) { |
|
998 | - $left = $value[0]; |
|
997 | + if ( ! empty( $value[ 0 ] ) && $value[ 0 ] instanceof GF_Query_Column ) { |
|
998 | + $left = $value[ 0 ]; |
|
999 | 999 | } else { |
1000 | 1000 | continue; |
1001 | 1001 | } |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | $on = $_join->join_on; |
1012 | 1012 | $join = $_join->join; |
1013 | 1013 | |
1014 | - $search_conditions[] = GF_Query_Condition::_or( |
|
1014 | + $search_conditions[ ] = GF_Query_Condition::_or( |
|
1015 | 1015 | // Join |
1016 | 1016 | new GF_Query_Condition( |
1017 | 1017 | new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ), |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | ); |
1028 | 1028 | } |
1029 | 1029 | } else { |
1030 | - $search_conditions[] = new GF_Query_Condition( |
|
1030 | + $search_conditions[ ] = new GF_Query_Condition( |
|
1031 | 1031 | new GF_Query_Column( $left->field_id, $left->source, $alias ), |
1032 | 1032 | $search_condition->operator, |
1033 | 1033 | $search_condition->right |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | /** |
1050 | 1050 | * Combine the parts as a new WHERE clause. |
1051 | 1051 | */ |
1052 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) ); |
|
1052 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) ); |
|
1053 | 1053 | $query->where( $where ); |
1054 | 1054 | } |
1055 | 1055 | |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | $field_id = str_replace( array( 'filter_', 'input_' ), '', $key ); |
1073 | 1073 | |
1074 | 1074 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
1075 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
1075 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
1076 | 1076 | $field_id = str_replace( '_', '.', $field_id ); |
1077 | 1077 | } |
1078 | 1078 | |
@@ -1129,7 +1129,7 @@ discard block |
||
1129 | 1129 | // form is in searchable fields |
1130 | 1130 | $found = false; |
1131 | 1131 | foreach ( $searchable_fields as $field ) { |
1132 | - if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) { |
|
1132 | + if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) { |
|
1133 | 1133 | $found = true; |
1134 | 1134 | break; |
1135 | 1135 | } |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | |
1170 | 1170 | case 'select': |
1171 | 1171 | case 'radio': |
1172 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1172 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1173 | 1173 | break; |
1174 | 1174 | |
1175 | 1175 | case 'post_category': |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | |
1184 | 1184 | foreach ( $value as $val ) { |
1185 | 1185 | $cat = get_term( $val, 'category' ); |
1186 | - $filter[] = array( |
|
1186 | + $filter[ ] = array( |
|
1187 | 1187 | 'key' => $field_id, |
1188 | 1188 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
1189 | 1189 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | $filter = array(); |
1203 | 1203 | |
1204 | 1204 | foreach ( $value as $val ) { |
1205 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
1205 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | 1208 | break; |
@@ -1211,9 +1211,9 @@ discard block |
||
1211 | 1211 | // convert checkbox on/off into the correct search filter |
1212 | 1212 | if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
1213 | 1213 | foreach ( $form_field->inputs as $k => $input ) { |
1214 | - if ( $input['id'] == $field_id ) { |
|
1215 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
1216 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1214 | + if ( $input[ 'id' ] == $field_id ) { |
|
1215 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
1216 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1217 | 1217 | break; |
1218 | 1218 | } |
1219 | 1219 | } |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | $filter = array(); |
1224 | 1224 | |
1225 | 1225 | foreach ( $value as $val ) { |
1226 | - $filter[] = array( |
|
1226 | + $filter[ ] = array( |
|
1227 | 1227 | 'key' => $field_id, |
1228 | 1228 | 'value' => $val, |
1229 | 1229 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1244,9 +1244,9 @@ discard block |
||
1244 | 1244 | foreach ( $words as $word ) { |
1245 | 1245 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
1246 | 1246 | // Keep the same key for each filter |
1247 | - $filter['value'] = $word; |
|
1247 | + $filter[ 'value' ] = $word; |
|
1248 | 1248 | // Add a search for the value |
1249 | - $filters[] = $filter; |
|
1249 | + $filters[ ] = $filter; |
|
1250 | 1250 | } |
1251 | 1251 | } |
1252 | 1252 | |
@@ -1260,19 +1260,19 @@ discard block |
||
1260 | 1260 | |
1261 | 1261 | foreach ( $searchable_fields as $searchable_field ) { |
1262 | 1262 | |
1263 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
1263 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
1264 | 1264 | continue; |
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | // Only exact-match dropdowns, not text search |
1268 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
1268 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
1269 | 1269 | continue; |
1270 | 1270 | } |
1271 | 1271 | |
1272 | 1272 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
1273 | 1273 | |
1274 | 1274 | if ( 4 === $input_id ) { |
1275 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1275 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1276 | 1276 | }; |
1277 | 1277 | } |
1278 | 1278 | } |
@@ -1300,12 +1300,12 @@ discard block |
||
1300 | 1300 | * @since 1.16.3 |
1301 | 1301 | * Safeguard until GF implements '<=' operator |
1302 | 1302 | */ |
1303 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1303 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1304 | 1304 | $operator = '<'; |
1305 | 1305 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1306 | 1306 | } |
1307 | 1307 | |
1308 | - $filter[] = array( |
|
1308 | + $filter[ ] = array( |
|
1309 | 1309 | 'key' => $field_id, |
1310 | 1310 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1311 | 1311 | 'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ), |
@@ -1313,12 +1313,12 @@ discard block |
||
1313 | 1313 | } |
1314 | 1314 | } else { |
1315 | 1315 | $date = $value; |
1316 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1317 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1316 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1317 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | - if ('payment_date' === $key) { |
|
1321 | - $filter['operator'] = 'contains'; |
|
1320 | + if ( 'payment_date' === $key ) { |
|
1321 | + $filter[ 'operator' ] = 'contains'; |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | break; |
@@ -1347,7 +1347,7 @@ discard block |
||
1347 | 1347 | 'ymd_dot' => 'Y.m.d', |
1348 | 1348 | ); |
1349 | 1349 | |
1350 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1350 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1351 | 1351 | $format = $datepicker[ $field->dateFormat ]; |
1352 | 1352 | } |
1353 | 1353 | |
@@ -1384,7 +1384,7 @@ discard block |
||
1384 | 1384 | public function add_template_path( $file_paths ) { |
1385 | 1385 | |
1386 | 1386 | // Index 100 is the default GravityView template path. |
1387 | - $file_paths[102] = self::$file . 'templates/'; |
|
1387 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1388 | 1388 | |
1389 | 1389 | return $file_paths; |
1390 | 1390 | } |
@@ -1403,7 +1403,7 @@ discard block |
||
1403 | 1403 | $has_date = false; |
1404 | 1404 | |
1405 | 1405 | foreach ( $search_fields as $k => $field ) { |
1406 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1406 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1407 | 1407 | $has_date = true; |
1408 | 1408 | break; |
1409 | 1409 | } |
@@ -1432,7 +1432,7 @@ discard block |
||
1432 | 1432 | $view = \GV\View::by_id( $gravityview_view->view_id ); |
1433 | 1433 | |
1434 | 1434 | // get configured search fields |
1435 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1435 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1436 | 1436 | |
1437 | 1437 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1438 | 1438 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1446,39 +1446,39 @@ discard block |
||
1446 | 1446 | |
1447 | 1447 | $updated_field = $this->get_search_filter_details( $updated_field, $context, $widget_args ); |
1448 | 1448 | |
1449 | - switch ( $field['field'] ) { |
|
1449 | + switch ( $field[ 'field' ] ) { |
|
1450 | 1450 | |
1451 | 1451 | case 'search_all': |
1452 | - $updated_field['key'] = 'search_all'; |
|
1453 | - $updated_field['input'] = 'search_all'; |
|
1454 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1452 | + $updated_field[ 'key' ] = 'search_all'; |
|
1453 | + $updated_field[ 'input' ] = 'search_all'; |
|
1454 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1455 | 1455 | break; |
1456 | 1456 | |
1457 | 1457 | case 'entry_date': |
1458 | - $updated_field['key'] = 'entry_date'; |
|
1459 | - $updated_field['input'] = 'entry_date'; |
|
1460 | - $updated_field['value'] = array( |
|
1458 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1459 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1460 | + $updated_field[ 'value' ] = array( |
|
1461 | 1461 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1462 | 1462 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1463 | 1463 | ); |
1464 | 1464 | break; |
1465 | 1465 | |
1466 | 1466 | case 'entry_id': |
1467 | - $updated_field['key'] = 'entry_id'; |
|
1468 | - $updated_field['input'] = 'entry_id'; |
|
1469 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1467 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1468 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1469 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1470 | 1470 | break; |
1471 | 1471 | |
1472 | 1472 | case 'created_by': |
1473 | - $updated_field['key'] = 'created_by'; |
|
1474 | - $updated_field['name'] = 'gv_by'; |
|
1475 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1473 | + $updated_field[ 'key' ] = 'created_by'; |
|
1474 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1475 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1476 | 1476 | break; |
1477 | 1477 | |
1478 | 1478 | case 'is_approved': |
1479 | - $updated_field['key'] = 'is_approved'; |
|
1480 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1481 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1479 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1480 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1481 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1482 | 1482 | break; |
1483 | 1483 | } |
1484 | 1484 | |
@@ -1499,16 +1499,16 @@ discard block |
||
1499 | 1499 | |
1500 | 1500 | $gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args ); |
1501 | 1501 | |
1502 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1502 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1503 | 1503 | |
1504 | 1504 | /** @since 1.14 */ |
1505 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1505 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1506 | 1506 | |
1507 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1507 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1508 | 1508 | |
1509 | 1509 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1510 | 1510 | |
1511 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1511 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1512 | 1512 | |
1513 | 1513 | if ( $this->has_date_field( $search_fields ) ) { |
1514 | 1514 | // enqueue datepicker stuff only if needed! |
@@ -1530,10 +1530,10 @@ discard block |
||
1530 | 1530 | public static function get_search_class( $custom_class = '' ) { |
1531 | 1531 | $gravityview_view = GravityView_View::getInstance(); |
1532 | 1532 | |
1533 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1533 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1534 | 1534 | |
1535 | - if ( ! empty( $custom_class ) ) { |
|
1536 | - $search_class .= ' '.$custom_class; |
|
1535 | + if ( ! empty( $custom_class ) ) { |
|
1536 | + $search_class .= ' ' . $custom_class; |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | /** |
@@ -1584,9 +1584,9 @@ discard block |
||
1584 | 1584 | |
1585 | 1585 | if ( ! $label ) { |
1586 | 1586 | |
1587 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1587 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1588 | 1588 | |
1589 | - switch( $field['field'] ) { |
|
1589 | + switch ( $field[ 'field' ] ) { |
|
1590 | 1590 | case 'search_all': |
1591 | 1591 | $label = __( 'Search Entries:', 'gk-gravityview' ); |
1592 | 1592 | break; |
@@ -1598,10 +1598,10 @@ discard block |
||
1598 | 1598 | break; |
1599 | 1599 | default: |
1600 | 1600 | // If this is a field input, not a field |
1601 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1601 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1602 | 1602 | |
1603 | 1603 | // Get the label for the field in question, which returns an array |
1604 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1604 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1605 | 1605 | |
1606 | 1606 | // Get the item with the `label` key |
1607 | 1607 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1645,13 +1645,13 @@ discard block |
||
1645 | 1645 | $form = $gravityview_view->getForm(); |
1646 | 1646 | |
1647 | 1647 | // for advanced field ids (eg, first name / last name ) |
1648 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1648 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1649 | 1649 | |
1650 | 1650 | // get searched value from $_GET/$_POST (string or array) |
1651 | 1651 | $value = $this->rgget_or_rgpost( $name ); |
1652 | 1652 | |
1653 | 1653 | // get form field details |
1654 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1654 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1655 | 1655 | |
1656 | 1656 | $form_field_type = \GV\Utils::get( $form_field, 'type' ); |
1657 | 1657 | |
@@ -1665,22 +1665,22 @@ discard block |
||
1665 | 1665 | ); |
1666 | 1666 | |
1667 | 1667 | // collect choices |
1668 | - if ( 'post_category' === $form_field_type && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1669 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1670 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1671 | - $filter['choices'] = $form_field['choices']; |
|
1668 | + if ( 'post_category' === $form_field_type && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1669 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1670 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1671 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1672 | 1672 | } |
1673 | 1673 | |
1674 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1675 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1674 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1675 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1676 | 1676 | } |
1677 | 1677 | |
1678 | - if ( 'created_by' === $field['field'] ) { |
|
1679 | - $filter['choices'] = self::get_created_by_choices( ( isset( $context->view ) ? $context->view : null ) ); |
|
1680 | - $filter['type'] = 'created_by'; |
|
1678 | + if ( 'created_by' === $field[ 'field' ] ) { |
|
1679 | + $filter[ 'choices' ] = self::get_created_by_choices( ( isset( $context->view ) ? $context->view : null ) ); |
|
1680 | + $filter[ 'type' ] = 'created_by'; |
|
1681 | 1681 | } |
1682 | 1682 | |
1683 | - if ( ! empty( $filter['choices'] ) ) { |
|
1683 | + if ( ! empty( $filter[ 'choices' ] ) ) { |
|
1684 | 1684 | |
1685 | 1685 | $sieve_choices = \GV\Utils::get( $widget_args, 'sieve_choices', false ); |
1686 | 1686 | |
@@ -1692,7 +1692,7 @@ discard block |
||
1692 | 1692 | * @param \GV\Context The context. |
1693 | 1693 | */ |
1694 | 1694 | if ( apply_filters( 'gravityview/search/sieve_choices', $sieve_choices, $field, $context, $widget_args ) ) { |
1695 | - $filter['choices'] = $this->sieve_filter_choices( $filter, $context ); |
|
1695 | + $filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context ); |
|
1696 | 1696 | } |
1697 | 1697 | } |
1698 | 1698 | |
@@ -1721,18 +1721,18 @@ discard block |
||
1721 | 1721 | * @return array The filter choices. |
1722 | 1722 | */ |
1723 | 1723 | private function sieve_filter_choices( $filter, $context ) { |
1724 | - if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) { |
|
1724 | + if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) { |
|
1725 | 1725 | return $filter; // @todo Populate plugins might give us empty choices |
1726 | 1726 | } |
1727 | 1727 | |
1728 | 1728 | // Allow only created_by and field-ids to be sieved. |
1729 | - if ( 'created_by' !== $filter['key'] && ! is_numeric( $filter['key'] ) ) { |
|
1729 | + if ( 'created_by' !== $filter[ 'key' ] && ! is_numeric( $filter[ 'key' ] ) ) { |
|
1730 | 1730 | return $filter; |
1731 | 1731 | } |
1732 | 1732 | |
1733 | 1733 | $form_id = $context->view->form->ID; // @todo Support multiple forms (joins) |
1734 | 1734 | |
1735 | - $cache = new GravityView_Cache( $form_id, [ 'sieve', $filter['key'], $context->view->ID ] ); |
|
1735 | + $cache = new GravityView_Cache( $form_id, [ 'sieve', $filter[ 'key' ], $context->view->ID ] ); |
|
1736 | 1736 | |
1737 | 1737 | $filter_choices = $cache->get(); |
1738 | 1738 | |
@@ -1745,13 +1745,13 @@ discard block |
||
1745 | 1745 | $entry_table_name = GFFormsModel::get_entry_table_name(); |
1746 | 1746 | $entry_meta_table_name = GFFormsModel::get_entry_meta_table_name(); |
1747 | 1747 | |
1748 | - $key_like = $wpdb->esc_like( $filter['key'] ) . '.%'; |
|
1748 | + $key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%'; |
|
1749 | 1749 | |
1750 | 1750 | switch ( \GV\Utils::get( $filter, 'type' ) ) { |
1751 | 1751 | case 'post_category': |
1752 | 1752 | $choices = $wpdb->get_col( $wpdb->prepare( |
1753 | 1753 | "SELECT DISTINCT SUBSTRING_INDEX( `meta_value`, ':', 1) FROM $entry_meta_table_name WHERE ( `meta_key` LIKE %s OR `meta_key` = %d) AND `form_id` = %d", |
1754 | - $key_like, $filter['key'], $form_id |
|
1754 | + $key_like, $filter[ 'key' ], $form_id |
|
1755 | 1755 | ) ); |
1756 | 1756 | break; |
1757 | 1757 | case 'created_by': |
@@ -1763,17 +1763,17 @@ discard block |
||
1763 | 1763 | default: |
1764 | 1764 | $choices = $wpdb->get_col( $wpdb->prepare( |
1765 | 1765 | "SELECT DISTINCT `meta_value` FROM $entry_meta_table_name WHERE ( `meta_key` LIKE %s OR `meta_key` = %d) AND `form_id` = %d", |
1766 | - $key_like, $filter['key'], $form_id |
|
1766 | + $key_like, $filter[ 'key' ], $form_id |
|
1767 | 1767 | ) ); |
1768 | 1768 | |
1769 | - if ( ( $field = gravityview_get_field( $form_id, $filter['key'] ) ) && 'json' === $field->storageType ) { |
|
1769 | + if ( ( $field = gravityview_get_field( $form_id, $filter[ 'key' ] ) ) && 'json' === $field->storageType ) { |
|
1770 | 1770 | $choices = array_map( 'json_decode', $choices ); |
1771 | 1771 | $_choices_array = array(); |
1772 | 1772 | foreach ( $choices as $choice ) { |
1773 | 1773 | if ( is_array( $choice ) ) { |
1774 | 1774 | $_choices_array = array_merge( $_choices_array, $choice ); |
1775 | 1775 | } else { |
1776 | - $_choices_array [] = $choice; |
|
1776 | + $_choices_array [ ] = $choice; |
|
1777 | 1777 | } |
1778 | 1778 | } |
1779 | 1779 | $choices = array_unique( $_choices_array ); |
@@ -1783,9 +1783,9 @@ discard block |
||
1783 | 1783 | } |
1784 | 1784 | |
1785 | 1785 | $filter_choices = array(); |
1786 | - foreach ( $filter['choices'] as $choice ) { |
|
1787 | - if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) { |
|
1788 | - $filter_choices[] = $choice; |
|
1786 | + foreach ( $filter[ 'choices' ] as $choice ) { |
|
1787 | + if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) { |
|
1788 | + $filter_choices[ ] = $choice; |
|
1789 | 1789 | } |
1790 | 1790 | } |
1791 | 1791 | |
@@ -1822,7 +1822,7 @@ discard block |
||
1822 | 1822 | * @param \GV\View|null $view The view. |
1823 | 1823 | */ |
1824 | 1824 | $text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view ); |
1825 | - $choices[] = array( |
|
1825 | + $choices[ ] = array( |
|
1826 | 1826 | 'value' => $user->ID, |
1827 | 1827 | 'text' => $text, |
1828 | 1828 | ); |
@@ -1842,9 +1842,9 @@ discard block |
||
1842 | 1842 | |
1843 | 1843 | $choices = array(); |
1844 | 1844 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1845 | - $choices[] = array( |
|
1846 | - 'value' => $status['value'], |
|
1847 | - 'text' => $status['label'], |
|
1845 | + $choices[ ] = array( |
|
1846 | + 'value' => $status[ 'value' ], |
|
1847 | + 'text' => $status[ 'label' ], |
|
1848 | 1848 | ); |
1849 | 1849 | } |
1850 | 1850 | |
@@ -1898,7 +1898,7 @@ discard block |
||
1898 | 1898 | */ |
1899 | 1899 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1900 | 1900 | |
1901 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1901 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1902 | 1902 | |
1903 | 1903 | return $js_dependencies; |
1904 | 1904 | } |
@@ -1942,7 +1942,7 @@ discard block |
||
1942 | 1942 | 'isRTL' => is_rtl(), |
1943 | 1943 | ), $view_data ); |
1944 | 1944 | |
1945 | - $localizations['datepicker'] = $datepicker_settings; |
|
1945 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1946 | 1946 | |
1947 | 1947 | return $localizations; |
1948 | 1948 | |
@@ -1969,7 +1969,7 @@ discard block |
||
1969 | 1969 | * @return void |
1970 | 1970 | */ |
1971 | 1971 | private function maybe_enqueue_flexibility() { |
1972 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1972 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1973 | 1973 | wp_enqueue_script( 'gv-flexibility' ); |
1974 | 1974 | } |
1975 | 1975 | } |
@@ -1991,7 +1991,7 @@ discard block |
||
1991 | 1991 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1992 | 1992 | |
1993 | 1993 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1994 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1994 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1995 | 1995 | |
1996 | 1996 | /** |
1997 | 1997 | * @filter `gravityview_search_datepicker_class` |
@@ -2070,7 +2070,7 @@ discard block |
||
2070 | 2070 | public function add_preview_inputs() { |
2071 | 2071 | global $wp; |
2072 | 2072 | |
2073 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
2073 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
2074 | 2074 | return; |
2075 | 2075 | } |
2076 | 2076 | |
@@ -2128,7 +2128,7 @@ discard block |
||
2128 | 2128 | */ |
2129 | 2129 | class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition { |
2130 | 2130 | public function __construct( $filter, $view ) { |
2131 | - $this->value = $filter['value']; |
|
2131 | + $this->value = $filter[ 'value' ]; |
|
2132 | 2132 | $this->view = $view; |
2133 | 2133 | } |
2134 | 2134 | |
@@ -2160,11 +2160,11 @@ discard block |
||
2160 | 2160 | $conditions = array(); |
2161 | 2161 | |
2162 | 2162 | foreach ( $user_fields as $user_field ) { |
2163 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2163 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2164 | 2164 | } |
2165 | 2165 | |
2166 | 2166 | foreach ( $user_meta_fields as $meta_field ) { |
2167 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2167 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2168 | 2168 | } |
2169 | 2169 | |
2170 | 2170 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | function modify_entry_value_workflow_final_status( $output, $entry, $field_settings, $field ) { |
43 | 43 | |
44 | - if( ! empty( $output ) ) { |
|
44 | + if ( ! empty( $output ) ) { |
|
45 | 45 | $output = gravity_flow()->translate_status_label( $output ); |
46 | 46 | } |
47 | 47 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | foreach ( $search_fields as & $search_field ) { |
66 | 66 | if ( $this->name === \GV\Utils::get( $search_field, 'key' ) ) { |
67 | - $search_field['choices'] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options(); |
|
67 | + $search_field[ 'choices' ] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options(); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 |
@@ -7,15 +7,15 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | 12 | |
13 | 13 | $html_input_type = RGFormsModel::is_html5_enabled() ? 'search' : 'text'; |
14 | 14 | ?> |
15 | 15 | |
16 | 16 | <div class="gv-search-box gv-search-field-text gv-search-field-search_all"> |
17 | 17 | <div class="gv-search"> |
18 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
18 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
19 | 19 | <label for="gv_search_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
20 | 20 | <?php } ?> |
21 | 21 | <p><input type="<?php echo $html_input_type; ?>" name="gv_search" id="gv_search_<?php echo $view_id; ?>" value="<?php echo esc_attr( $value ); ?>" /></p> |