| Conditions | 1 |
| Paths | 1 |
| Total Lines | 118 |
| Code Lines | 98 |
| 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 |
||
| 42 | function add_template( $gallery_templates ) { |
||
| 43 | |||
| 44 | $gallery_templates[] = array( |
||
| 45 | 'slug' => 'image-viewer', |
||
| 46 | 'name' => __( 'Image Viewer', 'foogallery-image-viewer'), |
||
| 47 | 'lazyload_support' => true, |
||
| 48 | 'preview_css' => FOOGALLERY_IMAGE_VIEWER_GALLERY_TEMPLATE_URL . 'css/gallery-image-viewer.css', |
||
| 49 | 'admin_js' => FOOGALLERY_IMAGE_VIEWER_GALLERY_TEMPLATE_URL . 'js/admin-gallery-image-viewer.js', |
||
| 50 | 'fields' => array( |
||
| 51 | array( |
||
| 52 | 'id' => 'alignment', |
||
| 53 | 'title' => __( 'Alignment', 'foogallery' ), |
||
| 54 | 'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery.', 'foogallery' ), |
||
| 55 | 'default' => 'alignment-center', |
||
| 56 | 'type' => 'select', |
||
| 57 | 'choices' => array( |
||
| 58 | 'alignment-left' => __( 'Left', 'foogallery' ), |
||
| 59 | 'alignment-center' => __( 'Center', 'foogallery' ), |
||
| 60 | 'alignment-right' => __( 'Right', 'foogallery' ), |
||
| 61 | ) |
||
| 62 | ), |
||
| 63 | array( |
||
| 64 | 'id' => 'lightbox', |
||
| 65 | 'title' => __('Lightbox', 'foogallery-image-viewer'), |
||
| 66 | 'desc' => __('Choose which lightbox you want to use in the gallery.', 'foogallery-image-viewer'), |
||
| 67 | 'type' => 'lightbox' |
||
| 68 | ), |
||
| 69 | array( |
||
| 70 | 'id' => 'theme', |
||
| 71 | 'title' => __('Theme', 'foogallery'), |
||
| 72 | 'default' => '', |
||
| 73 | 'type' => 'radio', |
||
| 74 | 'spacer' => '<span class="spacer"></span>', |
||
| 75 | 'choices' => array( |
||
| 76 | '' => __( 'Light', 'foogallery' ), |
||
| 77 | 'fiv-dark' => __( 'Dark', 'foogallery' ), |
||
| 78 | 'fiv-custom' => __( 'Custom', 'foogallery' ) |
||
| 79 | ) |
||
| 80 | ), |
||
| 81 | array( |
||
| 82 | 'id' => 'theme_custom_bgcolor', |
||
| 83 | 'title' => __('Background Color', 'foogallery'), |
||
| 84 | 'section' => __( 'Custom Theme Colors', 'foogallery' ), |
||
| 85 | 'type' => 'colorpicker', |
||
| 86 | 'default' => '#FFFFFF', |
||
| 87 | 'opacity' => true |
||
| 88 | ), |
||
| 89 | array( |
||
| 90 | 'id' => 'theme_custom_textcolor', |
||
| 91 | 'title' => __('Text Color', 'foogallery'), |
||
| 92 | 'section' => __( 'Custom Theme Colors', 'foogallery' ), |
||
| 93 | 'type' => 'colorpicker', |
||
| 94 | 'default' => '#1b1b1b', |
||
| 95 | 'opacity' => true |
||
| 96 | ), |
||
| 97 | array( |
||
| 98 | 'id' => 'theme_custom_hovercolor', |
||
| 99 | 'title' => __('Hover BG Color', 'foogallery'), |
||
| 100 | 'section' => __( 'Custom Theme Colors', 'foogallery' ), |
||
| 101 | 'type' => 'colorpicker', |
||
| 102 | 'default' => '#F2F2F2', |
||
| 103 | 'opacity' => true |
||
| 104 | ), |
||
| 105 | array( |
||
| 106 | 'id' => 'theme_custom_bordercolor', |
||
| 107 | 'title' => __('Border Color', 'foogallery'), |
||
| 108 | 'section' => __( 'Custom Theme Colors', 'foogallery' ), |
||
| 109 | 'type' => 'colorpicker', |
||
| 110 | 'default' => '#e6e6e6', |
||
| 111 | 'opacity' => true |
||
| 112 | ), |
||
| 113 | array( |
||
| 114 | 'id' => 'thumbnail_size', |
||
| 115 | 'title' => __('Thumbnail Size', 'foogallery-image-viewer'), |
||
| 116 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 117 | 'desc' => __('Choose the size of your thumbs.', 'foogallery-image-viewer'), |
||
| 118 | 'type' => 'thumb_size', |
||
| 119 | 'default' => array( |
||
| 120 | 'width' => 640, |
||
| 121 | 'height' => 360, |
||
| 122 | 'crop' => true |
||
| 123 | ) |
||
| 124 | ), |
||
| 125 | array( |
||
| 126 | 'id' => 'thumbnail_link', |
||
| 127 | 'title' => __('Thumbnail Link', 'foogallery-image-viewer'), |
||
| 128 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
| 129 | 'default' => 'image' , |
||
| 130 | 'type' => 'thumb_link', |
||
| 131 | 'spacer' => '<span class="spacer"></span>', |
||
| 132 | 'desc' => __('You can choose to either link each thumbnail to the full size image or to the image\'s attachment page.', 'foogallery-image-viewer') |
||
| 133 | ), |
||
| 134 | array( |
||
| 135 | 'id' => 'text-prev', |
||
| 136 | 'title' => __( '"Prev" Text', 'foogallery' ), |
||
| 137 | 'section' => __( 'Language Settings', 'foogallery' ), |
||
| 138 | 'type' => 'text', |
||
| 139 | 'default' => __('Prev', 'foogallery') |
||
| 140 | ), |
||
| 141 | array( |
||
| 142 | 'id' => 'text-of', |
||
| 143 | 'title' => __( '"of" Text', 'foogallery' ), |
||
| 144 | 'section' => __( 'Language Settings', 'foogallery' ), |
||
| 145 | 'type' => 'text', |
||
| 146 | 'default' => __('of', 'foogallery') |
||
| 147 | ), |
||
| 148 | array( |
||
| 149 | 'id' => 'text-next', |
||
| 150 | 'title' => __( '"Next" Text', 'foogallery' ), |
||
| 151 | 'section' => __( 'Language Settings', 'foogallery' ), |
||
| 152 | 'type' => 'text', |
||
| 153 | 'default' => __('Next', 'foogallery') |
||
| 154 | ) |
||
| 155 | ) |
||
| 156 | ); |
||
| 157 | |||
| 158 | return $gallery_templates; |
||
| 159 | } |
||
| 160 | |||
| 252 | } |
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.