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