Conditions | 2 |
Paths | 2 |
Total Lines | 152 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
201 | public function form( $instance ) { |
||
202 | $instance = wp_parse_args( |
||
203 | $instance, |
||
204 | array( 'code' => '' ) |
||
205 | ); |
||
206 | |||
207 | $this->form_sections = array( |
||
208 | array( |
||
209 | 'title' => esc_html__( 'Text Elements', 'jetpack' ), |
||
210 | 'fields' => array( |
||
211 | array( |
||
212 | 'title' => esc_html__( 'Email Placeholder', 'jetpack' ), |
||
213 | 'id' => 'jetpack_mailchimp_email', |
||
214 | 'placeholder' => esc_html__( 'Enter your email', 'jetpack' ), |
||
215 | 'type' => 'text', |
||
216 | ), |
||
217 | ), |
||
218 | ), |
||
219 | |||
220 | array( |
||
221 | 'title' => esc_html__( 'Notifications', 'jetpack' ), |
||
222 | 'fields' => array( |
||
223 | array( |
||
224 | 'title' => esc_html__( 'Processing', 'jetpack' ), |
||
225 | 'id' => 'jetpack_mailchimp_processing_text', |
||
226 | 'placeholder' => esc_html__( 'Processing', 'jetpack' ), |
||
227 | 'type' => 'text', |
||
228 | ), |
||
229 | |||
230 | array( |
||
231 | 'title' => esc_html__( 'Success text', 'jetpack' ), |
||
232 | 'id' => 'jetpack_mailchimp_success_text', |
||
233 | 'placeholder' => esc_html__( 'Success! You\'re on the list.', 'jetpack' ), |
||
234 | 'type' => 'text', |
||
235 | ), |
||
236 | |||
237 | array( |
||
238 | 'title' => esc_html__( 'Error text', 'jetpack' ), |
||
239 | 'id' => 'jetpack_mailchimp_error_text', |
||
240 | 'placeholder' => esc_html__( 'Whoops! There was an error and we couldn\'t process your subscription. Please reload the page and try again.', 'jetpack' ), |
||
241 | 'type' => 'text', |
||
242 | ), |
||
243 | ), |
||
244 | ), |
||
245 | |||
246 | array( |
||
247 | 'title' => esc_html__( 'Mailchimp Groups', 'jetpack' ), |
||
248 | 'fields' => array( |
||
249 | array( |
||
250 | 'type' => 'groups', |
||
251 | ), |
||
252 | ), |
||
253 | ), |
||
254 | |||
255 | array( |
||
256 | 'title' => esc_html__( 'Signup Location Tracking', 'jetpack' ), |
||
257 | 'fields' => array( |
||
258 | array( |
||
259 | 'title' => esc_html__( 'Signup Field Tag', 'jetpack' ), |
||
260 | 'id' => 'jetpack_mailchimp_signup_tag', |
||
261 | 'placeholder' => esc_html__( 'SIGNUP', 'jetpack' ), |
||
262 | 'type' => 'text', |
||
263 | ), |
||
264 | |||
265 | array( |
||
266 | 'title' => esc_html__( 'Signup Field Value', 'jetpack' ), |
||
267 | 'id' => 'jetpack_mailchimp_signup_value', |
||
268 | 'placeholder' => esc_html__( 'website', 'jetpack' ), |
||
269 | 'type' => 'text', |
||
270 | ), |
||
271 | ), |
||
272 | 'extra_content' => array( |
||
273 | 'text' => esc_html__( 'Learn about signup location tracking(opens in a new tab)', 'jetpack' ), |
||
274 | 'link' => 'https://mailchimp.com/help/determine-webpage-signup-location/', |
||
275 | 'type' => 'link', |
||
276 | ), |
||
277 | ), |
||
278 | |||
279 | array( |
||
280 | 'title' => esc_html__( 'Mailchimp Groups', 'jetpack' ), |
||
281 | 'extra_content' => array( |
||
282 | 'text' => esc_html__( 'Manage Connection', 'jetpack' ), |
||
283 | 'link' => 'https://jetpack.com/redirect?source=calypso-marketing-connections&site=[site_url]&query=mailchimp', |
||
284 | 'type' => 'link', |
||
285 | ), |
||
286 | ), |
||
287 | |||
288 | array( |
||
289 | 'title' => esc_html__( 'Button Color Settings', 'jetpack' ), |
||
290 | 'fields' => array( |
||
291 | array( |
||
292 | 'id' => 'jetpack_mailchimp_button_color', |
||
293 | 'type' => 'color', |
||
294 | ), |
||
295 | |||
296 | array( |
||
297 | 'id' => 'jetpack_mailchimp_button_text_color', |
||
298 | 'type' => 'color', |
||
299 | ), |
||
300 | ), |
||
301 | ), |
||
302 | |||
303 | array( |
||
304 | 'title' => esc_html__( 'Advanced', 'jetpack' ), |
||
305 | 'fields' => array( |
||
306 | array( |
||
307 | 'title' => esc_html__( 'Additional CSS class(es)', 'jetpack' ), |
||
308 | 'id' => 'jetpack_mailchimp_css_class', |
||
309 | 'placeholder' => '', |
||
310 | 'help_text' => esc_html__( 'Separate multiple classes with spaces.', 'jetpack' ), |
||
311 | 'type' => 'text', |
||
312 | ), |
||
313 | ), |
||
314 | ), |
||
315 | ); |
||
316 | |||
317 | $this->placeholder_data = array( |
||
318 | 'instructions' => esc_html__( 'You need to connect your Mailchimp account and choose a list in order to start collecting Email subscribers.', 'jetpack' ), |
||
319 | 'setupButtonText' => esc_html__( 'Set up Mailchimp form', 'jetpack' ), |
||
320 | 'recheckText' => esc_html__( 'Re-check Connection', 'jetpack' ), |
||
321 | ); |
||
322 | |||
323 | wp_localize_script( |
||
324 | 'mailchimp-admin', |
||
325 | 'mailchimpAdmin', |
||
326 | array( |
||
327 | 'formSections' => $this->form_sections, |
||
328 | 'placeholderData' => $this->placeholder_data, |
||
329 | ) |
||
330 | ); |
||
331 | |||
332 | if ( empty( $instance['code'] ) ) { |
||
333 | ?> |
||
334 | <div class="mailchimp_widget_jetpack_form_wrapper"></div> |
||
335 | <?php |
||
336 | return; |
||
337 | } |
||
338 | |||
339 | ?> |
||
340 | |||
341 | <p class="mailchimp_code"> |
||
342 | <label for="<?php echo esc_attr( $this->get_field_id( 'code' ) ); ?>"> |
||
343 | <?php printf( __( 'Code: <a href="%s" target="_blank">( ? )</a>', 'jetpack' ), 'https://en.support.wordpress.com/mailchimp/' ); ?> |
||
344 | </label> |
||
345 | <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'code' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'code' ) ); ?>" rows="3"><?php echo esc_textarea( $instance['code'] ); ?></textarea> |
||
346 | </p> |
||
347 | <p> |
||
348 | <input type="checkbox" id="jetpack_mailchimp_new_form" name="<?php echo esc_attr( $this->get_field_name( 'new_form' ) ); ?>" > <?php echo esc_html__( 'Check if you want to use the new form for this widget (the code in the box above will be deleted)', 'jetpack' ); ?> |
||
349 | </p> |
||
350 | <div class="mailchimp_widget_jetpack_form_wrapper"></div> |
||
351 | <?php |
||
352 | } |
||
353 | |||
357 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: