Conditions | 1 |
Paths | 1 |
Total Lines | 86 |
Code Lines | 65 |
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 |
||
41 | function add_template( $gallery_templates ) { |
||
42 | $gallery_templates[] = array( |
||
43 | 'slug' => 'default', |
||
44 | 'name' => __( 'Responsive Image Gallery', 'foogallery' ), |
||
45 | 'lazyload_support' => true, |
||
46 | 'preview_css' => FOOGALLERY_DEFAULT_GALLERY_TEMPLATE_URL . 'css/gallery-default.css', |
||
47 | 'admin_js' => FOOGALLERY_DEFAULT_GALLERY_TEMPLATE_URL . 'js/admin-gallery-default.js', |
||
48 | 'fields' => array( |
||
49 | array( |
||
50 | 'id' => 'lightbox', |
||
51 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
52 | 'desc' => __( 'Choose which lightbox you want to use. The lightbox will only work if you set the thumbnail link to "Full Size Image".', 'foogallery' ), |
||
53 | 'type' => 'lightbox', |
||
54 | ), |
||
55 | array( |
||
56 | 'id' => 'spacing', |
||
57 | 'title' => __( 'Spacing', 'foogallery' ), |
||
58 | 'desc' => __( 'The spacing or gap between thumbnails in the gallery.', 'foogallery' ), |
||
59 | 'type' => 'select', |
||
60 | 'default' => 'spacing-width-10', |
||
61 | 'choices' => array( |
||
62 | 'spacing-width-0' => __( '0 pixels', 'foogallery' ), |
||
63 | 'spacing-width-5' => __( '5 pixels', 'foogallery' ), |
||
64 | 'spacing-width-10' => __( '10 pixels', 'foogallery' ), |
||
65 | 'spacing-width-15' => __( '15 pixels', 'foogallery' ), |
||
66 | 'spacing-width-20' => __( '20 pixels', 'foogallery' ), |
||
67 | 'spacing-width-25' => __( '25 pixels', 'foogallery' ), |
||
68 | ), |
||
69 | ), |
||
70 | array( |
||
71 | 'id' => 'alignment', |
||
72 | 'title' => __( 'Alignment', 'foogallery' ), |
||
73 | 'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery.', 'foogallery' ), |
||
74 | 'default' => 'alignment-center', |
||
75 | 'type' => 'select', |
||
76 | 'choices' => array( |
||
77 | 'alignment-left' => __( 'Left', 'foogallery' ), |
||
78 | 'alignment-center' => __( 'Center', 'foogallery' ), |
||
79 | 'alignment-right' => __( 'Right', 'foogallery' ), |
||
80 | ) |
||
81 | ), |
||
82 | array( |
||
83 | 'id' => 'loading_animation', |
||
84 | 'title' => __( 'Loading Indicator', 'foogallery' ), |
||
85 | 'default' => 'yes', |
||
86 | 'type' => 'radio', |
||
87 | 'choices' => array( |
||
88 | 'yes' => __( 'Show Thumbnail Loading Indicator', 'foogallery' ), |
||
89 | 'no' => __( 'Disabled', 'foogallery' ) |
||
90 | ), |
||
91 | 'spacer' => '<span class="spacer"></span>', |
||
92 | 'desc' => __( 'By default, an animated loading animation indicator is shown before the thumbnails have loaded. You can disable the loader if you want.', 'foogallery' ), |
||
93 | ), |
||
94 | array( |
||
95 | 'id' => 'thumbnail_dimensions', |
||
96 | 'title' => __( 'Size', 'foogallery' ), |
||
97 | 'desc' => __( 'Choose the size of your thumbnails.', 'foogallery' ), |
||
98 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
99 | 'type' => 'thumb_size', |
||
100 | 'default' => array( |
||
101 | 'width' => get_option( 'thumbnail_size_w' ), |
||
102 | 'height' => get_option( 'thumbnail_size_h' ), |
||
103 | 'crop' => true, |
||
104 | ), |
||
105 | ), |
||
106 | array( |
||
107 | 'id' => 'thumbnail_link', |
||
108 | 'title' => __( 'Link', 'foogallery' ), |
||
109 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
110 | 'default' => 'image', |
||
111 | 'type' => 'thumb_link', |
||
112 | 'spacer' => '<span class="spacer"></span>', |
||
113 | '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' ), |
||
114 | ) |
||
115 | // array( |
||
116 | // 'id' => 'thumb_preview', |
||
117 | // 'title' => __( 'Preview', 'foogallery' ), |
||
118 | // 'desc' => __( 'This is what your gallery thumbnails will look like.', 'foogallery' ), |
||
119 | // 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
120 | // 'type' => 'default_thumb_preview', |
||
121 | // ) |
||
122 | ) |
||
123 | ); |
||
124 | |||
125 | return $gallery_templates; |
||
126 | } |
||
127 | |||
219 | } |
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.