@@ -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"><?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"><?php esc_html_e('Should search results match all search fields, or any?', 'gravityview' ); ?></span |
|
245 | + <span class="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> |