Conditions | 1 |
Paths | 1 |
Total Lines | 183 |
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 |
||
28 | function foogallery_album_templates() { |
||
29 | $album_templates[] = array( |
||
30 | 'slug' => 'default', |
||
31 | 'name' => __( 'Responsive Album Layout', 'foogallery' ), |
||
32 | 'fields' => array( |
||
33 | array( |
||
34 | 'id' => 'thumbnail_dimensions', |
||
35 | 'title' => __( 'Thumbnail Size', 'foogallery' ), |
||
36 | 'desc' => __( 'Choose the size of your gallery thumbnails.', 'foogallery' ), |
||
37 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
38 | 'type' => 'thumb_size', |
||
39 | 'default' => array( |
||
40 | 'width' => get_option( 'thumbnail_size_w' ), |
||
41 | 'height' => get_option( 'thumbnail_size_h' ), |
||
42 | 'crop' => true, |
||
43 | ), |
||
44 | ), |
||
45 | array( |
||
46 | 'id' => 'title_bg', |
||
47 | 'title' => __( 'Title Background Color', 'foogallery' ), |
||
48 | 'desc' => __( 'The color of the title that overlays the album thumbnails', 'foogallery' ), |
||
49 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
50 | 'type' => 'colorpicker', |
||
51 | 'default' => '#fff' |
||
52 | ), |
||
53 | array( |
||
54 | 'id' => 'title_font_color', |
||
55 | 'title' => __( 'Title Text Color', 'foogallery' ), |
||
56 | 'desc' => __( 'The color of the title text that overlays the album thumbnails', 'foogallery' ), |
||
57 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
58 | 'type' => 'colorpicker', |
||
59 | 'default' => '#000000' |
||
60 | ), |
||
61 | array( |
||
62 | 'id' => 'alignment', |
||
63 | 'title' => __( 'Alignment', 'foogallery' ), |
||
64 | 'desc' => __( 'The horizontal alignment of the gallery thumbnails inside the album.', 'foogallery' ), |
||
65 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
66 | 'default' => 'alignment-left', |
||
67 | 'type' => 'select', |
||
68 | 'choices' => array( |
||
69 | 'alignment-left' => __( 'Left', 'foogallery' ), |
||
70 | 'alignment-center' => __( 'Center', 'foogallery' ), |
||
71 | 'alignment-right' => __( 'Right', 'foogallery' ), |
||
72 | ) |
||
73 | ), |
||
74 | array( |
||
75 | 'id' => 'gallery_link', |
||
76 | 'title' => __( 'Gallery Link', 'foogallery' ), |
||
77 | 'section' => __( 'URL Settings', 'foogallery' ), |
||
78 | 'default' => '', |
||
79 | 'type' => 'radio', |
||
80 | 'spacer' => '<span class="spacer"></span>', |
||
81 | 'choices' => array( |
||
82 | '' => __('Default', 'foogallery'), |
||
83 | 'custom_url' => __('Custom URL', 'foogallery') |
||
84 | ), |
||
85 | 'desc' => __( 'You can choose to link each gallery to the default embedded gallery, or you can choose to link to the gallery custom URL (if set).', 'foogallery' ), |
||
86 | ), |
||
87 | array( |
||
88 | 'id' => 'gallery_link_format', |
||
89 | 'title' => __( 'Gallery Link Format', 'foogallery' ), |
||
90 | 'desc' => __( 'The format of the URL for each individual gallery in the album.', 'foogallery' ), |
||
91 | 'section' => __( 'URL Settings', 'foogallery' ), |
||
92 | 'type' => 'radio', |
||
93 | 'choices' => array( |
||
94 | 'default' => __('Pretty, e.g. ', 'foogallery') . '<code>/page-with-album/' . foogallery_album_gallery_url_slug() . '/some-gallery</code>', |
||
95 | 'querystring' => __('Querystring e.g. ', 'foogallery') . '<code>/page-with-album?' . foogallery_album_gallery_url_slug() . '=some-gallery</code>' |
||
96 | ), |
||
97 | 'default' => foogallery_determine_best_link_format_default() |
||
98 | ), |
||
99 | array( |
||
100 | 'id' => 'url_help', |
||
101 | 'title' => __( 'Please Note', 'foogallery' ), |
||
102 | 'section' => __( 'URL Settings', 'foogallery' ), |
||
103 | 'type' => 'help', |
||
104 | 'help' => true, |
||
105 | 'desc' => __( 'If you are getting 404\'s when clicking on the album galleries, then change to the querystring format. To force your rewrite rules to flush, simply deactivate and activate the albums extension again.', 'foogallery' ), |
||
106 | ), |
||
107 | array( |
||
108 | 'id' => 'album_hash', |
||
109 | 'title' => __( 'Remember Scroll Position', 'foogallery' ), |
||
110 | 'desc' => __( 'When a gallery is loaded in your album, the page is refreshed which means the scroll position will be lost .', 'foogallery' ), |
||
111 | 'section' => __( 'URL Settings', 'foogallery' ), |
||
112 | 'type' => 'radio', |
||
113 | 'choices' => array( |
||
114 | 'none' => __('Don\'t Remember', 'foogallery'), |
||
115 | 'remember' => __('Remember Scroll Position', 'foogallery') |
||
116 | ), |
||
117 | 'default' => 'none' |
||
118 | ), |
||
119 | array( |
||
120 | 'id' => 'gallery_title_size', |
||
121 | 'title' => __( 'Gallery Title Size', 'foogallery' ), |
||
122 | 'desc' => __( 'The size of the title when displaying a gallery page.', 'foogallery' ), |
||
123 | 'section' => __( 'Gallery Settings', 'foogallery' ), |
||
124 | 'default' => 'h2', |
||
125 | 'type' => 'select', |
||
126 | 'choices' => array( |
||
127 | 'h2' => __( 'H2', 'foogallery' ), |
||
128 | 'h3' => __( 'H3', 'foogallery' ), |
||
129 | 'h4' => __( 'H4', 'foogallery' ), |
||
130 | 'h5' => __( 'H5', 'foogallery' ), |
||
131 | 'h6' => __( 'H6', 'foogallery' ), |
||
132 | ) |
||
133 | ), |
||
134 | ) |
||
135 | ); |
||
136 | |||
137 | $album_templates[] = array( |
||
138 | 'slug' => 'stack', |
||
139 | 'name' => __( 'All-In-One Stack Album', 'foogallery' ), |
||
140 | 'fields' => array( |
||
141 | array( |
||
142 | 'id' => 'lightbox', |
||
143 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
144 | 'desc' => __( 'Choose which lightbox you want to use to display images.', 'foogallery' ), |
||
145 | 'type' => 'lightbox', |
||
146 | ), |
||
147 | |||
148 | array( |
||
149 | 'id' => 'thumbnail_dimensions', |
||
150 | 'title' => __( 'Thumbnail Size', 'foogallery' ), |
||
151 | 'desc' => __( 'Choose the size of your image stack thumbnails.', 'foogallery' ), |
||
152 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
153 | 'type' => 'thumb_size', |
||
154 | 'default' => array( |
||
155 | 'width' => get_option( 'thumbnail_size_w' ), |
||
156 | 'height' => get_option( 'thumbnail_size_h' ), |
||
157 | 'crop' => true, |
||
158 | ), |
||
159 | ), |
||
160 | |||
161 | array( |
||
162 | 'id' => 'random_angle', |
||
163 | 'title' => __( 'Thumbnail Rotation', 'foogallery' ), |
||
164 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
165 | 'desc' => __( 'Choose how thumbnails in each gallery are shown when clicking an image stack.', 'foogallery' ), |
||
166 | 'type' => 'radio', |
||
167 | 'default' => 'false', |
||
168 | 'choices' => array( |
||
169 | 'false' => __( 'Normal', 'foogallery' ), |
||
170 | 'true' => __( 'Random Angles', 'foogallery' ) |
||
171 | ) |
||
172 | ), |
||
173 | |||
174 | array( |
||
175 | 'id' => 'gutter', |
||
176 | 'title' => __( 'Thumbnail Gutter', 'foogallery' ), |
||
177 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
178 | 'desc' => __( 'The spacing between each image stack.', 'foogallery' ), |
||
179 | 'type' => 'number', |
||
180 | 'default' => 50 |
||
181 | ), |
||
182 | |||
183 | array( |
||
184 | 'id' => 'delay', |
||
185 | 'title' => __( 'Expand Delay', 'foogallery' ), |
||
186 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
187 | 'desc' => __( 'The delay between expanding each image on a image stack.', 'foogallery' ), |
||
188 | 'type' => 'number', |
||
189 | 'default' => 0 |
||
190 | ), |
||
191 | |||
192 | array( |
||
193 | 'id' => 'pile_angles', |
||
194 | 'title' => __( 'Image Stack Angles', 'foogallery' ), |
||
195 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
196 | 'desc' => __( 'The angle of the images behind the thumbnail in each image stack.', 'foogallery' ), |
||
197 | 'type' => 'radio', |
||
198 | 'default' => '1', |
||
199 | 'choices' => array( |
||
200 | '1' => __( 'Low', 'foogallery' ), |
||
201 | '2' => __( 'Normal', 'foogallery' ), |
||
202 | '3' => __( 'More Than Normal', 'foogallery' ), |
||
203 | '5' => __( 'High', 'foogallery' ), |
||
204 | ) |
||
205 | ) |
||
206 | ) |
||
207 | ); |
||
208 | |||
209 | return apply_filters( 'foogallery_album_templates', $album_templates ); |
||
210 | } |
||
211 | |||
376 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: