Conditions | 1 |
Paths | 1 |
Total Lines | 127 |
Code Lines | 107 |
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 |
||
57 | function add_template( $gallery_templates ) { |
||
58 | $gallery_templates[] = array( |
||
59 | 'slug' => 'masonry', |
||
60 | 'name' => __( 'Masonry Image Gallery', 'foogallery' ), |
||
61 | 'preview_support' => true, |
||
62 | 'common_fields_support' => true, |
||
63 | 'lazyload_support' => true, |
||
64 | 'paging_support' => true, |
||
65 | 'mandatory_classes' => 'fg-masonry', |
||
66 | 'thumbnail_dimensions' => true, |
||
67 | 'fields' => array( |
||
68 | array( |
||
69 | 'id' => 'thumbnail_width', |
||
70 | 'title' => __( 'Thumb Width', 'foogallery' ), |
||
71 | 'desc' => __( 'Choose the width of your thumbnails. Thumbnails will be generated on the fly and cached once generated', 'foogallery' ), |
||
72 | 'section' => __( 'General', 'foogallery' ), |
||
73 | 'type' => 'number', |
||
74 | 'class' => 'small-text', |
||
75 | 'default' => 150, |
||
76 | 'step' => '1', |
||
77 | 'min' => '0', |
||
78 | 'row_data'=> array( |
||
79 | 'data-foogallery-change-selector' => 'input', |
||
80 | 'data-foogallery-preview' => 'shortcode' |
||
81 | ) |
||
82 | ), |
||
83 | array( |
||
84 | 'id' => 'layout', |
||
85 | 'title' => __( 'Masonry Layout', 'foogallery' ), |
||
86 | 'desc' => __( 'Choose a fixed width thumb layout, or responsive columns.', 'foogallery' ), |
||
87 | 'section' => __( 'General', 'foogallery' ), |
||
88 | 'type' => 'radio', |
||
89 | 'choices' => array( |
||
90 | 'fixed' => __( 'Fixed Width', 'foogallery' ), |
||
91 | 'col2' => __( '2 Columns', 'foogallery' ), |
||
92 | 'col3' => __( '3 Columns', 'foogallery' ), |
||
93 | 'col4' => __( '4 Columns', 'foogallery' ), |
||
94 | 'col5' => __( '5 Columns', 'foogallery' ) |
||
95 | ), |
||
96 | 'default' => 'fixed', |
||
97 | 'row_data'=> array( |
||
98 | 'data-foogallery-change-selector' => 'input:radio', |
||
99 | 'data-foogallery-value-selector' => 'input:checked', |
||
100 | 'data-foogallery-preview' => 'shortcode' |
||
101 | ) |
||
102 | ), |
||
103 | array( |
||
104 | 'id' => 'gutter_width', |
||
105 | 'title' => __( 'Gutter Width', 'foogallery' ), |
||
106 | 'desc' => __( 'The spacing between your thumbnails. Only applicable when using a fixed layout!', 'foogallery' ), |
||
107 | 'section' => __( 'General', 'foogallery' ), |
||
108 | 'type' => 'number', |
||
109 | 'class' => 'small-text', |
||
110 | 'default' => 10, |
||
111 | 'step' => '1', |
||
112 | 'min' => '0', |
||
113 | 'row_data'=> array( |
||
114 | 'data-foogallery-hidden' => true, |
||
115 | 'data-foogallery-change-selector' => 'input', |
||
116 | 'data-foogallery-value-selector' => 'input', |
||
117 | 'data-foogallery-show-when-field' => 'layout', |
||
118 | 'data-foogallery-show-when-field-value' => 'fixed', |
||
119 | 'data-foogallery-preview' => 'shortcode', |
||
120 | ) |
||
121 | ), |
||
122 | array( |
||
123 | 'id' => 'gutter_percent', |
||
124 | 'title' => __( 'Gutter Size', 'foogallery' ), |
||
125 | 'desc' => __( 'Choose a gutter size when using responsive columns.', 'foogallery' ), |
||
126 | 'section' => __( 'General', 'foogallery' ), |
||
127 | 'type' => 'radio', |
||
128 | 'choices' => array( |
||
129 | 'fg-gutter-none' => __( 'No Gutter', 'foogallery' ), |
||
130 | '' => __( 'Normal Size Gutter', 'foogallery' ), |
||
131 | 'fg-gutter-large' => __( 'Larger Gutter', 'foogallery' ) |
||
132 | ), |
||
133 | 'default' => '', |
||
134 | 'row_data'=> array( |
||
135 | 'data-foogallery-hidden' => true, |
||
136 | 'data-foogallery-change-selector' => 'input:radio', |
||
137 | 'data-foogallery-value-selector' => 'input:checked', |
||
138 | 'data-foogallery-show-when-field' => 'layout', |
||
139 | 'data-foogallery-show-when-field-operator' => '!==', |
||
140 | 'data-foogallery-show-when-field-value' => 'fixed', |
||
141 | 'data-foogallery-preview' => 'class' |
||
142 | ) |
||
143 | ), |
||
144 | array( |
||
145 | 'id' => 'alignment', |
||
146 | 'title' => __( 'Alignment', 'foogallery' ), |
||
147 | 'desc' => __( 'You can choose to center align your images or leave them at the default (left). Only applicable when using a fixed layout!', 'foogallery' ), |
||
148 | 'section' => __( 'General', 'foogallery' ), |
||
149 | 'type' => 'radio', |
||
150 | 'spacer' => '<span class="spacer"></span>', |
||
151 | 'choices' => array( |
||
152 | '' => __( 'Left', 'foogallery' ), |
||
153 | 'fg-center' => __( 'Center', 'foogallery' ) |
||
154 | ), |
||
155 | 'default' => 'fg-center', |
||
156 | 'row_data'=> array( |
||
157 | 'data-foogallery-hidden' => true, |
||
158 | 'data-foogallery-show-when-field' => 'layout', |
||
159 | 'data-foogallery-show-when-field-value' => 'fixed', |
||
160 | 'data-foogallery-change-selector' => 'input:radio', |
||
161 | 'data-foogallery-preview' => 'class' |
||
162 | ) |
||
163 | ), |
||
164 | array( |
||
165 | 'id' => 'thumbnail_link', |
||
166 | 'title' => __( 'Thumb Link', 'foogallery' ), |
||
167 | 'default' => 'image' , |
||
168 | 'type' => 'thumb_link', |
||
169 | 'desc' => __( 'You can choose to link each thumbnail to the full size image, or to the image\'s attachment page, or you can choose to not link to anything', 'foogallery' ), |
||
170 | ), |
||
171 | array( |
||
172 | 'id' => 'lightbox', |
||
173 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
174 | 'desc' => __( 'Choose which lightbox you want to display images with. The lightbox will only work if you set the thumbnail link to "Full Size Image"', 'foogallery' ), |
||
175 | 'type' => 'lightbox', |
||
176 | 'default' => 'none', |
||
177 | ), |
||
178 | ), |
||
179 | ); |
||
180 | |||
181 | |||
182 | return $gallery_templates; |
||
183 | } |
||
184 | |||
331 | } |
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.