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