| Conditions | 2 |
| Paths | 2 |
| Total Lines | 190 |
| 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 |
||
| 299 | public function form( $instance ) { |
||
| 300 | $defaults = array( |
||
| 301 | 'title' => esc_html__( 'Follow me on Twitter', 'jetpack' ), |
||
| 302 | 'width' => '', |
||
| 303 | 'height' => '400', |
||
| 304 | 'type' => 'profile', |
||
| 305 | 'widget-id' => '', |
||
| 306 | 'link-color' => '#f96e5b', |
||
| 307 | 'border-color' => '#e8e8e8', |
||
| 308 | 'theme' => 'light', |
||
| 309 | 'chrome' => array(), |
||
| 310 | 'tweet-limit' => null, |
||
| 311 | ); |
||
| 312 | |||
| 313 | $instance = wp_parse_args( (array) $instance, $defaults ); |
||
| 314 | |||
| 315 | if ( 'widget-id' === $instance['type'] ) { |
||
| 316 | $instance['widget-id'] = ''; |
||
| 317 | } |
||
| 318 | |||
| 319 | $instance['type'] = 'profile'; |
||
| 320 | ?> |
||
| 321 | |||
| 322 | <p> |
||
| 323 | <label for="<?php echo $this->get_field_id( 'title' ); ?>"> |
||
| 324 | <?php esc_html_e( 'Title:', 'jetpack' ); ?> |
||
| 325 | </label> |
||
| 326 | <input |
||
| 327 | class="widefat" |
||
| 328 | id="<?php echo $this->get_field_id( 'title' ); ?>" |
||
| 329 | name="<?php echo $this->get_field_name( 'title' ); ?>" |
||
| 330 | type="text" |
||
| 331 | value="<?php echo esc_attr( $instance['title'] ); ?>" |
||
| 332 | /> |
||
| 333 | </p> |
||
| 334 | |||
| 335 | <p> |
||
| 336 | <label for="<?php echo $this->get_field_id( 'width' ); ?>"> |
||
| 337 | <?php esc_html_e( 'Maximum Width (px; 220 to 1200):', 'jetpack' ); ?> |
||
| 338 | </label> |
||
| 339 | <input |
||
| 340 | class="widefat" |
||
| 341 | id="<?php echo $this->get_field_id( 'width' ); ?>" |
||
| 342 | name="<?php echo $this->get_field_name( 'width' ); ?>" |
||
| 343 | type="number" min="220" max="1200" |
||
| 344 | value="<?php echo esc_attr( $instance['width'] ); ?>" |
||
| 345 | /> |
||
| 346 | </p> |
||
| 347 | |||
| 348 | <p> |
||
| 349 | <label for="<?php echo $this->get_field_id( 'height' ); ?>"> |
||
| 350 | <?php esc_html_e( 'Height (px; at least 200):', 'jetpack' ); ?> |
||
| 351 | </label> |
||
| 352 | <input |
||
| 353 | class="widefat" |
||
| 354 | id="<?php echo $this->get_field_id( 'height' ); ?>" |
||
| 355 | name="<?php echo $this->get_field_name( 'height' ); ?>" |
||
| 356 | type="number" min="200" |
||
| 357 | value="<?php echo esc_attr( $instance['height'] ); ?>" |
||
| 358 | /> |
||
| 359 | </p> |
||
| 360 | |||
| 361 | <p> |
||
| 362 | <label for="<?php echo $this->get_field_id( 'tweet-limit' ); ?>"> |
||
| 363 | <?php esc_html_e( '# of Tweets Shown (1 to 20):', 'jetpack' ); ?> |
||
| 364 | </label> |
||
| 365 | <input |
||
| 366 | class="widefat" |
||
| 367 | id="<?php echo $this->get_field_id( 'tweet-limit' ); ?>" |
||
| 368 | name="<?php echo $this->get_field_name( 'tweet-limit' ); ?>" |
||
| 369 | type="number" min="1" max="20" |
||
| 370 | value="<?php echo esc_attr( $instance['tweet-limit'] ); ?>" |
||
| 371 | /> |
||
| 372 | </p> |
||
| 373 | |||
| 374 | <p class="jetpack-twitter-timeline-widget-id-container"> |
||
| 375 | <label for="<?php echo $this->get_field_id( 'widget-id' ); ?>"> |
||
| 376 | <?php esc_html_e( 'Twitter Username:', 'jetpack' ); ?> |
||
| 377 | <?php echo $this->get_docs_link( '#twitter-username' ); ?> |
||
| 378 | </label> |
||
| 379 | <input |
||
| 380 | class="widefat" |
||
| 381 | id="<?php echo $this->get_field_id( 'widget-id' ); ?>" |
||
| 382 | name="<?php echo $this->get_field_name( 'widget-id' ); ?>" |
||
| 383 | type="text" |
||
| 384 | value="<?php echo esc_attr( $instance['widget-id'] ); ?>" |
||
| 385 | /> |
||
| 386 | </p> |
||
| 387 | |||
| 388 | <p> |
||
| 389 | <label for="<?php echo $this->get_field_id( 'chrome-noheader' ); ?>"> |
||
| 390 | <?php esc_html_e( 'Layout Options:', 'jetpack' ); ?> |
||
| 391 | </label> |
||
| 392 | <br /> |
||
| 393 | <input |
||
| 394 | type="checkbox"<?php checked( in_array( 'noheader', $instance['chrome'] ) ); ?> |
||
| 395 | id="<?php echo $this->get_field_id( 'chrome-noheader' ); ?>" |
||
| 396 | name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" |
||
| 397 | value="noheader" |
||
| 398 | /> |
||
| 399 | <label for="<?php echo $this->get_field_id( 'chrome-noheader' ); ?>"> |
||
| 400 | <?php esc_html_e( 'No Header', 'jetpack' ); ?> |
||
| 401 | </label> |
||
| 402 | <br /> |
||
| 403 | <input |
||
| 404 | type="checkbox"<?php checked( in_array( 'nofooter', $instance['chrome'] ) ); ?> |
||
| 405 | id="<?php echo $this->get_field_id( 'chrome-nofooter' ); ?>" |
||
| 406 | name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" |
||
| 407 | value="nofooter" |
||
| 408 | /> |
||
| 409 | <label for="<?php echo $this->get_field_id( 'chrome-nofooter' ); ?>"> |
||
| 410 | <?php esc_html_e( 'No Footer', 'jetpack' ); ?> |
||
| 411 | </label> |
||
| 412 | <br /> |
||
| 413 | <input |
||
| 414 | type="checkbox"<?php checked( in_array( 'noborders', $instance['chrome'] ) ); ?> |
||
| 415 | id="<?php echo $this->get_field_id( 'chrome-noborders' ); ?>" |
||
| 416 | name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" |
||
| 417 | value="noborders" |
||
| 418 | /> |
||
| 419 | <label for="<?php echo $this->get_field_id( 'chrome-noborders' ); ?>"> |
||
| 420 | <?php esc_html_e( 'No Borders', 'jetpack' ); ?> |
||
| 421 | </label> |
||
| 422 | <br /> |
||
| 423 | <input |
||
| 424 | type="checkbox"<?php checked( in_array( 'noscrollbar', $instance['chrome'] ) ); ?> |
||
| 425 | id="<?php echo $this->get_field_id( 'chrome-noscrollbar' ); ?>" |
||
| 426 | name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" |
||
| 427 | value="noscrollbar" |
||
| 428 | /> |
||
| 429 | <label for="<?php echo $this->get_field_id( 'chrome-noscrollbar' ); ?>"> |
||
| 430 | <?php esc_html_e( 'No Scrollbar', 'jetpack' ); ?> |
||
| 431 | </label> |
||
| 432 | <br /> |
||
| 433 | <input |
||
| 434 | type="checkbox"<?php checked( in_array( 'transparent', $instance['chrome'] ) ); ?> |
||
| 435 | id="<?php echo $this->get_field_id( 'chrome-transparent' ); ?>" |
||
| 436 | name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" |
||
| 437 | value="transparent" |
||
| 438 | /> |
||
| 439 | <label for="<?php echo $this->get_field_id( 'chrome-transparent' ); ?>"> |
||
| 440 | <?php esc_html_e( 'Transparent Background', 'jetpack' ); ?> |
||
| 441 | </label> |
||
| 442 | </p> |
||
| 443 | |||
| 444 | <p> |
||
| 445 | <label for="<?php echo $this->get_field_id( 'link-color' ); ?>"> |
||
| 446 | <?php _e( 'Link Color (hex):', 'jetpack' ); ?> |
||
| 447 | </label> |
||
| 448 | <input |
||
| 449 | class="widefat" |
||
| 450 | id="<?php echo $this->get_field_id( 'link-color' ); ?>" |
||
| 451 | name="<?php echo $this->get_field_name( 'link-color' ); ?>" |
||
| 452 | type="text" |
||
| 453 | value="<?php echo esc_attr( $instance['link-color'] ); ?>" |
||
| 454 | /> |
||
| 455 | </p> |
||
| 456 | |||
| 457 | <p> |
||
| 458 | <label for="<?php echo $this->get_field_id( 'border-color' ); ?>"> |
||
| 459 | <?php _e( 'Border Color (hex):', 'jetpack' ); ?> |
||
| 460 | </label> |
||
| 461 | <input |
||
| 462 | class="widefat" |
||
| 463 | id="<?php echo $this->get_field_id( 'border-color' ); ?>" |
||
| 464 | name="<?php echo $this->get_field_name( 'border-color' ); ?>" |
||
| 465 | type="text" |
||
| 466 | value="<?php echo esc_attr( $instance['border-color'] ); ?>" |
||
| 467 | /> |
||
| 468 | </p> |
||
| 469 | |||
| 470 | <p> |
||
| 471 | <label for="<?php echo $this->get_field_id( 'theme' ); ?>"> |
||
| 472 | <?php _e( 'Timeline Theme:', 'jetpack' ); ?> |
||
| 473 | </label> |
||
| 474 | <select |
||
| 475 | name="<?php echo $this->get_field_name( 'theme' ); ?>" |
||
| 476 | id="<?php echo $this->get_field_id( 'theme' ); ?>" |
||
| 477 | class="widefat" |
||
| 478 | > |
||
| 479 | <option value="light"<?php selected( $instance['theme'], 'light' ); ?>> |
||
| 480 | <?php esc_html_e( 'Light', 'jetpack' ); ?> |
||
| 481 | </option> |
||
| 482 | <option value="dark"<?php selected( $instance['theme'], 'dark' ); ?>> |
||
| 483 | <?php esc_html_e( 'Dark', 'jetpack' ); ?> |
||
| 484 | </option> |
||
| 485 | </select> |
||
| 486 | </p> |
||
| 487 | <?php |
||
| 488 | } |
||
| 489 | } |
||
| 490 |