Conditions | 1 |
Paths | 1 |
Total Lines | 169 |
Code Lines | 142 |
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 |
||
37 | function add_template( $gallery_templates ) { |
||
38 | |||
39 | $gallery_templates[] = array( |
||
40 | 'slug' => 'image-viewer', |
||
41 | 'name' => __( 'Image Viewer', 'foogallery-image-viewer'), |
||
42 | 'preview_css' => FOOGALLERY_IMAGE_VIEWER_GALLERY_TEMPLATE_URL . 'css/gallery-image-viewer.css', |
||
43 | 'admin_js' => FOOGALLERY_IMAGE_VIEWER_GALLERY_TEMPLATE_URL . 'js/admin-gallery-image-viewer.js', |
||
44 | 'fields' => array( |
||
45 | array( |
||
46 | 'id' => 'alignment', |
||
47 | 'title' => __( 'Alignment', 'foogallery' ), |
||
48 | 'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery.', 'foogallery' ), |
||
49 | 'default' => 'alignment-center', |
||
50 | 'type' => 'select', |
||
51 | 'choices' => array( |
||
52 | 'alignment-left' => __( 'Left', 'foogallery' ), |
||
53 | 'alignment-center' => __( 'Center', 'foogallery' ), |
||
54 | 'alignment-right' => __( 'Right', 'foogallery' ), |
||
55 | ) |
||
56 | ), |
||
57 | array( |
||
58 | 'id' => 'lightbox', |
||
59 | 'title' => __('Lightbox', 'foogallery-image-viewer'), |
||
60 | 'desc' => __('Choose which lightbox you want to use in the gallery.', 'foogallery-image-viewer'), |
||
61 | 'type' => 'lightbox' |
||
62 | ), |
||
63 | array( |
||
64 | 'id' => 'theme', |
||
65 | 'title' => __('Theme', 'foogallery'), |
||
66 | 'default' => '', |
||
67 | 'type' => 'radio', |
||
68 | 'spacer' => '<span class="spacer"></span>', |
||
69 | 'choices' => array( |
||
70 | '' => __( 'Light', 'foogallery' ), |
||
71 | 'fiv-dark' => __( 'Dark', 'foogallery' ), |
||
72 | 'fiv-custom' => __( 'Custom', 'foogallery' ) |
||
73 | ) |
||
74 | ), |
||
75 | array( |
||
76 | 'id' => 'theme_custom_bgcolor', |
||
77 | 'title' => __('Background Color', 'foogallery'), |
||
78 | 'section' => __( 'Custom Theme Colors', 'foogallery' ), |
||
79 | 'type' => 'colorpicker', |
||
80 | 'default' => '#FFFFFF', |
||
81 | 'opacity' => true |
||
82 | ), |
||
83 | array( |
||
84 | 'id' => 'theme_custom_textcolor', |
||
85 | 'title' => __('Text Color', 'foogallery'), |
||
86 | 'section' => __( 'Custom Theme Colors', 'foogallery' ), |
||
87 | 'type' => 'colorpicker', |
||
88 | 'default' => '#1b1b1b', |
||
89 | 'opacity' => true |
||
90 | ), |
||
91 | array( |
||
92 | 'id' => 'theme_custom_hovercolor', |
||
93 | 'title' => __('Hover BG Color', 'foogallery'), |
||
94 | 'section' => __( 'Custom Theme Colors', 'foogallery' ), |
||
95 | 'type' => 'colorpicker', |
||
96 | 'default' => '#F2F2F2', |
||
97 | 'opacity' => true |
||
98 | ), |
||
99 | array( |
||
100 | 'id' => 'theme_custom_bordercolor', |
||
101 | 'title' => __('Border Color', 'foogallery'), |
||
102 | 'section' => __( 'Custom Theme Colors', 'foogallery' ), |
||
103 | 'type' => 'colorpicker', |
||
104 | 'default' => '#e6e6e6', |
||
105 | 'opacity' => true |
||
106 | ), |
||
107 | array( |
||
108 | 'id' => 'thumbnail_size', |
||
109 | 'title' => __('Thumbnail Size', 'foogallery-image-viewer'), |
||
110 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
111 | 'desc' => __('Choose the size of your thumbs.', 'foogallery-image-viewer'), |
||
112 | 'type' => 'thumb_size', |
||
113 | 'default' => array( |
||
114 | 'width' => 640, |
||
115 | 'height' => 360, |
||
116 | 'crop' => true |
||
117 | ) |
||
118 | ), |
||
119 | array( |
||
120 | 'id' => 'thumbnail_link', |
||
121 | 'title' => __('Thumbnail Link', 'foogallery-image-viewer'), |
||
122 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
123 | 'default' => 'image' , |
||
124 | 'type' => 'thumb_link', |
||
125 | 'spacer' => '<span class="spacer"></span>', |
||
126 | 'desc' => __('You can choose to either link each thumbnail to the full size image or to the image\'s attachment page.', 'foogallery-image-viewer') |
||
127 | ), |
||
128 | array( |
||
129 | 'id' => 'hover-effect-type', |
||
130 | 'title' => __( 'Hover Effect Type', 'foogallery' ), |
||
131 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
132 | 'default' => '', |
||
133 | 'type' => 'radio', |
||
134 | 'choices' => apply_filters( 'foogallery_gallery_template_hover-effect-types', array( |
||
135 | '' => __( 'Icon', 'foogallery' ), |
||
136 | 'hover-effect-tint' => __( 'Dark Tint', 'foogallery' ), |
||
137 | 'hover-effect-color' => __( 'Colorize', 'foogallery' ), |
||
138 | 'hover-effect-none' => __( 'None', 'foogallery' ) |
||
139 | ) ), |
||
140 | 'spacer' => '<span class="spacer"></span>', |
||
141 | 'desc' => __( 'The type of hover effect the thumbnails will use.', 'foogallery' ) |
||
142 | ), |
||
143 | array( |
||
144 | 'id' => 'hover-effect', |
||
145 | 'title' => __( 'Icon Hover Effect', 'foogallery' ), |
||
146 | 'desc' => __( 'When the hover effect type of Icon is chosen, you can choose which icon is shown when you hover over each thumbnail.', 'foogallery' ), |
||
147 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
148 | 'type' => 'icon', |
||
149 | 'default' => 'hover-effect-zoom', |
||
150 | 'choices' => array( |
||
151 | 'hover-effect-zoom' => array( 'label' => __( 'Zoom' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom.png' ), |
||
152 | 'hover-effect-zoom2' => array( 'label' => __( 'Zoom 2' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom2.png' ), |
||
153 | 'hover-effect-zoom3' => array( 'label' => __( 'Zoom 3' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom3.png' ), |
||
154 | 'hover-effect-plus' => array( 'label' => __( 'Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-plus.png' ), |
||
155 | 'hover-effect-circle-plus' => array( 'label' => __( 'Circle Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-circle-plus.png' ), |
||
156 | 'hover-effect-eye' => array( 'label' => __( 'Eye' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-eye.png' ) |
||
157 | ), |
||
158 | ), |
||
159 | array( |
||
160 | 'id' => 'caption-content', |
||
161 | 'title' => __( 'Caption Content', 'foogallery' ), |
||
162 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
163 | 'default' => 'title', |
||
164 | 'type' => 'radio', |
||
165 | 'choices' => apply_filters( 'foogallery_gallery_template_caption-content', array( |
||
166 | 'none' => __( 'None', 'foogallery' ), |
||
167 | 'title' => __( 'Title Only', 'foogallery' ), |
||
168 | 'desc' => __( 'Description Only', 'foogallery' ), |
||
169 | 'both' => __( 'Title and Description', 'foogallery' ) |
||
170 | ) ), |
||
171 | 'spacer' => '<span class="spacer"></span>' |
||
172 | ), |
||
173 | array( |
||
174 | 'id' => 'thumb_preview', |
||
175 | 'title' => __( 'Preview', 'foogallery' ), |
||
176 | 'desc' => __( 'This is what your gallery will look like.', 'foogallery' ), |
||
177 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
178 | 'type' => 'image_viewer_preview', |
||
179 | ), |
||
180 | array( |
||
181 | 'id' => 'text-prev', |
||
182 | 'title' => __( '"Prev" Text', 'foogallery' ), |
||
183 | 'section' => __( 'Language Settings', 'foogallery' ), |
||
184 | 'type' => 'text', |
||
185 | 'default' => __('Prev', 'foogallery') |
||
186 | ), |
||
187 | array( |
||
188 | 'id' => 'text-of', |
||
189 | 'title' => __( '"of" Text', 'foogallery' ), |
||
190 | 'section' => __( 'Language Settings', 'foogallery' ), |
||
191 | 'type' => 'text', |
||
192 | 'default' => __('of', 'foogallery') |
||
193 | ), |
||
194 | array( |
||
195 | 'id' => 'text-next', |
||
196 | 'title' => __( '"Next" Text', 'foogallery' ), |
||
197 | 'section' => __( 'Language Settings', 'foogallery' ), |
||
198 | 'type' => 'text', |
||
199 | 'default' => __('Next', 'foogallery') |
||
200 | ) |
||
201 | ) |
||
202 | ); |
||
203 | |||
204 | return $gallery_templates; |
||
205 | } |
||
206 | |||
290 | } |
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.