| Conditions | 1 |
| Paths | 1 |
| Total Lines | 284 |
| Code Lines | 157 |
| Lines | 0 |
| Ratio | 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 | function form($instance) |
||
| 300 | { |
||
| 301 | //widgetform in backend |
||
| 302 | $instance = wp_parse_args((array)$instance, array( |
||
| 303 | 'title' => '', |
||
| 304 | 'icon_color' => '#757575', |
||
| 305 | 'title1' => '', |
||
| 306 | 'title2' => '', |
||
| 307 | 'title3' => '', |
||
| 308 | 'title4' => '', |
||
| 309 | 'title5' => '', |
||
| 310 | 'title6' => '', |
||
| 311 | 'title7' => '', |
||
| 312 | 'title8' => '', |
||
| 313 | 'title9' => '', |
||
| 314 | 'title10' => '', |
||
| 315 | 'title11' => '', |
||
| 316 | 'title12' => '', |
||
| 317 | 'image1' => '', |
||
| 318 | 'image2' => '', |
||
| 319 | 'image3' => '', |
||
| 320 | 'image4' => '', |
||
| 321 | 'image5' => '', |
||
| 322 | 'image6' => '', |
||
| 323 | 'image7' => '', |
||
| 324 | 'image8' => '', |
||
| 325 | 'image9' => '', |
||
| 326 | 'image10' => '', |
||
| 327 | 'image11' => '', |
||
| 328 | 'image12' => '', |
||
| 329 | 'desc1' => '', |
||
| 330 | 'desc2' => '', |
||
| 331 | 'desc3' => '', |
||
| 332 | 'desc4' => '', |
||
| 333 | 'desc5' => '', |
||
| 334 | 'desc6' => '', |
||
| 335 | 'desc7' => '', |
||
| 336 | 'desc8' => '', |
||
| 337 | 'desc9' => '', |
||
| 338 | 'desc10' => '', |
||
| 339 | 'desc11' => '', |
||
| 340 | 'desc12' => '', |
||
| 341 | )); |
||
| 342 | $title = strip_tags($instance['title']); |
||
| 343 | $icon_color = strip_tags($instance['icon_color']); |
||
| 344 | |||
| 345 | $title1 = strip_tags($instance['title1']); |
||
| 346 | $title2 = strip_tags($instance['title2']); |
||
| 347 | $title3 = strip_tags($instance['title3']); |
||
| 348 | $title4 = strip_tags($instance['title4']); |
||
| 349 | $title5 = strip_tags($instance['title5']); |
||
| 350 | $title6 = strip_tags($instance['title6']); |
||
| 351 | $title7 = strip_tags($instance['title7']); |
||
| 352 | $title8 = strip_tags($instance['title8']); |
||
| 353 | $title9 = strip_tags($instance['title9']); |
||
| 354 | $title10 = strip_tags($instance['title10']); |
||
| 355 | $title11 = strip_tags($instance['title11']); |
||
| 356 | $title12 = strip_tags($instance['title12']); |
||
| 357 | |||
| 358 | $image1 = strip_tags($instance['image1']); |
||
| 359 | $image2 = strip_tags($instance['image2']); |
||
| 360 | $image3 = strip_tags($instance['image3']); |
||
| 361 | $image4 = strip_tags($instance['image4']); |
||
| 362 | $image5 = strip_tags($instance['image5']); |
||
| 363 | $image6 = strip_tags($instance['image6']); |
||
| 364 | $image7 = strip_tags($instance['image7']); |
||
| 365 | $image8 = strip_tags($instance['image8']); |
||
| 366 | $image9 = strip_tags($instance['image9']); |
||
| 367 | $image10 = strip_tags($instance['image10']); |
||
| 368 | $image11 = strip_tags($instance['image11']); |
||
| 369 | $image12 = strip_tags($instance['image12']); |
||
| 370 | |||
| 371 | $desc1 = strip_tags($instance['desc1']); |
||
| 372 | $desc2 = strip_tags($instance['desc2']); |
||
| 373 | $desc3 = strip_tags($instance['desc3']); |
||
| 374 | $desc4 = strip_tags($instance['desc4']); |
||
| 375 | $desc5 = strip_tags($instance['desc5']); |
||
| 376 | $desc6 = strip_tags($instance['desc6']); |
||
| 377 | $desc7 = strip_tags($instance['desc7']); |
||
| 378 | $desc8 = strip_tags($instance['desc8']); |
||
| 379 | $desc9 = strip_tags($instance['desc9']); |
||
| 380 | $desc10 = strip_tags($instance['desc10']); |
||
| 381 | $desc11 = strip_tags($instance['desc11']); |
||
| 382 | $desc12 = strip_tags($instance['desc12']); |
||
| 383 | ?> |
||
| 384 | <p> |
||
| 385 | <b>Heads Up!</b> If you don't have enough content, You can keep some boxes blank. |
||
| 386 | </p> |
||
| 387 | <p> |
||
| 388 | For font awesome icons refer <a href="https://fortawesome.github.io/Font-Awesome/icons/" target="_blank">this page</a>. You must enter "icon class" if you are planning to use font awesome icons. |
||
| 389 | For example if you planning to use "recycle" icon as your image, then you have to enter "fa-recycle" as class name which you can find in <a href="http://fortawesome.github.io/Font-Awesome/icon/recycle/" target="_blank">this page</a> |
||
| 390 | </p> |
||
| 391 | |||
| 392 | <p> |
||
| 393 | <label><?php echo __("Widget Title (Optional):", 'geodirectory'); ?></label> |
||
| 394 | <input name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" class="widefat"/> |
||
| 395 | </p> |
||
| 396 | |||
| 397 | <p> |
||
| 398 | <label><?php echo __("Font Awesome Icon Color:", 'geodirectory'); ?></label> |
||
| 399 | <input name="<?php echo $this->get_field_name('icon_color'); ?>" type="text" value="<?php echo esc_attr($icon_color); ?>" class="widefat"/> |
||
| 400 | </p> |
||
| 401 | |||
| 402 | <p class="features-title"> |
||
| 403 | <label><?php echo __( 'Title 1:', 'geodirectory' ); ?></label> |
||
| 404 | <input name="<?php echo $this->get_field_name( 'title1' ); ?>" type="text" value="<?php echo esc_attr($title1); ?>" class="widefat" /> |
||
| 405 | </p> |
||
| 406 | |||
| 407 | <p class="features-image"> |
||
| 408 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 409 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image1' ); ?>" value="<?php echo esc_attr($image1); ?>" /> |
||
| 410 | </p> |
||
| 411 | |||
| 412 | <p class="features-desc"> |
||
| 413 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 414 | <textarea name="<?php echo $this->get_field_name( 'desc1' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc1); ?></textarea> |
||
| 415 | </p> |
||
| 416 | |||
| 417 | <p class="features-title"> |
||
| 418 | <label><?php echo __( 'Title 2:', 'geodirectory' ); ?></label> |
||
| 419 | <input name="<?php echo $this->get_field_name( 'title2' ); ?>" type="text" value="<?php echo esc_attr($title2); ?>" class="widefat" /> |
||
| 420 | </p> |
||
| 421 | |||
| 422 | <p class="features-image"> |
||
| 423 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 424 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image2' ); ?>" value="<?php echo esc_attr($image2); ?>" /> |
||
| 425 | </p> |
||
| 426 | |||
| 427 | <p class="features-desc"> |
||
| 428 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 429 | <textarea name="<?php echo $this->get_field_name( 'desc2' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc2); ?></textarea> |
||
| 430 | </p> |
||
| 431 | |||
| 432 | <p class="features-title"> |
||
| 433 | <label><?php echo __( 'Title 3:', 'geodirectory' ); ?></label> |
||
| 434 | <input name="<?php echo $this->get_field_name( 'title3' ); ?>" type="text" value="<?php echo esc_attr($title3); ?>" class="widefat" /> |
||
| 435 | </p> |
||
| 436 | |||
| 437 | <p class="features-image"> |
||
| 438 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 439 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image3' ); ?>" value="<?php echo esc_attr($image3); ?>" /> |
||
| 440 | </p> |
||
| 441 | |||
| 442 | <p class="features-desc"> |
||
| 443 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 444 | <textarea name="<?php echo $this->get_field_name( 'desc3' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc3); ?></textarea> |
||
| 445 | </p> |
||
| 446 | |||
| 447 | <p class="features-title"> |
||
| 448 | <label><?php echo __( 'Title 4:', 'geodirectory' ); ?></label> |
||
| 449 | <input name="<?php echo $this->get_field_name( 'title4' ); ?>" type="text" value="<?php echo esc_attr($title4); ?>" class="widefat" /> |
||
| 450 | </p> |
||
| 451 | |||
| 452 | <p class="features-image"> |
||
| 453 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 454 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image4' ); ?>" value="<?php echo esc_attr($image4); ?>" /> |
||
| 455 | </p> |
||
| 456 | |||
| 457 | <p class="features-desc"> |
||
| 458 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 459 | <textarea name="<?php echo $this->get_field_name( 'desc4' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc4); ?></textarea> |
||
| 460 | </p> |
||
| 461 | |||
| 462 | <p class="features-title"> |
||
| 463 | <label><?php echo __( 'Title 5:', 'geodirectory' ); ?></label> |
||
| 464 | <input name="<?php echo $this->get_field_name( 'title5' ); ?>" type="text" value="<?php echo esc_attr($title5); ?>" class="widefat" /> |
||
| 465 | </p> |
||
| 466 | |||
| 467 | <p class="features-image"> |
||
| 468 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 469 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image5' ); ?>" value="<?php echo esc_attr($image5); ?>" /> |
||
| 470 | </p> |
||
| 471 | |||
| 472 | <p class="features-desc"> |
||
| 473 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 474 | <textarea name="<?php echo $this->get_field_name( 'desc5' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc5); ?></textarea> |
||
| 475 | </p> |
||
| 476 | |||
| 477 | <p class="features-title"> |
||
| 478 | <label><?php echo __( 'Title 6:', 'geodirectory' ); ?></label> |
||
| 479 | <input name="<?php echo $this->get_field_name( 'title6' ); ?>" type="text" value="<?php echo esc_attr($title6); ?>" class="widefat" /> |
||
| 480 | </p> |
||
| 481 | |||
| 482 | <p class="features-image"> |
||
| 483 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 484 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image6' ); ?>" value="<?php echo esc_attr($image6); ?>" /> |
||
| 485 | </p> |
||
| 486 | |||
| 487 | <p class="features-desc"> |
||
| 488 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 489 | <textarea name="<?php echo $this->get_field_name( 'desc6' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc6); ?></textarea> |
||
| 490 | </p> |
||
| 491 | |||
| 492 | <p class="features-title"> |
||
| 493 | <label><?php echo __( 'Title 7:', 'geodirectory' ); ?></label> |
||
| 494 | <input name="<?php echo $this->get_field_name( 'title7' ); ?>" type="text" value="<?php echo esc_attr($title7); ?>" class="widefat" /> |
||
| 495 | </p> |
||
| 496 | |||
| 497 | <p class="features-image"> |
||
| 498 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 499 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image7' ); ?>" value="<?php echo esc_attr($image7); ?>" /> |
||
| 500 | </p> |
||
| 501 | |||
| 502 | <p class="features-desc"> |
||
| 503 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 504 | <textarea name="<?php echo $this->get_field_name( 'desc7' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc7); ?></textarea> |
||
| 505 | </p> |
||
| 506 | |||
| 507 | <p class="features-title"> |
||
| 508 | <label><?php echo __( 'Title 8:', 'geodirectory' ); ?></label> |
||
| 509 | <input name="<?php echo $this->get_field_name( 'title8' ); ?>" type="text" value="<?php echo esc_attr($title8); ?>" class="widefat" /> |
||
| 510 | </p> |
||
| 511 | |||
| 512 | <p class="features-image"> |
||
| 513 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 514 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image8' ); ?>" value="<?php echo esc_attr($image8); ?>" /> |
||
| 515 | </p> |
||
| 516 | |||
| 517 | <p class="features-desc"> |
||
| 518 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 519 | <textarea name="<?php echo $this->get_field_name( 'desc8' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc8); ?></textarea> |
||
| 520 | </p> |
||
| 521 | |||
| 522 | <p class="features-title"> |
||
| 523 | <label><?php echo __( 'Title 9:', 'geodirectory' ); ?></label> |
||
| 524 | <input name="<?php echo $this->get_field_name( 'title9' ); ?>" type="text" value="<?php echo esc_attr($title9); ?>" class="widefat" /> |
||
| 525 | </p> |
||
| 526 | |||
| 527 | <p class="features-image"> |
||
| 528 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 529 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image9' ); ?>" value="<?php echo esc_attr($image9); ?>" /> |
||
| 530 | </p> |
||
| 531 | |||
| 532 | <p class="features-desc"> |
||
| 533 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 534 | <textarea name="<?php echo $this->get_field_name( 'desc9' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc9); ?></textarea> |
||
| 535 | </p> |
||
| 536 | |||
| 537 | <p class="features-title"> |
||
| 538 | <label><?php echo __( 'Title 10:', 'geodirectory' ); ?></label> |
||
| 539 | <input name="<?php echo $this->get_field_name( 'title10' ); ?>" type="text" value="<?php echo esc_attr($title10); ?>" class="widefat" /> |
||
| 540 | </p> |
||
| 541 | |||
| 542 | <p class="features-image"> |
||
| 543 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 544 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image10' ); ?>" value="<?php echo esc_attr($image10); ?>" /> |
||
| 545 | </p> |
||
| 546 | |||
| 547 | <p class="features-desc"> |
||
| 548 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 549 | <textarea name="<?php echo $this->get_field_name( 'desc10' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc10); ?></textarea> |
||
| 550 | </p> |
||
| 551 | |||
| 552 | <p class="features-title"> |
||
| 553 | <label><?php echo __( 'Title 11:', 'geodirectory' ); ?></label> |
||
| 554 | <input name="<?php echo $this->get_field_name( 'title11' ); ?>" type="text" value="<?php echo esc_attr($title11); ?>" class="widefat" /> |
||
| 555 | </p> |
||
| 556 | |||
| 557 | <p class="features-image"> |
||
| 558 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 559 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image11' ); ?>" value="<?php echo esc_attr($image11); ?>" /> |
||
| 560 | </p> |
||
| 561 | |||
| 562 | <p class="features-desc"> |
||
| 563 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 564 | <textarea name="<?php echo $this->get_field_name( 'desc11' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc11); ?></textarea> |
||
| 565 | </p> |
||
| 566 | |||
| 567 | <p class="features-title"> |
||
| 568 | <label><?php echo __( 'Title 12:', 'geodirectory' ); ?></label> |
||
| 569 | <input name="<?php echo $this->get_field_name( 'title12' ); ?>" type="text" value="<?php echo esc_attr($title12); ?>" class="widefat" /> |
||
| 570 | </p> |
||
| 571 | |||
| 572 | <p class="features-image"> |
||
| 573 | <label><?php echo __( 'Image URL:', 'geodirectory' ); ?></label> |
||
| 574 | <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'image12' ); ?>" value="<?php echo esc_attr($image12); ?>" /> |
||
| 575 | </p> |
||
| 576 | |||
| 577 | <p class="features-desc"> |
||
| 578 | <label><?php echo __( 'Description:', 'geodirectory' ); ?></label> |
||
| 579 | <textarea name="<?php echo $this->get_field_name( 'desc12' ); ?>" rows="3" class="widefat"><?php echo esc_attr($desc12); ?></textarea> |
||
| 580 | </p> |
||
| 581 | <?php |
||
| 582 | } |
||
| 583 | |||
| 600 | } |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.