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