Conditions | 1 |
Paths | 1 |
Total Lines | 89 |
Code Lines | 75 |
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 |
||
35 | function add_template( $gallery_templates ) { |
||
36 | $gallery_templates[] = array( |
||
37 | 'slug' => 'justified', |
||
38 | 'name' => __( 'Justified Gallery', 'foogallery' ), |
||
39 | 'fields' => array( |
||
40 | array( |
||
41 | 'id' => 'help', |
||
42 | 'title' => __( 'Tip', 'foogallery' ), |
||
43 | 'type' => 'html', |
||
44 | 'help' => true, |
||
45 | 'desc' => __( 'The Justified Gallery template uses the popular <a href="http://miromannino.com/projects/justified-gallery/" target="_blank">Justified Gallery jQuery Plugin</a> under the hood. You can specify thumbnail captions by setting the alt text for your attachments.', 'foogallery' ), |
||
46 | ), |
||
47 | array( |
||
48 | 'id' => 'thumb_height', |
||
49 | 'title' => __( 'Thumb Height', 'foogallery' ), |
||
50 | 'desc' => __( 'Choose the height of your thumbnails. Thumbnails will be generated on the fly and cached once generated.', 'foogallery' ), |
||
51 | 'type' => 'number', |
||
52 | 'class' => 'small-text', |
||
53 | 'default' => 250, |
||
54 | 'step' => '10', |
||
55 | 'min' => '0', |
||
56 | ), |
||
57 | array( |
||
58 | 'id' => 'row_height', |
||
59 | 'title' => __( 'Row Height', 'foogallery' ), |
||
60 | 'desc' => __( 'The preferred height of your gallery rows. This can be different from the thumbnail height.', 'foogallery' ), |
||
61 | 'type' => 'number', |
||
62 | 'class' => 'small-text', |
||
63 | 'default' => 150, |
||
64 | 'step' => '10', |
||
65 | 'min' => '0', |
||
66 | ), |
||
67 | array( |
||
68 | 'id' => 'max_row_height', |
||
69 | 'title' => __( 'Max Row Height', 'foogallery' ), |
||
70 | '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' ), |
||
71 | 'type' => 'text', |
||
72 | 'class' => 'small-text', |
||
73 | 'default' => '200%' |
||
74 | ), |
||
75 | array( |
||
76 | 'id' => 'margins', |
||
77 | 'title' => __( 'Margins', 'foogallery' ), |
||
78 | 'desc' => __( 'The spacing between your thumbnails.', 'foogallery' ), |
||
79 | 'type' => 'number', |
||
80 | 'class' => 'small-text', |
||
81 | 'default' => 1, |
||
82 | 'step' => '1', |
||
83 | 'min' => '0', |
||
84 | ), |
||
85 | array( |
||
86 | 'id' => 'captions', |
||
87 | 'title' => __( 'Show Captions', 'foogallery' ), |
||
88 | 'desc' => __( 'Show a caption when hovering over your thumbnails. (Set captions by adding either a title or alt text to an attachment)', 'foogallery' ), |
||
89 | 'type' => 'checkbox', |
||
90 | 'default' => 'on', |
||
91 | ), |
||
92 | array( |
||
93 | 'id' => 'caption_source', |
||
94 | 'title' => __( 'Caption Source', 'foogallery' ), |
||
95 | 'desc' => __( 'Pull captions from either the attachment Title, Caption or Alt Text.', 'foogallery' ), |
||
96 | 'type' => 'radio', |
||
97 | 'default' => 'title', |
||
98 | 'spacer' => '<span class="spacer"></span>', |
||
99 | 'choices' => array( |
||
100 | 'title' => __( 'Attachment Title', 'foogallery' ), |
||
101 | 'caption' => __( 'Attachment Caption', 'foogallery' ), |
||
102 | 'alt' => __( 'Attachment Alt Text', 'foogallery' ) |
||
103 | ) |
||
104 | ), |
||
105 | array( |
||
106 | 'id' => 'thumbnail_link', |
||
107 | 'title' => __( 'Thumbnail Link', 'foogallery' ), |
||
108 | 'default' => 'image' , |
||
109 | 'type' => 'thumb_link', |
||
110 | 'spacer' => '<span class="spacer"></span>', |
||
111 | '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' ), |
||
112 | ), |
||
113 | array( |
||
114 | 'id' => 'lightbox', |
||
115 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
116 | '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' ), |
||
117 | 'type' => 'lightbox', |
||
118 | ), |
||
119 | ), |
||
120 | ); |
||
121 | |||
122 | return $gallery_templates; |
||
123 | } |
||
124 | |||
142 | } |
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.