| Conditions | 1 |
| Paths | 1 |
| Total Lines | 83 |
| Code Lines | 70 |
| 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 |
||
| 39 | function add_template( $gallery_templates ) { |
||
| 40 | $gallery_templates[] = array( |
||
| 41 | 'slug' => 'justified', |
||
| 42 | 'name' => __( 'Justified Gallery', 'foogallery' ), |
||
| 43 | 'lazyload_support' => true, |
||
| 44 | 'fields' => array( |
||
| 45 | array( |
||
| 46 | 'id' => 'thumb_height', |
||
| 47 | 'title' => __( 'Thumb Height', 'foogallery' ), |
||
| 48 | 'desc' => __( 'Choose the height of your thumbnails. Thumbnails will be generated on the fly and cached once generated.', 'foogallery' ), |
||
| 49 | 'type' => 'number', |
||
| 50 | 'class' => 'small-text', |
||
| 51 | 'default' => 250, |
||
| 52 | 'step' => '10', |
||
| 53 | 'min' => '0', |
||
| 54 | ), |
||
| 55 | array( |
||
| 56 | 'id' => 'row_height', |
||
| 57 | 'title' => __( 'Row Height', 'foogallery' ), |
||
| 58 | 'desc' => __( 'The preferred height of your gallery rows. This can be different from the thumbnail height.', 'foogallery' ), |
||
| 59 | 'type' => 'number', |
||
| 60 | 'class' => 'small-text', |
||
| 61 | 'default' => 150, |
||
| 62 | 'step' => '10', |
||
| 63 | 'min' => '0', |
||
| 64 | ), |
||
| 65 | array( |
||
| 66 | 'id' => 'max_row_height', |
||
| 67 | 'title' => __( 'Max Row Height', 'foogallery' ), |
||
| 68 | 'desc' => __( 'A number (e.g 200) which specifies the maximum row height in pixels. A negative value for no limits. Alternatively, use a percentage (e.g. 200% which means that the row height cannot exceed 2 * rowHeight)', 'foogallery' ), |
||
| 69 | 'type' => 'text', |
||
| 70 | 'class' => 'small-text', |
||
| 71 | 'default' => '200%' |
||
| 72 | ), |
||
| 73 | array( |
||
| 74 | 'id' => 'margins', |
||
| 75 | 'title' => __( 'Margins', 'foogallery' ), |
||
| 76 | 'desc' => __( 'The spacing between your thumbnails.', 'foogallery' ), |
||
| 77 | 'type' => 'number', |
||
| 78 | 'class' => 'small-text', |
||
| 79 | 'default' => 1, |
||
| 80 | 'step' => '1', |
||
| 81 | 'min' => '0', |
||
| 82 | ), |
||
| 83 | array( |
||
| 84 | 'id' => 'captions', |
||
| 85 | 'title' => __( 'Show Captions', 'foogallery' ), |
||
| 86 | 'desc' => __( 'Show a caption when hovering over your thumbnails. (Set captions by adding either a title or alt text to an attachment)', 'foogallery' ), |
||
| 87 | 'type' => 'checkbox', |
||
| 88 | 'default' => 'on', |
||
| 89 | ), |
||
| 90 | array( |
||
| 91 | 'id' => 'caption_source', |
||
| 92 | 'title' => __( 'Caption Source', 'foogallery' ), |
||
| 93 | 'desc' => __( 'Pull captions from either the attachment Title, Caption or Alt Text.', 'foogallery' ), |
||
| 94 | 'type' => 'radio', |
||
| 95 | 'default' => 'title', |
||
| 96 | 'spacer' => '<span class="spacer"></span>', |
||
| 97 | 'choices' => array( |
||
| 98 | 'title' => __( 'Attachment Title', 'foogallery' ), |
||
| 99 | 'caption' => __( 'Attachment Caption', 'foogallery' ), |
||
| 100 | 'alt' => __( 'Attachment Alt Text', 'foogallery' ) |
||
| 101 | ) |
||
| 102 | ), |
||
| 103 | array( |
||
| 104 | 'id' => 'thumbnail_link', |
||
| 105 | 'title' => __( 'Thumbnail Link', 'foogallery' ), |
||
| 106 | 'default' => 'image' , |
||
| 107 | 'type' => 'thumb_link', |
||
| 108 | 'spacer' => '<span class="spacer"></span>', |
||
| 109 | 'desc' => __( 'You can choose to link each thumbnail to the full size image, or to the image\'s attachment page, or you can choose to not link to anything.', 'foogallery' ), |
||
| 110 | ), |
||
| 111 | array( |
||
| 112 | 'id' => 'lightbox', |
||
| 113 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
| 114 | 'desc' => __( 'Choose which lightbox you want to display images with. The lightbox will only work if you set the thumbnail link to "Full Size Image".', 'foogallery' ), |
||
| 115 | 'type' => 'lightbox', |
||
| 116 | ), |
||
| 117 | ), |
||
| 118 | ); |
||
| 119 | |||
| 120 | return $gallery_templates; |
||
| 121 | } |
||
| 122 | |||
| 172 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.