| Conditions | 1 |
| Paths | 1 |
| Total Lines | 150 |
| Code Lines | 127 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 35 | function add_template( $gallery_templates ) { |
||
| 36 | $gallery_templates[] = array( |
||
| 37 | 'slug' => 'default', |
||
| 38 | 'name' => __( 'Responsive Image Gallery', 'foogallery' ), |
||
| 39 | 'preview_css' => FOOGALLERY_DEFAULT_GALLERY_TEMPLATE_URL . 'css/gallery-default.css', |
||
| 40 | 'admin_js' => FOOGALLERY_DEFAULT_GALLERY_TEMPLATE_URL . 'js/admin-gallery-default.js', |
||
| 41 | 'fields' => array( |
||
| 42 | array( |
||
| 43 | 'id' => 'lightbox', |
||
| 44 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
| 45 | 'desc' => __( 'Choose which lightbox you want to use. The lightbox will only work if you set the thumbnail link to "Full Size Image".', 'foogallery' ), |
||
| 46 | 'type' => 'lightbox', |
||
| 47 | ), |
||
| 48 | array( |
||
| 49 | 'id' => 'spacing', |
||
| 50 | 'title' => __( 'Spacing', 'foogallery' ), |
||
| 51 | 'desc' => __( 'The spacing or gap between thumbnails in the gallery.', 'foogallery' ), |
||
| 52 | 'type' => 'select', |
||
| 53 | 'default' => 'spacing-width-10', |
||
| 54 | 'choices' => array( |
||
| 55 | 'spacing-width-0' => __( '0 pixels', 'foogallery' ), |
||
| 56 | 'spacing-width-5' => __( '5 pixels', 'foogallery' ), |
||
| 57 | 'spacing-width-10' => __( '10 pixels', 'foogallery' ), |
||
| 58 | 'spacing-width-15' => __( '15 pixels', 'foogallery' ), |
||
| 59 | 'spacing-width-20' => __( '20 pixels', 'foogallery' ), |
||
| 60 | 'spacing-width-25' => __( '25 pixels', 'foogallery' ), |
||
| 61 | ), |
||
| 62 | ), |
||
| 63 | array( |
||
| 64 | 'id' => 'alignment', |
||
| 65 | 'title' => __( 'Alignment', 'foogallery' ), |
||
| 66 | 'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery.', 'foogallery' ), |
||
| 67 | 'default' => 'alignment-center', |
||
| 68 | 'type' => 'select', |
||
| 69 | 'choices' => array( |
||
| 70 | 'alignment-left' => __( 'Left', 'foogallery' ), |
||
| 71 | 'alignment-center' => __( 'Center', 'foogallery' ), |
||
| 72 | 'alignment-right' => __( 'Right', 'foogallery' ), |
||
| 73 | ) |
||
| 74 | ), |
||
| 75 | array( |
||
| 76 | 'id' => 'thumbnail_dimensions', |
||
| 77 | 'title' => __( 'Size', 'foogallery' ), |
||
| 78 | 'desc' => __( 'Choose the size of your thumbnails.', 'foogallery' ), |
||
| 79 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 80 | 'type' => 'thumb_size', |
||
| 81 | 'default' => array( |
||
| 82 | 'width' => get_option( 'thumbnail_size_w' ), |
||
| 83 | 'height' => get_option( 'thumbnail_size_h' ), |
||
| 84 | 'crop' => true, |
||
| 85 | ), |
||
| 86 | ), |
||
| 87 | array( |
||
| 88 | 'id' => 'thumbnail_link', |
||
| 89 | 'title' => __( 'Link', 'foogallery' ), |
||
| 90 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 91 | 'default' => 'image', |
||
| 92 | 'type' => 'thumb_link', |
||
| 93 | 'spacer' => '<span class="spacer"></span>', |
||
| 94 | 'desc' => __( 'You can choose to link each thumbnail to the full size image, the image\'s attachment page, a custom URL, or you can choose to not link to anything.', 'foogallery' ), |
||
| 95 | ), |
||
| 96 | array( |
||
| 97 | 'id' => 'border-style', |
||
| 98 | 'title' => __( 'Border Style', 'foogallery' ), |
||
| 99 | 'desc' => __( 'The border style for each thumbnail in the gallery.', 'foogallery' ), |
||
| 100 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 101 | 'type' => 'icon', |
||
| 102 | 'default' => 'border-style-square-white', |
||
| 103 | 'choices' => array( |
||
| 104 | 'border-style-square-white' => array( 'label' => __( 'Square white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-white.png' ), |
||
| 105 | 'border-style-circle-white' => array( 'label' => __( 'Circular white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-white.png' ), |
||
| 106 | 'border-style-square-black' => array( 'label' => __( 'Square Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-black.png' ), |
||
| 107 | 'border-style-circle-black' => array( 'label' => __( 'Circular Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-black.png' ), |
||
| 108 | 'border-style-inset' => array( 'label' => __( 'Square Inset' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-inset.png' ), |
||
| 109 | 'border-style-rounded' => array( 'label' => __( 'Plain Rounded' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-plain-rounded.png' ), |
||
| 110 | '' => array( 'label' => __( 'Plain' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-none.png' ), |
||
| 111 | ) |
||
| 112 | ), |
||
| 113 | array( |
||
| 114 | 'id' => 'hover-effect-type', |
||
| 115 | 'title' => __( 'Hover Effect Type', 'foogallery' ), |
||
| 116 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 117 | 'default' => '', |
||
| 118 | 'type' => 'radio', |
||
| 119 | 'choices' => apply_filters( 'foogallery_gallery_template_hover-effect-types', array( |
||
| 120 | '' => __( 'Icon', 'foogallery' ), |
||
| 121 | 'hover-effect-tint' => __( 'Dark Tint', 'foogallery' ), |
||
| 122 | 'hover-effect-color' => __( 'Colorize', 'foogallery' ), |
||
| 123 | 'hover-effect-caption' => __( 'Caption', 'foogallery' ), |
||
| 124 | 'hover-effect-none' => __( 'None', 'foogallery' ) |
||
| 125 | ) ), |
||
| 126 | 'spacer' => '<span class="spacer"></span>', |
||
| 127 | 'desc' => __( 'The type of hover effect the thumbnails will use.', 'foogallery' ), |
||
| 128 | ), |
||
| 129 | array( |
||
| 130 | 'id' => 'hover-effect', |
||
| 131 | 'title' => __( 'Icon Hover Effect', 'foogallery' ), |
||
| 132 | 'desc' => __( 'When the hover effect type of Icon is chosen, you can choose which icon is shown when you hover over each thumbnail.', 'foogallery' ), |
||
| 133 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 134 | 'type' => 'icon', |
||
| 135 | 'default' => 'hover-effect-zoom', |
||
| 136 | 'choices' => array( |
||
| 137 | 'hover-effect-zoom' => array( 'label' => __( 'Zoom' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom.png' ), |
||
| 138 | 'hover-effect-zoom2' => array( 'label' => __( 'Zoom 2' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom2.png' ), |
||
| 139 | 'hover-effect-zoom3' => array( 'label' => __( 'Zoom 3' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom3.png' ), |
||
| 140 | 'hover-effect-plus' => array( 'label' => __( 'Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-plus.png' ), |
||
| 141 | 'hover-effect-circle-plus' => array( 'label' => __( 'Cirlce Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-circle-plus.png' ), |
||
| 142 | 'hover-effect-eye' => array( 'label' => __( 'Eye' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-eye.png' ) |
||
| 143 | ), |
||
| 144 | ), |
||
| 145 | array( |
||
| 146 | 'id' => 'caption-hover-effect', |
||
| 147 | 'title' => __( 'Caption Effect', 'foogallery' ), |
||
| 148 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 149 | 'default' => 'hover-caption-simple', |
||
| 150 | 'type' => 'radio', |
||
| 151 | 'choices' => apply_filters( 'foogallery_gallery_template_caption-hover-effects', array( |
||
| 152 | 'hover-caption-simple' => __( 'Simple', 'foogallery' ), |
||
| 153 | 'hover-caption-full-drop' => __( 'Drop', 'foogallery' ), |
||
| 154 | 'hover-caption-full-fade' => __( 'Fade In', 'foogallery' ), |
||
| 155 | 'hover-caption-push' => __( 'Push', 'foogallery' ), |
||
| 156 | 'hover-caption-simple-always' => __( 'Always Visible', 'foogallery' ) |
||
| 157 | ) ), |
||
| 158 | 'spacer' => '<span class="spacer"></span>' |
||
| 159 | ), |
||
| 160 | array( |
||
| 161 | 'id' => 'caption-content', |
||
| 162 | 'title' => __( 'Caption Content', 'foogallery' ), |
||
| 163 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 164 | 'default' => 'title', |
||
| 165 | 'type' => 'radio', |
||
| 166 | 'choices' => apply_filters( 'foogallery_gallery_template_caption-content', array( |
||
| 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 thumbnails will look like.', 'foogallery' ), |
||
| 177 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 178 | 'type' => 'default_thumb_preview', |
||
| 179 | ) |
||
| 180 | ) |
||
| 181 | ); |
||
| 182 | |||
| 183 | return $gallery_templates; |
||
| 184 | } |
||
| 185 | |||
| 233 | } |
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.