Conditions | 1 |
Paths | 1 |
Total Lines | 181 |
Code Lines | 139 |
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 |
||
83 | function add_template( $gallery_templates ) { |
||
84 | |||
85 | $gallery_templates[] = array( |
||
86 | 'slug' => 'foogridpro', |
||
87 | 'name' => __( 'Grid PRO', 'foogallery'), |
||
88 | 'preview_support' => true, |
||
89 | 'common_fields_support' => true, |
||
90 | 'lazyload_support' => true, |
||
91 | 'paging_support' => true, |
||
92 | 'thumbnail_dimensions' => true, |
||
93 | 'mandatory_classes' => 'foogrid', |
||
94 | 'fields' => array( |
||
95 | array( |
||
96 | 'id' => 'thumbnail_size', |
||
97 | 'title' => __('Thumbnail Size', 'foogallery'), |
||
98 | 'desc' => __('Choose the size of your thumbs.', 'foogallery'), |
||
99 | 'type' => 'thumb_size', |
||
100 | 'default' => array( |
||
101 | 'width' => 320, |
||
102 | 'height' => 180, |
||
103 | 'crop' => true |
||
104 | ), |
||
105 | 'row_data'=> array( |
||
106 | 'data-foogallery-change-selector' => 'input', |
||
107 | 'data-foogallery-preview' => 'shortcode' |
||
108 | ) |
||
109 | ), |
||
110 | array( |
||
111 | 'id' => 'thumbnail_link', |
||
112 | 'title' => __('Thumbnail Link', 'foogallery'), |
||
113 | 'default' => 'image' , |
||
114 | 'type' => 'thumb_link', |
||
115 | 'desc' => __('You can choose to either link each thumbnail to the full size image or to the image\'s attachment page.', 'foogallery') |
||
116 | ), |
||
117 | // array( |
||
118 | // 'id' => 'theme', |
||
119 | // 'section' => __( 'General', 'foogallery' ), |
||
120 | // 'title' => __('Theme', 'foogallery'), |
||
121 | // 'desc' => __('The theme for the content viewer.', 'foogallery'), |
||
122 | // 'default' => '', |
||
123 | // 'type' => 'radio', |
||
124 | // 'spacer' => '<span class="spacer"></span>', |
||
125 | // 'choices' => array( |
||
126 | // '' => __( 'Dark (Default)', 'foogallery' ), |
||
127 | // 'foogrid-light' => __( 'Light', 'foogallery' ) |
||
128 | // ) |
||
129 | // ), |
||
130 | array( |
||
131 | 'id' => 'transition', |
||
132 | 'section' => __( 'General', 'foogallery' ), |
||
133 | 'title' => __('Transition', 'foogallery'), |
||
134 | 'desc' => __('Transition type to use switching between items, or no transitions at all.', 'foogallery'), |
||
135 | 'default' => 'foogrid-transition-fade', |
||
136 | 'type' => 'radio', |
||
137 | 'spacer' => '<span class="spacer"></span>', |
||
138 | 'choices' => array( |
||
139 | 'foogrid-transition-fade' => __( 'Fade', 'foogallery' ), |
||
140 | 'foogrid-transition-horizontal' => __( 'Horizontal', 'foogallery' ), |
||
141 | 'foogrid-transition-vertical' => __( 'Vertical', 'foogallery' ), |
||
142 | '' => __( 'None', 'foogallery' ) |
||
143 | ), |
||
144 | 'row_data'=> array( |
||
145 | 'data-foogallery-change-selector' => 'input', |
||
146 | 'data-foogallery-value-selector' => 'input:checked', |
||
147 | 'data-foogallery-preview' => 'class' |
||
148 | ) |
||
149 | ), |
||
150 | array( |
||
151 | 'id' => 'loop', |
||
152 | 'section' => __( 'General', 'foogallery' ), |
||
153 | 'title' => __('Loop', 'foogallery'), |
||
154 | 'desc' => __('Whether the slider should loop (i.e. the first slide goes to the last, the last slide goes to the first).', 'foogallery'), |
||
155 | 'default' => 'yes', |
||
156 | 'type' => 'radio', |
||
157 | 'spacer' => '<span class="spacer"></span>', |
||
158 | 'choices' => array( |
||
159 | 'yes' => __( 'Yes', 'foogallery' ), |
||
160 | 'no' => __( 'No', 'foogallery' ) |
||
161 | ), |
||
162 | 'row_data'=> array( |
||
163 | 'data-foogallery-change-selector' => 'input', |
||
164 | 'data-foogallery-value-selector' => 'input:checked', |
||
165 | 'data-foogallery-preview' => 'shortcode' |
||
166 | ) |
||
167 | ), |
||
168 | array( |
||
169 | 'id' => 'columns', |
||
170 | 'section' => __( 'General', 'foogallery' ), |
||
171 | 'title' => __('Max Columns', 'foogallery'), |
||
172 | 'desc' => __('The maximum number of thumbnail columns to display. * This amount is automatically reduced on small screen sizes.', 'foogallery'), |
||
173 | 'default' => 'foogrid-cols-4', |
||
174 | 'type' => 'select', |
||
175 | 'choices' => array( |
||
176 | 'foogrid-cols-2' => __( '2 Columns', 'foogallery' ), |
||
177 | 'foogrid-cols-3' => __( '3 Columns', 'foogallery' ), |
||
178 | 'foogrid-cols-4' => __( '4 Columns', 'foogallery' ), |
||
179 | 'foogrid-cols-5' => __( '5 Columns', 'foogallery' ), |
||
180 | 'foogrid-cols-6' => __( '6 Columns', 'foogallery' ), |
||
181 | 'foogrid-cols-7' => __( '7 Columns', 'foogallery' ), |
||
182 | 'foogrid-cols-8' => __( '8 Columns', 'foogallery' ) |
||
183 | ), |
||
184 | 'row_data'=> array( |
||
185 | 'data-foogallery-change-selector' => 'select', |
||
186 | 'data-foogallery-value-selector' => 'option:selected', |
||
187 | 'data-foogallery-preview' => 'class' |
||
188 | ) |
||
189 | ), |
||
190 | array( |
||
191 | 'id' => 'captions', |
||
192 | 'section' => __( 'General', 'foogallery' ), |
||
193 | 'title' => __('Stage Caption', 'foogallery'), |
||
194 | 'desc' => __('The position of caption in the stage or no captions at all. * The caption will automatically switch to below the item on small screen sizes.', 'foogallery'), |
||
195 | 'default' => 'foogrid-caption-below', |
||
196 | 'type' => 'radio', |
||
197 | 'spacer' => '<span class="spacer"></span>', |
||
198 | 'choices' => array( |
||
199 | 'foogrid-caption-below' => __( 'Below', 'foogallery' ), |
||
200 | 'foogrid-caption-right' => __( 'Right', 'foogallery' ), |
||
201 | '' => __( 'None', 'foogallery' ) |
||
202 | ), |
||
203 | 'row_data'=> array( |
||
204 | 'data-foogallery-change-selector' => 'input', |
||
205 | 'data-foogallery-value-selector' => 'input:checked', |
||
206 | 'data-foogallery-preview' => 'class' |
||
207 | ) |
||
208 | ), |
||
209 | array( |
||
210 | 'id' => 'scroll', |
||
211 | 'section' => __( 'General', 'foogallery' ), |
||
212 | 'title' => __('Scroll', 'foogallery'), |
||
213 | 'desc' => __('Whether the page is scrolled to the selected item.', 'foogallery'), |
||
214 | 'default' => 'yes', |
||
215 | 'type' => 'radio', |
||
216 | 'spacer' => '<span class="spacer"></span>', |
||
217 | 'choices' => array( |
||
218 | 'yes' => __( 'Yes', 'foogallery' ), |
||
219 | 'no' => __( 'No', 'foogallery' ) |
||
220 | ), |
||
221 | 'row_data'=> array( |
||
222 | 'data-foogallery-change-selector' => 'input', |
||
223 | 'data-foogallery-value-selector' => 'input:checked', |
||
224 | 'data-foogallery-preview' => 'shortcode' |
||
225 | ) |
||
226 | ), |
||
227 | array( |
||
228 | 'id' => 'scroll_smooth', |
||
229 | 'section' => __( 'General', 'foogallery' ), |
||
230 | 'title' => __('Smooth Scroll', 'foogallery'), |
||
231 | 'desc' => __('Whether or not to perform a smooth scrolling animation to the selected item.', 'foogallery'), |
||
232 | 'default' => 'yes', |
||
233 | 'type' => 'radio', |
||
234 | 'spacer' => '<span class="spacer"></span>', |
||
235 | 'choices' => array( |
||
236 | 'yes' => __( 'Yes', 'foogallery' ), |
||
237 | 'no' => __( 'No', 'foogallery' ) |
||
238 | ), |
||
239 | 'row_data'=> array( |
||
240 | 'data-foogallery-change-selector' => 'input', |
||
241 | 'data-foogallery-value-selector' => 'input:checked', |
||
242 | 'data-foogallery-preview' => 'shortcode' |
||
243 | ) |
||
244 | ), |
||
245 | array( |
||
246 | 'id' => 'scroll_offset', |
||
247 | 'section' => __( 'General', 'foogallery' ), |
||
248 | 'title' => __('Scroll Offset', 'foogallery'), |
||
249 | 'desc' => __('The amount to offset scrolling by. * This can be used to counter fixed headers.', 'foogallery'), |
||
250 | 'class' => 'small-text', |
||
251 | 'type' => 'number', |
||
252 | 'default' => 0, |
||
253 | 'row_data'=> array( |
||
254 | 'data-foogallery-change-selector' => 'input', |
||
255 | 'data-foogallery-value-selector' => 'input', |
||
256 | 'data-foogallery-preview' => 'shortcode' |
||
257 | ) |
||
258 | ), |
||
259 | ) |
||
260 | ); |
||
261 | |||
262 | return $gallery_templates; |
||
263 | } |
||
264 | |||
345 | } |
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.