@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | function __construct( ) { |
14 | 14 | |
15 | - $name = __('GravityView Recent Entries', 'gravityview'); |
|
15 | + $name = __( 'GravityView Recent Entries', 'gravityview' ); |
|
16 | 16 | |
17 | 17 | $widget_options = array( |
18 | 18 | 'description' => __( 'Display the most recent entries for a View', 'gravityview' ), |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | private function initialize() { |
27 | 27 | |
28 | - add_action('admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') ); |
|
28 | + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
29 | 29 | |
30 | 30 | add_action( 'wp_ajax_gv_get_view_merge_tag_data', array( $this, 'ajax_get_view_merge_tag_data' ) ); |
31 | 31 | |
@@ -38,21 +38,21 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function ajax_get_view_merge_tag_data() { |
40 | 40 | |
41 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajax_widget' ) ) { |
|
41 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajax_widget' ) ) { |
|
42 | 42 | exit( false ); |
43 | 43 | } |
44 | 44 | |
45 | - $form_id = gravityview_get_form_id( $_POST['view_id'] ); |
|
45 | + $form_id = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
46 | 46 | |
47 | 47 | $form = RGFormsModel::get_form_meta( $form_id ); |
48 | 48 | |
49 | 49 | $output = array( |
50 | 50 | 'form' => array( |
51 | - 'id' => $form['id'], |
|
52 | - 'title' => $form['title'], |
|
53 | - 'fields' => $form['fields'], |
|
51 | + 'id' => $form[ 'id' ], |
|
52 | + 'title' => $form[ 'title' ], |
|
53 | + 'fields' => $form[ 'fields' ], |
|
54 | 54 | ), |
55 | - 'mergeTags' => GFCommon::get_merge_tags( $form['fields'], '', false ), |
|
55 | + 'mergeTags' => GFCommon::get_merge_tags( $form[ 'fields' ], '', false ), |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | echo json_encode( $output ); |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | function admin_enqueue_scripts() { |
69 | 69 | global $pagenow; |
70 | 70 | |
71 | - if( $pagenow === 'widgets.php' ) { |
|
71 | + if ( $pagenow === 'widgets.php' ) { |
|
72 | 72 | |
73 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
73 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
74 | 74 | |
75 | - wp_enqueue_script( 'gravityview_widgets', plugins_url('assets/js/admin-widgets'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
75 | + wp_enqueue_script( 'gravityview_widgets', plugins_url( 'assets/js/admin-widgets' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
76 | 76 | |
77 | 77 | wp_localize_script( 'gravityview_widgets', 'GVWidgets', array( |
78 | 78 | 'nonce' => wp_create_nonce( 'gravityview_ajax_widget' ) |
79 | - )); |
|
79 | + ) ); |
|
80 | 80 | |
81 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons' ), GravityView_Plugin::version ); |
|
81 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons' ), GravityView_Plugin::version ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | function widget( $args, $instance ) { |
94 | 94 | |
95 | 95 | // Don't have the Customizer render too soon. |
96 | - if( empty( $instance['view_id'] ) ) { |
|
96 | + if ( empty( $instance[ 'view_id' ] ) ) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | 99 | |
100 | - $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'gv_recent_entries'; |
|
101 | - $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; |
|
100 | + $args[ 'id' ] = ( isset( $args[ 'id' ] ) ) ? $args[ 'id' ] : 'gv_recent_entries'; |
|
101 | + $instance[ 'title' ] = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : ''; |
|
102 | 102 | |
103 | - $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args['id'] ); |
|
103 | + $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args[ 'id' ] ); |
|
104 | 104 | |
105 | - echo $args['before_widget']; |
|
105 | + echo $args[ 'before_widget' ]; |
|
106 | 106 | |
107 | - if ( !empty( $title ) ) { |
|
108 | - echo $args['before_title'] . $title . $args['after_title']; |
|
107 | + if ( ! empty( $title ) ) { |
|
108 | + echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | do_action( 'gravityview/widget/recent-entries/after_widget', $args, $instance ); |
127 | 127 | |
128 | - echo $args['after_widget']; |
|
128 | + echo $args[ 'after_widget' ]; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | private function get_output( $instance ) { |
141 | 141 | |
142 | - $form_id = gravityview_get_form_id( $instance['view_id'] ); |
|
142 | + $form_id = gravityview_get_form_id( $instance[ 'view_id' ] ); |
|
143 | 143 | |
144 | 144 | $form = gravityview_get_form( $form_id ); |
145 | 145 | |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | * @since 1.6.1 |
150 | 150 | * @var int $entry_link_post_id The ID to use as the parent post for the entry |
151 | 151 | */ |
152 | - $entry_link_post_id = ( empty( $instance['error_post_id'] ) && !empty( $instance['post_id'] ) ) ? $instance['post_id'] : $instance['view_id']; |
|
152 | + $entry_link_post_id = ( empty( $instance[ 'error_post_id' ] ) && ! empty( $instance[ 'post_id' ] ) ) ? $instance[ 'post_id' ] : $instance[ 'view_id' ]; |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Generate list output |
156 | 156 | * @since 1.7.2 |
157 | 157 | */ |
158 | - $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget', null, $instance['view_id'] ); |
|
158 | + $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance[ 'link_format' ], $instance[ 'after_link' ], 'recent-entries-widget', null, $instance[ 'view_id' ] ); |
|
159 | 159 | |
160 | 160 | $output = $List->get_output(); |
161 | 161 | |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | */ |
181 | 181 | private function get_entries( $instance, $form_id ) { |
182 | 182 | |
183 | - $view = \GV\View::by_id( $instance['view_id'] ); |
|
183 | + $view = \GV\View::by_id( $instance[ 'view_id' ] ); |
|
184 | 184 | |
185 | - $limit = isset( $instance['limit'] ) ? $instance['limit'] : 10; |
|
185 | + $limit = isset( $instance[ 'limit' ] ) ? $instance[ 'limit' ] : 10; |
|
186 | 186 | |
187 | 187 | $view->settings->set( 'page_size', $limit ); |
188 | 188 | |
@@ -205,23 +205,23 @@ discard block |
||
205 | 205 | $instance = $new_instance; |
206 | 206 | |
207 | 207 | // Force positive number |
208 | - $instance['limit'] = empty( $instance['limit'] ) ? 10 : absint( $instance['limit'] ); |
|
208 | + $instance[ 'limit' ] = empty( $instance[ 'limit' ] ) ? 10 : absint( $instance[ 'limit' ] ); |
|
209 | 209 | |
210 | - $instance['view_id'] = intval( $instance['view_id'] ); |
|
210 | + $instance[ 'view_id' ] = intval( $instance[ 'view_id' ] ); |
|
211 | 211 | |
212 | - $instance['link_format'] = trim( rtrim( $instance['link_format'] ) ); |
|
212 | + $instance[ 'link_format' ] = trim( rtrim( $instance[ 'link_format' ] ) ); |
|
213 | 213 | |
214 | - $instance['link_format'] = empty( $instance['link_format'] ) ? $old_instance['link_format'] : $instance['link_format']; |
|
214 | + $instance[ 'link_format' ] = empty( $instance[ 'link_format' ] ) ? $old_instance[ 'link_format' ] : $instance[ 'link_format' ]; |
|
215 | 215 | |
216 | - $instance['post_id'] = empty( $instance['post_id'] ) ? '' : intval( $instance['post_id'] ); |
|
216 | + $instance[ 'post_id' ] = empty( $instance[ 'post_id' ] ) ? '' : intval( $instance[ 'post_id' ] ); |
|
217 | 217 | |
218 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'], true ); |
|
218 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance[ 'post_id' ], $instance[ 'view_id' ], true ); |
|
219 | 219 | |
220 | 220 | //check if post_id is a valid post with embedded View |
221 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
221 | + $instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
222 | 222 | |
223 | 223 | // Share that the widget isn't brand new |
224 | - $instance['updated'] = 1; |
|
224 | + $instance[ 'updated' ] = 1; |
|
225 | 225 | |
226 | 226 | /** |
227 | 227 | * Modify the updated instance. This will allow for validating any added instance settings externally. |
@@ -243,22 +243,22 @@ discard block |
||
243 | 243 | |
244 | 244 | // Set up some default widget settings. |
245 | 245 | $defaults = array( |
246 | - 'title' => __('Recent Entries', 'gravityview'), |
|
246 | + 'title' => __( 'Recent Entries', 'gravityview' ), |
|
247 | 247 | 'view_id' => NULL, |
248 | 248 | 'post_id' => NULL, |
249 | 249 | 'limit' => 10, |
250 | - 'link_format' => __('Entry #{entry_id}', 'gravityview'), |
|
250 | + 'link_format' => __( 'Entry #{entry_id}', 'gravityview' ), |
|
251 | 251 | 'after_link' => '' |
252 | 252 | ); |
253 | 253 | |
254 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
254 | + $instance = wp_parse_args( (array)$instance, $defaults ); |
|
255 | 255 | |
256 | 256 | ?> |
257 | 257 | |
258 | 258 | <!-- Title --> |
259 | 259 | <p> |
260 | 260 | <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'gravityview' ) ?></label> |
261 | - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
|
261 | + <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'title' ] ); ?>" /> |
|
262 | 262 | </p> |
263 | 263 | |
264 | 264 | <!-- Download --> |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $views = get_posts( $args ); |
272 | 272 | |
273 | 273 | // If there are no views set up yet, we get outta here. |
274 | - if( empty( $views ) ) { |
|
274 | + if ( empty( $views ) ) { |
|
275 | 275 | echo '<div id="select_gravityview_view"><div class="wrap">' . GravityView_Admin::no_views_text() . '</div></div>'; |
276 | 276 | return; |
277 | 277 | } |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | * Display errors generated for invalid embed IDs |
284 | 284 | * @see GravityView_View_Data::is_valid_embed_id |
285 | 285 | */ |
286 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
286 | + if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) { |
|
287 | 287 | ?> |
288 | 288 | <div class="error inline hide-on-view-change"> |
289 | - <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
|
289 | + <p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p> |
|
290 | 290 | </div> |
291 | 291 | <?php |
292 | 292 | unset ( $error ); |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | ?> |
295 | 295 | |
296 | 296 | <p> |
297 | - <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label> |
|
297 | + <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label> |
|
298 | 298 | <select class="widefat gv-recent-entries-select-view" name="<?php echo esc_attr( $this->get_field_name( 'view_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"> |
299 | 299 | <option value=""><?php esc_html_e( '— Select a View as Entries Source —', 'gravityview' ); ?></option> |
300 | 300 | <?php |
301 | 301 | |
302 | - foreach( $views as $view ) { |
|
303 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
304 | - echo '<option value="'. $view->ID .'"'.selected( absint( $instance['view_id'] ), $view->ID ).'>'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
302 | + foreach ( $views as $view ) { |
|
303 | + $title = empty( $view->post_title ) ? __( '(no title)', 'gravityview' ) : $view->post_title; |
|
304 | + echo '<option value="' . $view->ID . '"' . selected( absint( $instance[ 'view_id' ] ), $view->ID ) . '>' . esc_html( sprintf( '%s #%d', $title, $view->ID ) ) . '</option>'; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | ?> |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | * Display errors generated for invalid embed IDs |
314 | 314 | * @see GravityView_View_Data::is_valid_embed_id |
315 | 315 | */ |
316 | - if( !empty( $instance['error_post_id'] ) ) { |
|
316 | + if ( ! empty( $instance[ 'error_post_id' ] ) ) { |
|
317 | 317 | ?> |
318 | 318 | <div class="error inline"> |
319 | - <p><?php echo $instance['error_post_id']; ?></p> |
|
319 | + <p><?php echo $instance[ 'error_post_id' ]; ?></p> |
|
320 | 320 | </div> |
321 | 321 | <?php |
322 | 322 | unset ( $error ); |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | ?> |
325 | 325 | |
326 | 326 | <p> |
327 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
328 | - <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $instance['post_id'] ); ?>" /> |
|
327 | + <label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
328 | + <input class="code" size="3" id="<?php echo $this->get_field_id( 'post_id' ); ?>" name="<?php echo $this->get_field_name( 'post_id' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'post_id' ] ); ?>" /> |
|
329 | 329 | <span class="howto"><?php |
330 | - esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
331 | - echo ' '.gravityview_get_link('https://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
330 | + esc_html_e( 'To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
331 | + echo ' ' . gravityview_get_link( 'https://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
332 | 332 | ?></span> |
333 | 333 | </p> |
334 | 334 | |
@@ -336,21 +336,21 @@ discard block |
||
336 | 336 | <label for="<?php echo $this->get_field_id( 'limit' ); ?>"> |
337 | 337 | <span><?php _e( 'Number of entries to show:', 'gravityview' ); ?></span> |
338 | 338 | </label> |
339 | - <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance['limit'] ); ?>" size="3" /> |
|
339 | + <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance[ 'limit' ] ); ?>" size="3" /> |
|
340 | 340 | </p> |
341 | 341 | |
342 | 342 | <p> |
343 | 343 | <label for="<?php echo $this->get_field_id( 'link_format' ); ?>"> |
344 | 344 | <span><?php _e( 'Entry link text (required)', 'gravityview' ); ?></span> |
345 | 345 | </label> |
346 | - <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance['link_format'] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
346 | + <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'link_format' ] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
347 | 347 | </p> |
348 | 348 | |
349 | 349 | <p> |
350 | 350 | <label for="<?php echo $this->get_field_id( 'after_link' ); ?>"> |
351 | 351 | <span><?php _e( 'Text or HTML to display after the link (optional)', 'gravityview' ); ?></span> |
352 | 352 | </label> |
353 | - <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance['after_link'] ); ?></textarea> |
|
353 | + <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance[ 'after_link' ] ); ?></textarea> |
|
354 | 354 | </p> |
355 | 355 | |
356 | 356 | <?php |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @param GravityView_Recent_Entries_Widget $this WP_Widget object |
361 | 361 | * @param array $instance Current widget instance |
362 | 362 | */ |
363 | - do_action( 'gravityview_recent_entries_widget_form' , $this, $instance ); |
|
363 | + do_action( 'gravityview_recent_entries_widget_form', $this, $instance ); |
|
364 | 364 | |
365 | 365 | ?> |
366 | 366 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'search_clear' => array( |
56 | 56 | 'type' => 'checkbox', |
57 | 57 | 'label' => __( 'Show Clear button', 'gravityview' ), |
58 | - 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gravityview'), |
|
58 | + 'desc' => __( 'When a search is performed, display a button that removes all search values.', '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', 'gravityview' ), |
71 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
71 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
72 | 72 | 'value' => 'any', |
73 | 73 | 'class' => 'hide-if-js', |
74 | 74 | 'options' => array( |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
89 | 89 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
90 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
90 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
91 | 91 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
92 | 92 | |
93 | 93 | // ajax - get the searchable fields |
@@ -123,19 +123,19 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function add_reserved_args( $args ) { |
125 | 125 | |
126 | - $args[] = 'gv_search'; |
|
127 | - $args[] = 'gv_start'; |
|
128 | - $args[] = 'gv_end'; |
|
129 | - $args[] = 'gv_id'; |
|
130 | - $args[] = 'gv_by'; |
|
131 | - $args[] = 'mode'; |
|
126 | + $args[ ] = 'gv_search'; |
|
127 | + $args[ ] = 'gv_start'; |
|
128 | + $args[ ] = 'gv_end'; |
|
129 | + $args[ ] = 'gv_id'; |
|
130 | + $args[ ] = 'gv_by'; |
|
131 | + $args[ ] = 'mode'; |
|
132 | 132 | |
133 | - $get = (array) $_GET; |
|
133 | + $get = (array)$_GET; |
|
134 | 134 | |
135 | 135 | // If the fields being searched as reserved; not to be considered user-passed variables |
136 | 136 | foreach ( $get as $key => $value ) { |
137 | 137 | if ( $key !== $this->convert_request_key_to_filter_key( $key ) ) { |
138 | - $args[] = $key; |
|
138 | + $args[ ] = $key; |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
260 | 260 | $script_source = empty( $script_min ) ? '/source' : ''; |
261 | 261 | |
262 | - 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 ); |
|
262 | + 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 ); |
|
263 | 263 | |
264 | 264 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
265 | 265 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
282 | 282 | */ |
283 | 283 | public function register_no_conflict( $allowed ) { |
284 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
284 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
285 | 285 | return $allowed; |
286 | 286 | } |
287 | 287 | |
@@ -293,24 +293,24 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public static function get_searchable_fields() { |
295 | 295 | |
296 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
296 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
297 | 297 | exit( '0' ); |
298 | 298 | } |
299 | 299 | |
300 | 300 | $form = ''; |
301 | 301 | |
302 | 302 | // Fetch the form for the current View |
303 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
303 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
304 | 304 | |
305 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
305 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
306 | 306 | |
307 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
307 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
308 | 308 | |
309 | - $form = (int) $_POST['formid']; |
|
309 | + $form = (int)$_POST[ 'formid' ]; |
|
310 | 310 | |
311 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
311 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
312 | 312 | |
313 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
313 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | |
@@ -360,14 +360,14 @@ discard block |
||
360 | 360 | ); |
361 | 361 | |
362 | 362 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
363 | - $custom_fields['is_approved'] = array( |
|
363 | + $custom_fields[ 'is_approved' ] = array( |
|
364 | 364 | 'text' => esc_html__( 'Approval Status', 'gravityview' ), |
365 | 365 | 'type' => 'multi', |
366 | 366 | ); |
367 | 367 | } |
368 | 368 | |
369 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
370 | - $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'] ); |
|
369 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
370 | + $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' ] ); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | // Get fields with sub-inputs and no parent |
@@ -389,13 +389,13 @@ discard block |
||
389 | 389 | |
390 | 390 | foreach ( $fields as $id => $field ) { |
391 | 391 | |
392 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
392 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
393 | 393 | continue; |
394 | 394 | } |
395 | 395 | |
396 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
396 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
397 | 397 | |
398 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
398 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
419 | 419 | |
420 | 420 | // @todo - This needs to be improved - many fields have . including products and addresses |
421 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
421 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
422 | 422 | $input_type = 'boolean'; // on/off checkbox |
423 | 423 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
424 | 424 | $input_type = 'multi'; //multiselect |
@@ -464,19 +464,19 @@ discard block |
||
464 | 464 | $post_id = 0; |
465 | 465 | |
466 | 466 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
467 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
468 | - $post_id = absint( $widget_args['post_id'] ); |
|
467 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
468 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
469 | 469 | } |
470 | 470 | // We're in the WordPress Widget context, and the base View ID should be used |
471 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
472 | - $post_id = absint( $widget_args['view_id'] ); |
|
471 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
472 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | $args = gravityview_get_permalink_query_args( $post_id ); |
476 | 476 | |
477 | 477 | // Add hidden fields to the search form |
478 | 478 | foreach ( $args as $key => $value ) { |
479 | - $search_fields[] = array( |
|
479 | + $search_fields[ ] = array( |
|
480 | 480 | 'name' => $key, |
481 | 481 | 'input' => 'hidden', |
482 | 482 | 'value' => $value, |
@@ -515,28 +515,28 @@ discard block |
||
515 | 515 | /** |
516 | 516 | * Include the sidebar Widgets. |
517 | 517 | */ |
518 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
518 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
519 | 519 | |
520 | 520 | foreach ( $widgets as $widget ) { |
521 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
522 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
521 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
522 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
523 | 523 | foreach ( $_fields as $field ) { |
524 | - if ( empty( $field['form_id'] ) ) { |
|
525 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
524 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
525 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
526 | 526 | } |
527 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
527 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | } |
531 | 531 | } |
532 | 532 | |
533 | 533 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
534 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
534 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
535 | 535 | foreach ( $_fields as $field ) { |
536 | - if ( empty( $field['form_id'] ) ) { |
|
537 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
536 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
537 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
538 | 538 | } |
539 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
539 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
575 | 575 | } |
576 | 576 | |
577 | - if( 'post' === $this->search_method ) { |
|
577 | + if ( 'post' === $this->search_method ) { |
|
578 | 578 | $get = $_POST; |
579 | 579 | } else { |
580 | 580 | $get = $_GET; |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | $get = gv_map_deep( $get, 'rawurldecode' ); |
594 | 594 | |
595 | 595 | // Make sure array key is set up |
596 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
596 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
597 | 597 | |
598 | 598 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
599 | 599 | $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); |
@@ -613,9 +613,9 @@ discard block |
||
613 | 613 | $trim_search_value = apply_filters( 'gravityview/search-trim-input', true ); |
614 | 614 | |
615 | 615 | // add free search |
616 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
616 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
617 | 617 | |
618 | - $search_all_value = $trim_search_value ? trim( $get['gv_search'] ) : $get['gv_search']; |
|
618 | + $search_all_value = $trim_search_value ? trim( $get[ 'gv_search' ] ) : $get[ 'gv_search' ]; |
|
619 | 619 | |
620 | 620 | if ( $split_words ) { |
621 | 621 | // Search for a piece |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | } |
632 | 632 | |
633 | 633 | foreach ( $words as $word ) { |
634 | - $search_criteria['field_filters'][] = array( |
|
634 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
635 | 635 | 'key' => null, // The field ID to search |
636 | 636 | 'value' => $word, // The value to search |
637 | 637 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -644,14 +644,14 @@ discard block |
||
644 | 644 | /** |
645 | 645 | * Get and normalize the dates according to the input format. |
646 | 646 | */ |
647 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
648 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
647 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
648 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
649 | 649 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
650 | 650 | } |
651 | 651 | } |
652 | 652 | |
653 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
654 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
653 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
654 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
655 | 655 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
656 | 656 | } |
657 | 657 | } |
@@ -687,22 +687,22 @@ discard block |
||
687 | 687 | */ |
688 | 688 | if ( ! empty( $curr_start ) ) { |
689 | 689 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
690 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
690 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | if ( ! empty( $curr_end ) ) { |
694 | 694 | // Fast-forward 24 hour on the end time |
695 | 695 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
696 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
697 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
698 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
696 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
697 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
698 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
699 | 699 | } |
700 | 700 | } |
701 | 701 | } |
702 | 702 | |
703 | 703 | // search for a specific entry ID |
704 | 704 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
705 | - $search_criteria['field_filters'][] = array( |
|
705 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
706 | 706 | 'key' => 'id', |
707 | 707 | 'value' => absint( $get[ 'gv_id' ] ), |
708 | 708 | 'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ), |
@@ -711,15 +711,15 @@ discard block |
||
711 | 711 | |
712 | 712 | // search for a specific Created_by ID |
713 | 713 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
714 | - $search_criteria['field_filters'][] = array( |
|
714 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
715 | 715 | 'key' => 'created_by', |
716 | - 'value' => $get['gv_by'], |
|
716 | + 'value' => $get[ 'gv_by' ], |
|
717 | 717 | 'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ), |
718 | 718 | ); |
719 | 719 | } |
720 | 720 | |
721 | 721 | // Get search mode passed in URL |
722 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
722 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
723 | 723 | |
724 | 724 | // get the other search filters |
725 | 725 | foreach ( $get as $key => $value ) { |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | $value = is_array( $value ) ? array_map( 'trim', $value ) : trim( $value ); |
732 | 732 | } |
733 | 733 | |
734 | - if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
734 | + if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
735 | 735 | continue; |
736 | 736 | } |
737 | 737 | |
@@ -745,21 +745,21 @@ discard block |
||
745 | 745 | continue; |
746 | 746 | } |
747 | 747 | |
748 | - if ( ! isset( $filter['operator'] ) ) { |
|
749 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
748 | + if ( ! isset( $filter[ 'operator' ] ) ) { |
|
749 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
750 | 750 | } |
751 | 751 | |
752 | - if ( isset( $filter[0]['value'] ) ) { |
|
753 | - $filter[0]['value'] = $trim_search_value ? trim( $filter[0]['value'] ) : $filter[0]['value']; |
|
752 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
753 | + $filter[ 0 ][ 'value' ] = $trim_search_value ? trim( $filter[ 0 ][ 'value' ] ) : $filter[ 0 ][ 'value' ]; |
|
754 | 754 | |
755 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
755 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
756 | 756 | |
757 | 757 | // if date range type, set search mode to ALL |
758 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
758 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
759 | 759 | $mode = 'all'; |
760 | 760 | } |
761 | - } elseif( !empty( $filter ) ) { |
|
762 | - $search_criteria['field_filters'][] = $filter; |
|
761 | + } elseif ( ! empty( $filter ) ) { |
|
762 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
763 | 763 | } |
764 | 764 | } |
765 | 765 | |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | * @since 1.5.1 |
769 | 769 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
770 | 770 | */ |
771 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
771 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
772 | 772 | |
773 | 773 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
774 | 774 | |
@@ -802,19 +802,19 @@ discard block |
||
802 | 802 | |
803 | 803 | $query_class = $view->get_query_class(); |
804 | 804 | |
805 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
805 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
806 | 806 | return; |
807 | 807 | } |
808 | 808 | |
809 | 809 | $widgets = $view->widgets->by_id( $this->widget_id ); |
810 | 810 | if ( $widgets->count() ) { |
811 | 811 | $widgets = $widgets->all(); |
812 | - $widget = $widgets[0]; |
|
812 | + $widget = $widgets[ 0 ]; |
|
813 | 813 | |
814 | 814 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
815 | 815 | |
816 | - foreach ( (array) $search_fields as $search_field ) { |
|
817 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
816 | + foreach ( (array)$search_fields as $search_field ) { |
|
817 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
818 | 818 | $created_by_text_mode = true; |
819 | 819 | } |
820 | 820 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | $extra_conditions = array(); |
824 | 824 | $mode = 'any'; |
825 | 825 | |
826 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
826 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
827 | 827 | if ( ! is_array( $filter ) ) { |
828 | 828 | if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) { |
829 | 829 | $mode = $filter; |
@@ -832,13 +832,13 @@ discard block |
||
832 | 832 | } |
833 | 833 | |
834 | 834 | // Construct a manual query for unapproved statuses |
835 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
836 | - $_tmp_query = new $query_class( $view->form->ID, array( |
|
835 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
836 | + $_tmp_query = new $query_class( $view->form->ID, array( |
|
837 | 837 | 'field_filters' => array( |
838 | 838 | array( |
839 | 839 | 'operator' => 'in', |
840 | 840 | 'key' => 'is_approved', |
841 | - 'value' => (array) $filter['value'], |
|
841 | + 'value' => (array)$filter[ 'value' ], |
|
842 | 842 | ), |
843 | 843 | array( |
844 | 844 | 'operator' => 'is', |
@@ -850,30 +850,30 @@ discard block |
||
850 | 850 | ) ); |
851 | 851 | $_tmp_query_parts = $_tmp_query->_introspect(); |
852 | 852 | |
853 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
853 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
854 | 854 | |
855 | 855 | $filter = false; |
856 | 856 | continue; |
857 | 857 | } |
858 | 858 | |
859 | 859 | // Construct manual query for text mode creator search |
860 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
861 | - $extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
860 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
861 | + $extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
862 | 862 | $filter = false; |
863 | 863 | continue; |
864 | 864 | } |
865 | 865 | |
866 | 866 | // By default, we want searches to be wildcard for each field. |
867 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
867 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
868 | 868 | |
869 | 869 | // For multichoice, let's have an in (OR) search. |
870 | - if ( is_array( $filter['value'] ) ) { |
|
871 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
870 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
871 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | // Default form with joins functionality |
875 | - if ( empty( $filter['form_id'] ) ) { |
|
876 | - $filter['form_id'] = $view->form ? $view->form->ID : 0; |
|
875 | + if ( empty( $filter[ 'form_id' ] ) ) { |
|
876 | + $filter[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | /** |
@@ -883,28 +883,28 @@ discard block |
||
883 | 883 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
884 | 884 | * @param \GV\View $view The View we're operating on. |
885 | 885 | */ |
886 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view ); |
|
886 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view ); |
|
887 | 887 | } |
888 | 888 | |
889 | - if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) { |
|
889 | + if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) { |
|
890 | 890 | $date_criteria = array(); |
891 | 891 | |
892 | - if ( isset( $search_criteria['start_date'] ) ) { |
|
893 | - $date_criteria['start_date'] = $search_criteria['start_date']; |
|
892 | + if ( isset( $search_criteria[ 'start_date' ] ) ) { |
|
893 | + $date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ]; |
|
894 | 894 | } |
895 | 895 | |
896 | - if ( isset( $search_criteria['end_date'] ) ) { |
|
897 | - $date_criteria['end_date'] = $search_criteria['end_date']; |
|
896 | + if ( isset( $search_criteria[ 'end_date' ] ) ) { |
|
897 | + $date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ]; |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | $_tmp_query = new $query_class( $view->form->ID, $date_criteria ); |
901 | 901 | $_tmp_query_parts = $_tmp_query->_introspect(); |
902 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
902 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | $search_conditions = array(); |
906 | 906 | |
907 | - if ( $filters = array_filter( $search_criteria['field_filters'] ) ) { |
|
907 | + if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) { |
|
908 | 908 | foreach ( $filters as &$filter ) { |
909 | 909 | if ( ! is_array( $filter ) ) { |
910 | 910 | continue; |
@@ -916,12 +916,12 @@ discard block |
||
916 | 916 | * code by reusing what's inside GF_Query already as they |
917 | 917 | * take care of many small things like forcing numeric, etc. |
918 | 918 | */ |
919 | - $_tmp_query = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
919 | + $_tmp_query = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
920 | 920 | $_tmp_query_parts = $_tmp_query->_introspect(); |
921 | - $search_condition = $_tmp_query_parts['where']; |
|
921 | + $search_condition = $_tmp_query_parts[ 'where' ]; |
|
922 | 922 | |
923 | - if ( empty( $filter['key'] ) && $search_condition->expressions ) { |
|
924 | - $search_conditions[] = $search_condition; |
|
923 | + if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) { |
|
924 | + $search_conditions[ ] = $search_condition; |
|
925 | 925 | } else { |
926 | 926 | $left = $search_condition->left; |
927 | 927 | $alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' ); |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | $on = $_join->join_on; |
932 | 932 | $join = $_join->join; |
933 | 933 | |
934 | - $search_conditions[] = GF_Query_Condition::_or( |
|
934 | + $search_conditions[ ] = GF_Query_Condition::_or( |
|
935 | 935 | // Join |
936 | 936 | new GF_Query_Condition( |
937 | 937 | new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ), |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | ); |
948 | 948 | } |
949 | 949 | } else { |
950 | - $search_conditions[] = new GF_Query_Condition( |
|
950 | + $search_conditions[ ] = new GF_Query_Condition( |
|
951 | 951 | new GF_Query_Column( $left->field_id, $left->source, $alias ), |
952 | 952 | $search_condition->operator, |
953 | 953 | $search_condition->right |
@@ -969,7 +969,7 @@ discard block |
||
969 | 969 | /** |
970 | 970 | * Combine the parts as a new WHERE clause. |
971 | 971 | */ |
972 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) ); |
|
972 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) ); |
|
973 | 973 | $query->where( $where ); |
974 | 974 | } |
975 | 975 | |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | $field_id = str_replace( 'filter_', '', $key ); |
993 | 993 | |
994 | 994 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
995 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
995 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
996 | 996 | $field_id = str_replace( '_', '.', $field_id ); |
997 | 997 | } |
998 | 998 | |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | // form is in searchable fields |
1050 | 1050 | $found = false; |
1051 | 1051 | foreach ( $searchable_fields as $field ) { |
1052 | - if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) { |
|
1052 | + if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) { |
|
1053 | 1053 | $found = true; |
1054 | 1054 | break; |
1055 | 1055 | } |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | |
1090 | 1090 | case 'select': |
1091 | 1091 | case 'radio': |
1092 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1092 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1093 | 1093 | break; |
1094 | 1094 | |
1095 | 1095 | case 'post_category': |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | |
1104 | 1104 | foreach ( $value as $val ) { |
1105 | 1105 | $cat = get_term( $val, 'category' ); |
1106 | - $filter[] = array( |
|
1106 | + $filter[ ] = array( |
|
1107 | 1107 | 'key' => $field_id, |
1108 | 1108 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
1109 | 1109 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | $filter = array(); |
1123 | 1123 | |
1124 | 1124 | foreach ( $value as $val ) { |
1125 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
1125 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | break; |
@@ -1131,9 +1131,9 @@ discard block |
||
1131 | 1131 | // convert checkbox on/off into the correct search filter |
1132 | 1132 | if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
1133 | 1133 | foreach ( $form_field->inputs as $k => $input ) { |
1134 | - if ( $input['id'] == $field_id ) { |
|
1135 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
1136 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1134 | + if ( $input[ 'id' ] == $field_id ) { |
|
1135 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
1136 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1137 | 1137 | break; |
1138 | 1138 | } |
1139 | 1139 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | $filter = array(); |
1144 | 1144 | |
1145 | 1145 | foreach ( $value as $val ) { |
1146 | - $filter[] = array( |
|
1146 | + $filter[ ] = array( |
|
1147 | 1147 | 'key' => $field_id, |
1148 | 1148 | 'value' => $val, |
1149 | 1149 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1164,9 +1164,9 @@ discard block |
||
1164 | 1164 | foreach ( $words as $word ) { |
1165 | 1165 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
1166 | 1166 | // Keep the same key for each filter |
1167 | - $filter['value'] = $word; |
|
1167 | + $filter[ 'value' ] = $word; |
|
1168 | 1168 | // Add a search for the value |
1169 | - $filters[] = $filter; |
|
1169 | + $filters[ ] = $filter; |
|
1170 | 1170 | } |
1171 | 1171 | } |
1172 | 1172 | |
@@ -1180,19 +1180,19 @@ discard block |
||
1180 | 1180 | |
1181 | 1181 | foreach ( $searchable_fields as $searchable_field ) { |
1182 | 1182 | |
1183 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
1183 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
1184 | 1184 | continue; |
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | // Only exact-match dropdowns, not text search |
1188 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
1188 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
1189 | 1189 | continue; |
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
1193 | 1193 | |
1194 | 1194 | if ( 4 === $input_id ) { |
1195 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1195 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1196 | 1196 | }; |
1197 | 1197 | } |
1198 | 1198 | } |
@@ -1220,12 +1220,12 @@ discard block |
||
1220 | 1220 | * @since 1.16.3 |
1221 | 1221 | * Safeguard until GF implements '<=' operator |
1222 | 1222 | */ |
1223 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1223 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1224 | 1224 | $operator = '<'; |
1225 | 1225 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1226 | 1226 | } |
1227 | 1227 | |
1228 | - $filter[] = array( |
|
1228 | + $filter[ ] = array( |
|
1229 | 1229 | 'key' => $field_id, |
1230 | 1230 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1231 | 1231 | 'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ), |
@@ -1233,12 +1233,12 @@ discard block |
||
1233 | 1233 | } |
1234 | 1234 | } else { |
1235 | 1235 | $date = $value; |
1236 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1237 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1236 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1237 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | - if ('payment_date' === $key) { |
|
1241 | - $filter['operator'] = 'contains'; |
|
1240 | + if ( 'payment_date' === $key ) { |
|
1241 | + $filter[ 'operator' ] = 'contains'; |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | break; |
@@ -1267,7 +1267,7 @@ discard block |
||
1267 | 1267 | 'ymd_dot' => 'Y.m.d', |
1268 | 1268 | ); |
1269 | 1269 | |
1270 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1270 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1271 | 1271 | $format = $datepicker[ $field->dateFormat ]; |
1272 | 1272 | } |
1273 | 1273 | |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | public function add_template_path( $file_paths ) { |
1305 | 1305 | |
1306 | 1306 | // Index 100 is the default GravityView template path. |
1307 | - $file_paths[102] = self::$file . 'templates/'; |
|
1307 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1308 | 1308 | |
1309 | 1309 | return $file_paths; |
1310 | 1310 | } |
@@ -1323,7 +1323,7 @@ discard block |
||
1323 | 1323 | $has_date = false; |
1324 | 1324 | |
1325 | 1325 | foreach ( $search_fields as $k => $field ) { |
1326 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1326 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1327 | 1327 | $has_date = true; |
1328 | 1328 | break; |
1329 | 1329 | } |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | $view = \GV\View::by_id( $gravityview_view->view_id ); |
1353 | 1353 | |
1354 | 1354 | // get configured search fields |
1355 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1355 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1356 | 1356 | |
1357 | 1357 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1358 | 1358 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1366,39 +1366,39 @@ discard block |
||
1366 | 1366 | |
1367 | 1367 | $updated_field = $this->get_search_filter_details( $updated_field, $context ); |
1368 | 1368 | |
1369 | - switch ( $field['field'] ) { |
|
1369 | + switch ( $field[ 'field' ] ) { |
|
1370 | 1370 | |
1371 | 1371 | case 'search_all': |
1372 | - $updated_field['key'] = 'search_all'; |
|
1373 | - $updated_field['input'] = 'search_all'; |
|
1374 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1372 | + $updated_field[ 'key' ] = 'search_all'; |
|
1373 | + $updated_field[ 'input' ] = 'search_all'; |
|
1374 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1375 | 1375 | break; |
1376 | 1376 | |
1377 | 1377 | case 'entry_date': |
1378 | - $updated_field['key'] = 'entry_date'; |
|
1379 | - $updated_field['input'] = 'entry_date'; |
|
1380 | - $updated_field['value'] = array( |
|
1378 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1379 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1380 | + $updated_field[ 'value' ] = array( |
|
1381 | 1381 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1382 | 1382 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1383 | 1383 | ); |
1384 | 1384 | break; |
1385 | 1385 | |
1386 | 1386 | case 'entry_id': |
1387 | - $updated_field['key'] = 'entry_id'; |
|
1388 | - $updated_field['input'] = 'entry_id'; |
|
1389 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1387 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1388 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1389 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1390 | 1390 | break; |
1391 | 1391 | |
1392 | 1392 | case 'created_by': |
1393 | - $updated_field['key'] = 'created_by'; |
|
1394 | - $updated_field['name'] = 'gv_by'; |
|
1395 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1393 | + $updated_field[ 'key' ] = 'created_by'; |
|
1394 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1395 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1396 | 1396 | break; |
1397 | 1397 | |
1398 | 1398 | case 'is_approved': |
1399 | - $updated_field['key'] = 'is_approved'; |
|
1400 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1401 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1399 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1400 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1401 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1402 | 1402 | break; |
1403 | 1403 | } |
1404 | 1404 | |
@@ -1419,16 +1419,16 @@ discard block |
||
1419 | 1419 | |
1420 | 1420 | $gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args ); |
1421 | 1421 | |
1422 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1422 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1423 | 1423 | |
1424 | 1424 | /** @since 1.14 */ |
1425 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1425 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1426 | 1426 | |
1427 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1427 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1428 | 1428 | |
1429 | 1429 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1430 | 1430 | |
1431 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1431 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1432 | 1432 | |
1433 | 1433 | if ( $this->has_date_field( $search_fields ) ) { |
1434 | 1434 | // enqueue datepicker stuff only if needed! |
@@ -1450,10 +1450,10 @@ discard block |
||
1450 | 1450 | public static function get_search_class( $custom_class = '' ) { |
1451 | 1451 | $gravityview_view = GravityView_View::getInstance(); |
1452 | 1452 | |
1453 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1453 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1454 | 1454 | |
1455 | - if ( ! empty( $custom_class ) ) { |
|
1456 | - $search_class .= ' '.$custom_class; |
|
1455 | + if ( ! empty( $custom_class ) ) { |
|
1456 | + $search_class .= ' ' . $custom_class; |
|
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | /** |
@@ -1504,9 +1504,9 @@ discard block |
||
1504 | 1504 | |
1505 | 1505 | if ( ! $label ) { |
1506 | 1506 | |
1507 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1507 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1508 | 1508 | |
1509 | - switch( $field['field'] ) { |
|
1509 | + switch ( $field[ 'field' ] ) { |
|
1510 | 1510 | case 'search_all': |
1511 | 1511 | $label = __( 'Search Entries:', 'gravityview' ); |
1512 | 1512 | break; |
@@ -1518,10 +1518,10 @@ discard block |
||
1518 | 1518 | break; |
1519 | 1519 | default: |
1520 | 1520 | // If this is a field input, not a field |
1521 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1521 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1522 | 1522 | |
1523 | 1523 | // Get the label for the field in question, which returns an array |
1524 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1524 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1525 | 1525 | |
1526 | 1526 | // Get the item with the `label` key |
1527 | 1527 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1562,13 +1562,13 @@ discard block |
||
1562 | 1562 | $form = $gravityview_view->getForm(); |
1563 | 1563 | |
1564 | 1564 | // for advanced field ids (eg, first name / last name ) |
1565 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1565 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1566 | 1566 | |
1567 | 1567 | // get searched value from $_GET/$_POST (string or array) |
1568 | 1568 | $value = $this->rgget_or_rgpost( $name ); |
1569 | 1569 | |
1570 | 1570 | // get form field details |
1571 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1571 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1572 | 1572 | |
1573 | 1573 | $form_field_type = \GV\Utils::get( $form_field, 'type' ); |
1574 | 1574 | |
@@ -1582,22 +1582,22 @@ discard block |
||
1582 | 1582 | ); |
1583 | 1583 | |
1584 | 1584 | // collect choices |
1585 | - if ( 'post_category' === $form_field_type && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1586 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1587 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1588 | - $filter['choices'] = $form_field['choices']; |
|
1585 | + if ( 'post_category' === $form_field_type && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1586 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1587 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1588 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1589 | 1589 | } |
1590 | 1590 | |
1591 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1592 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1591 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1592 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1593 | 1593 | } |
1594 | 1594 | |
1595 | - if ( 'created_by' === $field['field'] ) { |
|
1596 | - $filter['choices'] = self::get_created_by_choices( $context->view ); |
|
1597 | - $filter['type'] = 'created_by'; |
|
1595 | + if ( 'created_by' === $field[ 'field' ] ) { |
|
1596 | + $filter[ 'choices' ] = self::get_created_by_choices( $context->view ); |
|
1597 | + $filter[ 'type' ] = 'created_by'; |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | - if ( ! empty( $filter['choices'] ) ) { |
|
1600 | + if ( ! empty( $filter[ 'choices' ] ) ) { |
|
1601 | 1601 | /** |
1602 | 1602 | * @filter `gravityview/search/sieve_choices` Only output used choices for this field. |
1603 | 1603 | * @param[in,out] bool Yes or no. |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | * @param \GV\Context The context. |
1606 | 1606 | */ |
1607 | 1607 | if ( apply_filters( 'gravityview/search/sieve_choices', false, $field, $context ) ) { |
1608 | - $filter['choices'] = $this->sieve_filter_choices( $filter, $context ); |
|
1608 | + $filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context ); |
|
1609 | 1609 | } |
1610 | 1610 | } |
1611 | 1611 | |
@@ -1634,12 +1634,12 @@ discard block |
||
1634 | 1634 | * @return array The filter choices. |
1635 | 1635 | */ |
1636 | 1636 | private function sieve_filter_choices( $filter, $context ) { |
1637 | - if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) { |
|
1637 | + if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) { |
|
1638 | 1638 | return $filter; // @todo Populate plugins might give us empty choices |
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | // Allow only created_by and field-ids to be sieved. |
1642 | - if ( 'created_by' !== $filter['key'] && ! is_numeric( $filter['key'] ) ) { |
|
1642 | + if ( 'created_by' !== $filter[ 'key' ] && ! is_numeric( $filter[ 'key' ] ) ) { |
|
1643 | 1643 | return $filter; |
1644 | 1644 | } |
1645 | 1645 | |
@@ -1650,13 +1650,13 @@ discard block |
||
1650 | 1650 | $entry_table_name = GFFormsModel::get_entry_table_name(); |
1651 | 1651 | $entry_meta_table_name = GFFormsModel::get_entry_meta_table_name(); |
1652 | 1652 | |
1653 | - $key_like = $wpdb->esc_like( $filter['key'] ) . '.%'; |
|
1653 | + $key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%'; |
|
1654 | 1654 | |
1655 | 1655 | switch ( \GV\Utils::get( $filter, 'type' ) ): |
1656 | 1656 | case 'post_category': |
1657 | 1657 | $choices = $wpdb->get_col( $wpdb->prepare( |
1658 | 1658 | "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", |
1659 | - $key_like, $filter['key'], $form_id |
|
1659 | + $key_like, $filter[ 'key' ], $form_id |
|
1660 | 1660 | ) ); |
1661 | 1661 | break; |
1662 | 1662 | case 'created_by': |
@@ -1668,17 +1668,17 @@ discard block |
||
1668 | 1668 | default: |
1669 | 1669 | $choices = $wpdb->get_col( $wpdb->prepare( |
1670 | 1670 | "SELECT DISTINCT meta_value FROM $entry_meta_table_name WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d", |
1671 | - $key_like, $filter['key'], $form_id |
|
1671 | + $key_like, $filter[ 'key' ], $form_id |
|
1672 | 1672 | ) ); |
1673 | 1673 | |
1674 | - if ( ( $field = gravityview_get_field( $form_id, $filter['key'] ) ) && 'json' === $field->storageType ) { |
|
1674 | + if ( ( $field = gravityview_get_field( $form_id, $filter[ 'key' ] ) ) && 'json' === $field->storageType ) { |
|
1675 | 1675 | $choices = array_map( 'json_decode', $choices ); |
1676 | 1676 | $_choices_array = array(); |
1677 | 1677 | foreach ( $choices as $choice ) { |
1678 | 1678 | if ( is_array( $choice ) ) { |
1679 | 1679 | $_choices_array = array_merge( $_choices_array, $choice ); |
1680 | 1680 | } else { |
1681 | - $_choices_array []= $choice; |
|
1681 | + $_choices_array [ ] = $choice; |
|
1682 | 1682 | } |
1683 | 1683 | } |
1684 | 1684 | $choices = array_unique( $_choices_array ); |
@@ -1688,9 +1688,9 @@ discard block |
||
1688 | 1688 | endswitch; |
1689 | 1689 | |
1690 | 1690 | $filter_choices = array(); |
1691 | - foreach ( $filter['choices'] as $choice ) { |
|
1692 | - if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) { |
|
1693 | - $filter_choices[] = $choice; |
|
1691 | + foreach ( $filter[ 'choices' ] as $choice ) { |
|
1692 | + if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) { |
|
1693 | + $filter_choices[ ] = $choice; |
|
1694 | 1694 | } |
1695 | 1695 | } |
1696 | 1696 | |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | * @param \GV\View $view The view. |
1726 | 1726 | */ |
1727 | 1727 | $text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view ); |
1728 | - $choices[] = array( |
|
1728 | + $choices[ ] = array( |
|
1729 | 1729 | 'value' => $user->ID, |
1730 | 1730 | 'text' => $text, |
1731 | 1731 | ); |
@@ -1745,9 +1745,9 @@ discard block |
||
1745 | 1745 | |
1746 | 1746 | $choices = array(); |
1747 | 1747 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1748 | - $choices[] = array( |
|
1749 | - 'value' => $status['value'], |
|
1750 | - 'text' => $status['label'], |
|
1748 | + $choices[ ] = array( |
|
1749 | + 'value' => $status[ 'value' ], |
|
1750 | + 'text' => $status[ 'label' ], |
|
1751 | 1751 | ); |
1752 | 1752 | } |
1753 | 1753 | |
@@ -1799,7 +1799,7 @@ discard block |
||
1799 | 1799 | */ |
1800 | 1800 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1801 | 1801 | |
1802 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1802 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1803 | 1803 | |
1804 | 1804 | return $js_dependencies; |
1805 | 1805 | } |
@@ -1843,7 +1843,7 @@ discard block |
||
1843 | 1843 | 'isRTL' => is_rtl(), |
1844 | 1844 | ), $view_data ); |
1845 | 1845 | |
1846 | - $localizations['datepicker'] = $datepicker_settings; |
|
1846 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1847 | 1847 | |
1848 | 1848 | return $localizations; |
1849 | 1849 | |
@@ -1870,7 +1870,7 @@ discard block |
||
1870 | 1870 | * @return void |
1871 | 1871 | */ |
1872 | 1872 | private function maybe_enqueue_flexibility() { |
1873 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1873 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1874 | 1874 | wp_enqueue_script( 'gv-flexibility' ); |
1875 | 1875 | } |
1876 | 1876 | } |
@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1893 | 1893 | |
1894 | 1894 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1895 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1895 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1896 | 1896 | |
1897 | 1897 | /** |
1898 | 1898 | * @filter `gravityview_search_datepicker_class` |
@@ -1971,7 +1971,7 @@ discard block |
||
1971 | 1971 | public function add_preview_inputs() { |
1972 | 1972 | global $wp; |
1973 | 1973 | |
1974 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
1974 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
1975 | 1975 | return; |
1976 | 1976 | } |
1977 | 1977 | |
@@ -2023,7 +2023,7 @@ discard block |
||
2023 | 2023 | */ |
2024 | 2024 | class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition { |
2025 | 2025 | public function __construct( $filter, $view ) { |
2026 | - $this->value = $filter['value']; |
|
2026 | + $this->value = $filter[ 'value' ]; |
|
2027 | 2027 | $this->view = $view; |
2028 | 2028 | } |
2029 | 2029 | |
@@ -2055,11 +2055,11 @@ discard block |
||
2055 | 2055 | $conditions = array(); |
2056 | 2056 | |
2057 | 2057 | foreach ( $user_fields as $user_field ) { |
2058 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2058 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2059 | 2059 | } |
2060 | 2060 | |
2061 | 2061 | foreach ( $user_meta_fields as $meta_field ) { |
2062 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2062 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
2063 | 2063 | } |
2064 | 2064 | |
2065 | 2065 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |