@@ -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,7 +93,7 @@ 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 | |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | - $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'gv_recent_entries'; |
|
105 | - $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; |
|
104 | + $args[ 'id' ] = ( isset( $args[ 'id' ] ) ) ? $args[ 'id' ] : 'gv_recent_entries'; |
|
105 | + $instance[ 'title' ] = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : ''; |
|
106 | 106 | |
107 | - $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args['id'] ); |
|
107 | + $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args[ 'id' ] ); |
|
108 | 108 | |
109 | - echo $args['before_widget']; |
|
109 | + echo $args[ 'before_widget' ]; |
|
110 | 110 | |
111 | - if ( !empty( $title ) ) { |
|
112 | - echo $args['before_title'] . $title . $args['after_title']; |
|
111 | + if ( ! empty( $title ) ) { |
|
112 | + echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | do_action( 'gravityview/widget/recent-entries/after_widget', $args, $instance ); |
131 | 131 | |
132 | - echo $args['after_widget']; |
|
132 | + echo $args[ 'after_widget' ]; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | private function get_output( $instance ) { |
145 | 145 | |
146 | - $form_id = gravityview_get_form_id( $instance['view_id'] ); |
|
146 | + $form_id = gravityview_get_form_id( $instance[ 'view_id' ] ); |
|
147 | 147 | |
148 | 148 | $form = gravityview_get_form( $form_id ); |
149 | 149 | |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | * @since 1.6.1 |
154 | 154 | * @var int $entry_link_post_id The ID to use as the parent post for the entry |
155 | 155 | */ |
156 | - $entry_link_post_id = ( empty( $instance['error_post_id'] ) && !empty( $instance['post_id'] ) ) ? $instance['post_id'] : $instance['view_id']; |
|
156 | + $entry_link_post_id = ( empty( $instance[ 'error_post_id' ] ) && ! empty( $instance[ 'post_id' ] ) ) ? $instance[ 'post_id' ] : $instance[ 'view_id' ]; |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Generate list output |
160 | 160 | * @since 1.7.2 |
161 | 161 | */ |
162 | - $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget', null, $instance['view_id'] ); |
|
162 | + $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance[ 'link_format' ], $instance[ 'after_link' ], 'recent-entries-widget', null, $instance[ 'view_id' ] ); |
|
163 | 163 | |
164 | 164 | $output = $List->get_output(); |
165 | 165 | |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | */ |
185 | 185 | private function get_entries( $instance, $form_id ) { |
186 | 186 | |
187 | - $view = \GV\View::by_id( $instance['view_id'] ); |
|
187 | + $view = \GV\View::by_id( $instance[ 'view_id' ] ); |
|
188 | 188 | |
189 | - $limit = isset( $instance['limit'] ) ? $instance['limit'] : 10; |
|
189 | + $limit = isset( $instance[ 'limit' ] ) ? $instance[ 'limit' ] : 10; |
|
190 | 190 | |
191 | 191 | $view->settings->set( 'page_size', $limit ); |
192 | 192 | |
@@ -209,23 +209,23 @@ discard block |
||
209 | 209 | $instance = $new_instance; |
210 | 210 | |
211 | 211 | // Force positive number |
212 | - $instance['limit'] = empty( $instance['limit'] ) ? 10 : absint( $instance['limit'] ); |
|
212 | + $instance[ 'limit' ] = empty( $instance[ 'limit' ] ) ? 10 : absint( $instance[ 'limit' ] ); |
|
213 | 213 | |
214 | - $instance['view_id'] = intval( $instance['view_id'] ); |
|
214 | + $instance[ 'view_id' ] = intval( $instance[ 'view_id' ] ); |
|
215 | 215 | |
216 | - $instance['link_format'] = trim( rtrim( $instance['link_format'] ) ); |
|
216 | + $instance[ 'link_format' ] = trim( rtrim( $instance[ 'link_format' ] ) ); |
|
217 | 217 | |
218 | - $instance['link_format'] = empty( $instance['link_format'] ) ? $old_instance['link_format'] : $instance['link_format']; |
|
218 | + $instance[ 'link_format' ] = empty( $instance[ 'link_format' ] ) ? $old_instance[ 'link_format' ] : $instance[ 'link_format' ]; |
|
219 | 219 | |
220 | - $instance['post_id'] = empty( $instance['post_id'] ) ? '' : intval( $instance['post_id'] ); |
|
220 | + $instance[ 'post_id' ] = empty( $instance[ 'post_id' ] ) ? '' : intval( $instance[ 'post_id' ] ); |
|
221 | 221 | |
222 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'], true ); |
|
222 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance[ 'post_id' ], $instance[ 'view_id' ], true ); |
|
223 | 223 | |
224 | 224 | //check if post_id is a valid post with embedded View |
225 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
225 | + $instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
226 | 226 | |
227 | 227 | // Share that the widget isn't brand new |
228 | - $instance['updated'] = 1; |
|
228 | + $instance[ 'updated' ] = 1; |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Modify the updated instance. This will allow for validating any added instance settings externally. |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | |
248 | 248 | // Set up some default widget settings. |
249 | 249 | $defaults = array( |
250 | - 'title' => __('Recent Entries', 'gravityview'), |
|
250 | + 'title' => __( 'Recent Entries', 'gravityview' ), |
|
251 | 251 | 'view_id' => NULL, |
252 | 252 | 'post_id' => NULL, |
253 | 253 | 'limit' => 10, |
254 | - 'link_format' => __('Entry #{entry_id}', 'gravityview'), |
|
254 | + 'link_format' => __( 'Entry #{entry_id}', 'gravityview' ), |
|
255 | 255 | 'after_link' => '' |
256 | 256 | ); |
257 | 257 | |
258 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
258 | + $instance = wp_parse_args( (array)$instance, $defaults ); |
|
259 | 259 | |
260 | 260 | ?> |
261 | 261 | |
262 | 262 | <!-- Title --> |
263 | 263 | <p> |
264 | 264 | <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'gravityview' ) ?></label> |
265 | - <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'] ); ?>" /> |
|
265 | + <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' ] ); ?>" /> |
|
266 | 266 | </p> |
267 | 267 | |
268 | 268 | <!-- Download --> |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $views = get_posts( $args ); |
276 | 276 | |
277 | 277 | // If there are no views set up yet, we get outta here. |
278 | - if( empty( $views ) ) { |
|
278 | + if ( empty( $views ) ) { |
|
279 | 279 | echo '<div id="select_gravityview_view"><div class="wrap">' . GravityView_Admin::no_views_text() . '</div></div>'; |
280 | 280 | return; |
281 | 281 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * Display errors generated for invalid embed IDs |
288 | 288 | * @see GravityView_View_Data::is_valid_embed_id |
289 | 289 | */ |
290 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
290 | + if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) { |
|
291 | 291 | ?> |
292 | 292 | <div class="error inline hide-on-view-change"> |
293 | - <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
|
293 | + <p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p> |
|
294 | 294 | </div> |
295 | 295 | <?php |
296 | 296 | unset ( $error ); |
@@ -298,14 +298,14 @@ discard block |
||
298 | 298 | ?> |
299 | 299 | |
300 | 300 | <p> |
301 | - <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label> |
|
301 | + <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label> |
|
302 | 302 | <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' ) ); ?>"> |
303 | 303 | <option value=""><?php esc_html_e( '— Select a View as Entries Source —', 'gravityview' ); ?></option> |
304 | 304 | <?php |
305 | 305 | |
306 | - foreach( $views as $view ) { |
|
307 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
308 | - echo '<option value="'. $view->ID .'"'.selected( absint( $instance['view_id'] ), $view->ID ).'>'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
306 | + foreach ( $views as $view ) { |
|
307 | + $title = empty( $view->post_title ) ? __( '(no title)', 'gravityview' ) : $view->post_title; |
|
308 | + echo '<option value="' . $view->ID . '"' . selected( absint( $instance[ 'view_id' ] ), $view->ID ) . '>' . esc_html( sprintf( '%s #%d', $title, $view->ID ) ) . '</option>'; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | ?> |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | * Display errors generated for invalid embed IDs |
318 | 318 | * @see GravityView_View_Data::is_valid_embed_id |
319 | 319 | */ |
320 | - if( !empty( $instance['error_post_id'] ) ) { |
|
320 | + if ( ! empty( $instance[ 'error_post_id' ] ) ) { |
|
321 | 321 | ?> |
322 | 322 | <div class="error inline"> |
323 | - <p><?php echo $instance['error_post_id']; ?></p> |
|
323 | + <p><?php echo $instance[ 'error_post_id' ]; ?></p> |
|
324 | 324 | </div> |
325 | 325 | <?php |
326 | 326 | unset ( $error ); |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | ?> |
329 | 329 | |
330 | 330 | <p> |
331 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
332 | - <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'] ); ?>" /> |
|
331 | + <label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
332 | + <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' ] ); ?>" /> |
|
333 | 333 | <span class="howto gv-howto"><?php |
334 | - 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' ); |
|
335 | - echo ' '.gravityview_get_link('https://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
334 | + 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' ); |
|
335 | + echo ' ' . gravityview_get_link( 'https://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
336 | 336 | ?></span> |
337 | 337 | </p> |
338 | 338 | |
@@ -340,21 +340,21 @@ discard block |
||
340 | 340 | <label for="<?php echo $this->get_field_id( 'limit' ); ?>"> |
341 | 341 | <span><?php _e( 'Number of entries to show:', 'gravityview' ); ?></span> |
342 | 342 | </label> |
343 | - <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" /> |
|
343 | + <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" /> |
|
344 | 344 | </p> |
345 | 345 | |
346 | 346 | <p> |
347 | 347 | <label for="<?php echo $this->get_field_id( 'link_format' ); ?>"> |
348 | 348 | <span><?php _e( 'Entry link text (required)', 'gravityview' ); ?></span> |
349 | 349 | </label> |
350 | - <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" /> |
|
350 | + <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" /> |
|
351 | 351 | </p> |
352 | 352 | |
353 | 353 | <p> |
354 | 354 | <label for="<?php echo $this->get_field_id( 'after_link' ); ?>"> |
355 | 355 | <span><?php _e( 'Text or HTML to display after the link (optional)', 'gravityview' ); ?></span> |
356 | 356 | </label> |
357 | - <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> |
|
357 | + <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> |
|
358 | 358 | </p> |
359 | 359 | |
360 | 360 | <?php |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @param GravityView_Recent_Entries_Widget $this WP_Widget object |
365 | 365 | * @param array $instance Current widget instance |
366 | 366 | */ |
367 | - do_action( 'gravityview_recent_entries_widget_form' , $this, $instance ); |
|
367 | + do_action( 'gravityview_recent_entries_widget_form', $this, $instance ); |
|
368 | 368 | |
369 | 369 | ?> |
370 | 370 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | $widget_ops = array( |
13 | 13 | 'classname' => 'widget_gravityview_search', |
14 | - 'description' => __( 'A search form for a specific GravityView.', 'gravityview') |
|
14 | + 'description' => __( 'A search form for a specific GravityView.', 'gravityview' ) |
|
15 | 15 | ); |
16 | 16 | |
17 | 17 | $widget_display = array( |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | private function load_required_files() { |
37 | - if( !class_exists( 'GravityView_Widget_Search' ) ) { |
|
37 | + if ( ! class_exists( 'GravityView_Widget_Search' ) ) { |
|
38 | 38 | gravityview_register_gravityview_widgets(); |
39 | 39 | } |
40 | 40 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | // Don't show unless a View ID has been set. |
60 | - if( empty( $instance['view_id'] ) ) { |
|
60 | + if ( empty( $instance[ 'view_id' ] ) ) { |
|
61 | 61 | |
62 | 62 | gravityview()->log->debug( 'No View ID has been defined. Not showing the widget.', array( 'data' => $instance ) ); |
63 | 63 | |
@@ -70,22 +70,22 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | /** This filter is documented in wp-includes/default-widgets.php */ |
73 | - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
|
73 | + $title = apply_filters( 'widget_title', empty( $instance[ 'title' ] ) ? '' : $instance[ 'title' ], $instance, $this->id_base ); |
|
74 | 74 | |
75 | - echo $args['before_widget']; |
|
75 | + echo $args[ 'before_widget' ]; |
|
76 | 76 | |
77 | 77 | if ( $title ) { |
78 | - echo $args['before_title'] . $title . $args['after_title']; |
|
78 | + echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // @todo Add to the widget configuration form |
82 | - $instance['search_layout'] = apply_filters( 'gravityview/widget/search/layout', 'vertical', $instance ); |
|
82 | + $instance[ 'search_layout' ] = apply_filters( 'gravityview/widget/search/layout', 'vertical', $instance ); |
|
83 | 83 | |
84 | - $instance['context'] = 'wp_widget'; |
|
84 | + $instance[ 'context' ] = 'wp_widget'; |
|
85 | 85 | |
86 | 86 | // form |
87 | - $instance['form_id'] = GVCommon::get_meta_form_id( $instance['view_id'] ); |
|
88 | - $instance['form'] = GVCommon::get_form( $instance['form_id'] ); |
|
87 | + $instance[ 'form_id' ] = GVCommon::get_meta_form_id( $instance[ 'view_id' ] ); |
|
88 | + $instance[ 'form' ] = GVCommon::get_form( $instance[ 'form_id' ] ); |
|
89 | 89 | |
90 | 90 | // We don't want to overwrite existing context, etc. |
91 | 91 | $previous_view = GravityView_View::getInstance(); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | new GravityView_View( $previous_view ); |
103 | 103 | |
104 | - echo $args['after_widget']; |
|
104 | + echo $args[ 'after_widget' ]; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -111,27 +111,27 @@ discard block |
||
111 | 111 | |
112 | 112 | $instance = $old_instance; |
113 | 113 | |
114 | - if( $this->is_preview() ) { |
|
114 | + if ( $this->is_preview() ) { |
|
115 | 115 | //Oh! Sorry but still not fully compatible with customizer |
116 | 116 | return $instance; |
117 | 117 | } |
118 | 118 | |
119 | - $new_instance = wp_parse_args( (array) $new_instance, self::get_defaults() ); |
|
119 | + $new_instance = wp_parse_args( (array)$new_instance, self::get_defaults() ); |
|
120 | 120 | |
121 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
122 | - $instance['view_id'] = absint( $new_instance['view_id'] ); |
|
123 | - $instance['search_fields'] = $new_instance['search_fields']; |
|
124 | - $instance['post_id'] = $new_instance['post_id']; |
|
125 | - $instance['search_clear'] = $new_instance['search_clear']; |
|
126 | - $instance['search_mode'] = $new_instance['search_mode']; |
|
121 | + $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] ); |
|
122 | + $instance[ 'view_id' ] = absint( $new_instance[ 'view_id' ] ); |
|
123 | + $instance[ 'search_fields' ] = $new_instance[ 'search_fields' ]; |
|
124 | + $instance[ 'post_id' ] = $new_instance[ 'post_id' ]; |
|
125 | + $instance[ 'search_clear' ] = $new_instance[ 'search_clear' ]; |
|
126 | + $instance[ 'search_mode' ] = $new_instance[ 'search_mode' ]; |
|
127 | 127 | |
128 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'], true ); |
|
128 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance[ 'post_id' ], $instance[ 'view_id' ], true ); |
|
129 | 129 | |
130 | 130 | //check if post_id is a valid post with embedded View |
131 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
131 | + $instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
132 | 132 | |
133 | 133 | // Share that the widget isn't brand new |
134 | - $instance['updated'] = 1; |
|
134 | + $instance[ 'updated' ] = 1; |
|
135 | 135 | |
136 | 136 | return $instance; |
137 | 137 | } |
@@ -142,28 +142,28 @@ discard block |
||
142 | 142 | public function form( $instance ) { |
143 | 143 | |
144 | 144 | // @todo Make compatible with Customizer |
145 | - if( $this->is_preview() ) { |
|
145 | + if ( $this->is_preview() ) { |
|
146 | 146 | |
147 | - $warning = sprintf( esc_html__( 'This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview' ), '<a href="'.admin_url('widgets.php').'">', '</a>' ); |
|
147 | + $warning = sprintf( esc_html__( 'This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview' ), '<a href="' . admin_url( 'widgets.php' ) . '">', '</a>' ); |
|
148 | 148 | |
149 | 149 | echo wpautop( GravityView_Admin::get_floaty() . $warning ); |
150 | 150 | |
151 | 151 | return; |
152 | 152 | } |
153 | 153 | |
154 | - $instance = wp_parse_args( (array) $instance, self::get_defaults() ); |
|
154 | + $instance = wp_parse_args( (array)$instance, self::get_defaults() ); |
|
155 | 155 | |
156 | - $title = $instance['title']; |
|
157 | - $view_id = $instance['view_id']; |
|
158 | - $post_id = $instance['post_id']; |
|
159 | - $search_fields = $instance['search_fields']; |
|
160 | - $search_clear = $instance['search_clear']; |
|
161 | - $search_mode = $instance['search_mode']; |
|
156 | + $title = $instance[ 'title' ]; |
|
157 | + $view_id = $instance[ 'view_id' ]; |
|
158 | + $post_id = $instance[ 'post_id' ]; |
|
159 | + $search_fields = $instance[ 'search_fields' ]; |
|
160 | + $search_clear = $instance[ 'search_clear' ]; |
|
161 | + $search_mode = $instance[ 'search_mode' ]; |
|
162 | 162 | |
163 | 163 | $views = GVCommon::get_all_views(); |
164 | 164 | |
165 | 165 | // If there are no views set up yet, we get outta here. |
166 | - if( empty( $views ) ) { ?> |
|
166 | + if ( empty( $views ) ) { ?> |
|
167 | 167 | <div id="select_gravityview_view"> |
168 | 168 | <div class="wrap"><?php echo GravityView_Admin::no_views_text(); ?></div> |
169 | 169 | </div> |
@@ -171,17 +171,17 @@ discard block |
||
171 | 171 | } |
172 | 172 | ?> |
173 | 173 | |
174 | - <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'gravityview'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> |
|
174 | + <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'gravityview' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> |
|
175 | 175 | |
176 | 176 | <?php |
177 | 177 | /** |
178 | 178 | * Display errors generated for invalid embed IDs |
179 | 179 | * @see GravityView_View_Data::is_valid_embed_id |
180 | 180 | */ |
181 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
181 | + if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) { |
|
182 | 182 | ?> |
183 | 183 | <div class="error inline hide-on-view-change"> |
184 | - <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
|
184 | + <p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p> |
|
185 | 185 | </div> |
186 | 186 | <?php |
187 | 187 | unset ( $error ); |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | |
191 | 191 | <p> |
192 | 192 | <label for="gravityview_view_id"><?php _e( 'View:', 'gravityview' ); ?></label> |
193 | - <select id="gravityview_view_id" name="<?php echo $this->get_field_name('view_id'); ?>" class="widefat"> |
|
193 | + <select id="gravityview_view_id" name="<?php echo $this->get_field_name( 'view_id' ); ?>" class="widefat"> |
|
194 | 194 | <option value=""><?php esc_html_e( '— Select a View —', 'gravityview' ); ?></option> |
195 | 195 | <?php |
196 | - foreach( $views as $view_option ) { |
|
197 | - $title = empty( $view_option->post_title ) ? __('(no title)', 'gravityview') : $view_option->post_title; |
|
198 | - echo '<option value="'. $view_option->ID .'" ' . selected( esc_attr( $view_id ), $view_option->ID, false ) . '>'. esc_html( sprintf('%s #%d', $title, $view_option->ID ) ) .'</option>'; |
|
196 | + foreach ( $views as $view_option ) { |
|
197 | + $title = empty( $view_option->post_title ) ? __( '(no title)', 'gravityview' ) : $view_option->post_title; |
|
198 | + echo '<option value="' . $view_option->ID . '" ' . selected( esc_attr( $view_id ), $view_option->ID, false ) . '>' . esc_html( sprintf( '%s #%d', $title, $view_option->ID ) ) . '</option>'; |
|
199 | 199 | } |
200 | 200 | ?> |
201 | 201 | </select> |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | * Display errors generated for invalid embed IDs |
208 | 208 | * @see GravityView_View_Data::is_valid_embed_id |
209 | 209 | */ |
210 | - if( !empty( $instance['error_post_id'] ) ) { |
|
210 | + if ( ! empty( $instance[ 'error_post_id' ] ) ) { |
|
211 | 211 | ?> |
212 | 212 | <div class="error inline"> |
213 | - <p><?php echo $instance['error_post_id']; ?></p> |
|
213 | + <p><?php echo $instance[ 'error_post_id' ]; ?></p> |
|
214 | 214 | </div> |
215 | 215 | <?php |
216 | 216 | unset ( $error ); |
@@ -218,40 +218,40 @@ discard block |
||
218 | 218 | ?> |
219 | 219 | |
220 | 220 | <p> |
221 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
222 | - <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( $post_id ); ?>" /> |
|
221 | + <label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
222 | + <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( $post_id ); ?>" /> |
|
223 | 223 | <span class="howto gv-howto"><?php |
224 | - 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' ); |
|
225 | - echo ' '.gravityview_get_link('https://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
224 | + 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' ); |
|
225 | + echo ' ' . gravityview_get_link( 'https://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
226 | 226 | ?></span> |
227 | 227 | </p> |
228 | 228 | |
229 | 229 | <p> |
230 | - <label for="<?php echo $this->get_field_id('search_clear'); ?>"><?php esc_html_e( 'Show Clear button', 'gravityview' ); ?>:</label> |
|
231 | - <input name="<?php echo $this->get_field_name('search_clear'); ?>" type="hidden" value="0"> |
|
232 | - <input id="<?php echo $this->get_field_id('search_clear'); ?>" name="<?php echo $this->get_field_name('search_clear'); ?>" type="checkbox" class="checkbox" value="1" <?php checked( $search_clear, 1, true ); ?>> |
|
230 | + <label for="<?php echo $this->get_field_id( 'search_clear' ); ?>"><?php esc_html_e( 'Show Clear button', 'gravityview' ); ?>:</label> |
|
231 | + <input name="<?php echo $this->get_field_name( 'search_clear' ); ?>" type="hidden" value="0"> |
|
232 | + <input id="<?php echo $this->get_field_id( 'search_clear' ); ?>" name="<?php echo $this->get_field_name( 'search_clear' ); ?>" type="checkbox" class="checkbox" value="1" <?php checked( $search_clear, 1, true ); ?>> |
|
233 | 233 | </p> |
234 | 234 | |
235 | 235 | <p> |
236 | 236 | <label><?php esc_html_e( 'Search Mode', 'gravityview' ); ?>:</label> |
237 | - <label for="<?php echo $this->get_field_id('search_mode'); ?>_any"> |
|
238 | - <input id="<?php echo $this->get_field_id('search_mode'); ?>_any" name="<?php echo $this->get_field_name('search_mode'); ?>" type="radio" class="radio" value="any" <?php checked( $search_mode, 'any', true ); ?>> |
|
237 | + <label for="<?php echo $this->get_field_id( 'search_mode' ); ?>_any"> |
|
238 | + <input id="<?php echo $this->get_field_id( 'search_mode' ); ?>_any" name="<?php echo $this->get_field_name( 'search_mode' ); ?>" type="radio" class="radio" value="any" <?php checked( $search_mode, 'any', true ); ?>> |
|
239 | 239 | <?php esc_html_e( 'Match Any Fields', 'gravityview' ); ?> |
240 | 240 | </label> |
241 | - <label for="<?php echo $this->get_field_id('search_mode'); ?>_all"> |
|
242 | - <input id="<?php echo $this->get_field_id('search_mode'); ?>_all" name="<?php echo $this->get_field_name('search_mode'); ?>" type="radio" class="radio" value="all" <?php checked( $search_mode, 'all', true ); ?>> |
|
241 | + <label for="<?php echo $this->get_field_id( 'search_mode' ); ?>_all"> |
|
242 | + <input id="<?php echo $this->get_field_id( 'search_mode' ); ?>_all" name="<?php echo $this->get_field_name( 'search_mode' ); ?>" type="radio" class="radio" value="all" <?php checked( $search_mode, 'all', true ); ?>> |
|
243 | 243 | <?php esc_html_e( 'Match All Fields', 'gravityview' ); ?> |
244 | 244 | </label> |
245 | - <span class="howto gv-howto"><?php esc_html_e('Should search results match all search fields, or any?', 'gravityview' ); ?></span |
|
245 | + <span class="howto gv-howto"><?php esc_html_e( 'Should search results match all search fields, or any?', 'gravityview' ); ?></span |
|
246 | 246 | </p> |
247 | 247 | |
248 | 248 | <hr /> |
249 | 249 | |
250 | 250 | <?php // @todo: move style to CSS ?> |
251 | 251 | <div style="margin-bottom: 1em;"> |
252 | - <label class="screen-reader-text" for="<?php echo $this->get_field_id('search_fields'); ?>"><?php _e( 'Searchable fields:', 'gravityview' ); ?></label> |
|
253 | - <div class="gv-widget-search-fields" title="<?php esc_html_e('Search Fields', 'gravityview'); ?>"> |
|
254 | - <input id="<?php echo $this->get_field_id('search_fields'); ?>" name="<?php echo $this->get_field_name('search_fields'); ?>" type="hidden" value="<?php echo esc_attr( $search_fields ); ?>" class="gv-search-fields-value"> |
|
252 | + <label class="screen-reader-text" for="<?php echo $this->get_field_id( 'search_fields' ); ?>"><?php _e( 'Searchable fields:', 'gravityview' ); ?></label> |
|
253 | + <div class="gv-widget-search-fields" title="<?php esc_html_e( 'Search Fields', 'gravityview' ); ?>"> |
|
254 | + <input id="<?php echo $this->get_field_id( 'search_fields' ); ?>" name="<?php echo $this->get_field_name( 'search_fields' ); ?>" type="hidden" value="<?php echo esc_attr( $search_fields ); ?>" class="gv-search-fields-value"> |
|
255 | 255 | </div> |
256 | 256 | |
257 | 257 | </div> |