Conditions | 1 |
Paths | 1 |
Total Lines | 130 |
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 |
||
70 | function add_template( $gallery_templates ) { |
||
71 | |||
72 | $gallery_templates[] = array( |
||
73 | 'slug' => 'image-viewer', |
||
74 | 'name' => __( 'Image Viewer', 'foogallery' ), |
||
75 | 'preview_support' => true, |
||
76 | 'common_fields_support' => true, |
||
77 | 'lazyload_support' => true, |
||
78 | 'mandatory_classes' => 'fg-image-viewer', |
||
79 | 'thumbnail_dimensions' => true, |
||
80 | 'fields' => array( |
||
81 | array( |
||
82 | 'id' => 'thumbnail-help', |
||
83 | 'title' => __( 'Thumbnail Help', 'foogallery' ), |
||
84 | 'desc' => __( 'It is recommended to crop your thumbnails, so that your gallery remains a constant size. If you do not crop, then the size of the gallery could potentially change for each thumbnail.', 'foogallery' ), |
||
85 | 'section' => __( 'General', 'foogallery' ), |
||
86 | 'type' => 'help' |
||
87 | ), |
||
88 | array( |
||
89 | 'id' => 'thumbnail_size', |
||
90 | 'title' => __( 'Thumb Size', 'foogallery' ), |
||
91 | 'section' => __( 'General', 'foogallery' ), |
||
92 | 'desc' => __( 'Choose the size of your thumbnails', 'foogallery' ), |
||
93 | 'type' => 'thumb_size', |
||
94 | 'default' => array( |
||
95 | 'width' => 640, |
||
96 | 'height' => 360, |
||
97 | 'crop' => true |
||
98 | ), |
||
99 | 'row_data'=> array( |
||
100 | 'data-foogallery-change-selector' => 'input', |
||
101 | 'data-foogallery-preview' => 'shortcode' |
||
102 | ) |
||
103 | ), |
||
104 | array( |
||
105 | 'id' => 'thumbnail_link', |
||
106 | 'title' => __( 'Thumb Link', 'foogallery' ), |
||
107 | 'section' => __( 'General', 'foogallery' ), |
||
108 | 'default' => 'image' , |
||
109 | 'type' => 'thumb_link', |
||
110 | 'desc' => __( 'You can choose to either link each thumbnail to the full size image or to the image\'s attachment page', 'foogallery') |
||
111 | ), |
||
112 | array( |
||
113 | 'id' => 'lightbox', |
||
114 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
115 | 'section' => __( 'General', 'foogallery' ), |
||
116 | 'desc' => __( 'Choose which lightbox you want to use in the gallery', 'foogallery' ), |
||
117 | 'default' => 'none', |
||
118 | 'type' => 'lightbox' |
||
119 | ), |
||
120 | array( |
||
121 | 'id' => 'alignment', |
||
122 | 'title' => __( 'Alignment', 'foogallery' ), |
||
123 | 'section' => __( 'General', 'foogallery' ), |
||
124 | 'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery', 'foogallery' ), |
||
125 | 'default' => 'fg-center', |
||
126 | 'type' => 'radio', |
||
127 | 'spacer' => '<span class="spacer"></span>', |
||
128 | 'choices' => array( |
||
129 | 'fg-left' => __( 'Left', 'foogallery' ), |
||
130 | 'fg-center' => __( 'Center', 'foogallery' ), |
||
131 | 'fg-right' => __( 'Right', 'foogallery' ), |
||
132 | ), |
||
133 | 'row_data'=> array( |
||
134 | 'data-foogallery-change-selector' => 'input:radio', |
||
135 | 'data-foogallery-preview' => 'class' |
||
136 | ) |
||
137 | ), |
||
138 | array( |
||
139 | 'id' => 'looping', |
||
140 | 'title' => __( 'Loop Images', 'foogallery' ), |
||
141 | 'section' => __( 'General', 'foogallery' ), |
||
142 | 'desc' => __( 'When navigating through the images, do you want to loop image back to the first after you navigate past the last image?', 'foogallery' ), |
||
143 | 'default' => 'enabled', |
||
144 | 'type' => 'radio', |
||
145 | 'spacer' => '<span class="spacer"></span>', |
||
146 | 'choices' => array( |
||
147 | 'disabled' => __( 'Disabled', 'foogallery' ), |
||
148 | 'enabled' => __( 'Looping Enabled', 'foogallery' ), |
||
149 | ), |
||
150 | 'row_data'=> array( |
||
151 | 'data-foogallery-change-selector' => 'input:radio', |
||
152 | 'data-foogallery-preview' => 'shortcode' |
||
153 | ) |
||
154 | ), |
||
155 | array( |
||
156 | 'id' => 'language-help', |
||
157 | 'title' => __( 'Language Help', 'foogallery' ), |
||
158 | 'desc' => __( 'This gallery template shows the below items of text. Change them to suit your preference or language.', 'foogallery' ), |
||
159 | 'section' => __( 'General', 'foogallery' ), |
||
160 | 'type' => 'help' |
||
161 | ), |
||
162 | array( |
||
163 | 'id' => 'text-prev', |
||
164 | 'title' => __( '"Prev" Text', 'foogallery' ), |
||
165 | 'section' => __( 'General', 'foogallery' ), |
||
166 | 'type' => 'text', |
||
167 | 'default' => __('Prev', 'foogallery'), |
||
168 | 'row_data'=> array( |
||
169 | 'data-foogallery-change-selector' => 'input', |
||
170 | 'data-foogallery-preview' => 'shortcode' |
||
171 | ) |
||
172 | ), |
||
173 | array( |
||
174 | 'id' => 'text-of', |
||
175 | 'title' => __( '"of" Text', 'foogallery' ), |
||
176 | 'section' => __( 'General', 'foogallery' ), |
||
177 | 'type' => 'text', |
||
178 | 'default' => __('of', 'foogallery'), |
||
179 | 'row_data'=> array( |
||
180 | 'data-foogallery-change-selector' => 'input', |
||
181 | 'data-foogallery-preview' => 'shortcode' |
||
182 | ) |
||
183 | ), |
||
184 | array( |
||
185 | 'id' => 'text-next', |
||
186 | 'title' => __( '"Next" Text', 'foogallery' ), |
||
187 | 'section' => __( 'General', 'foogallery' ), |
||
188 | 'type' => 'text', |
||
189 | 'default' => __('Next', 'foogallery'), |
||
190 | 'row_data'=> array( |
||
191 | 'data-foogallery-change-selector' => 'input', |
||
192 | 'data-foogallery-preview' => 'shortcode' |
||
193 | ) |
||
194 | ) |
||
195 | ) |
||
196 | ); |
||
197 | |||
198 | return $gallery_templates; |
||
199 | } |
||
200 | |||
337 | } |
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.