Conditions | 11 |
Paths | 16 |
Total Lines | 74 |
Code Lines | 53 |
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 |
||
181 | public function get_fields( $cmb, $section, $args ) { |
||
182 | $cmb->add_field( |
||
183 | array( |
||
184 | 'id' => 'settings_' . $section . '_sharing', |
||
185 | 'type' => 'title', |
||
186 | 'name' => $args['title'], |
||
187 | 'default' => $args['title'], |
||
188 | 'description' => $args['desc'], |
||
189 | ) |
||
190 | ); |
||
191 | if ( 'global' === $section ) { |
||
192 | $cmb->add_field( |
||
193 | array( |
||
194 | 'name' => esc_html__( 'Disable all', 'lsx-sharing' ), |
||
195 | 'id' => $section . '_disable_all', |
||
196 | 'description' => esc_html__( 'Disable all share buttons on the site', 'lsx-sharing' ), |
||
197 | 'type' => 'checkbox', |
||
198 | ) |
||
199 | ); |
||
200 | } else { |
||
201 | $cmb->add_field( |
||
202 | array( |
||
203 | 'name' => esc_html__( 'Disable', 'lsx-sharing' ), |
||
204 | 'id' => $section . '_disable_pt', |
||
205 | 'description' => esc_html__( 'Disable the share buttons on this post type', 'lsx-sharing' ), |
||
206 | 'type' => 'checkbox', |
||
207 | ) |
||
208 | ); |
||
209 | } |
||
210 | |||
211 | $cmb->add_field( |
||
212 | array( |
||
213 | 'name' => esc_html__( 'Label text', 'lsx-sharing' ), |
||
214 | 'id' => $section . '_label_text', |
||
215 | 'description' => esc_html__( 'A default label for the sharing.', 'lsx-sharing' ), |
||
216 | 'type' => 'text', |
||
217 | ) |
||
218 | ); |
||
219 | if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'facebook' ) ) ) { |
||
220 | $cmb->add_field( |
||
221 | array( |
||
222 | 'name' => esc_html__( 'Disable Facebook', 'lsx-sharing' ), |
||
223 | 'id' => $section . '_disable_facebook', |
||
224 | 'description' => esc_html__( 'Disable Facebook share button.', 'lsx-sharing' ), |
||
225 | 'type' => 'checkbox', |
||
226 | ) |
||
227 | ); |
||
228 | } |
||
229 | if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'twitter' ) ) ) { |
||
230 | $cmb->add_field( |
||
231 | array( |
||
232 | 'name' => esc_html__( 'Disable Twitter', 'lsx-sharing' ), |
||
233 | 'id' => $section . '_disable_twitter', |
||
234 | 'description' => esc_html__( 'Disable Twitter share button.', 'lsx-sharing' ), |
||
235 | 'type' => 'checkbox', |
||
236 | ) |
||
237 | ); |
||
238 | } |
||
239 | if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'pinterest' ) ) ) { |
||
240 | $cmb->add_field( |
||
241 | array( |
||
242 | 'name' => esc_html__( 'Disable Pinterest', 'lsx-sharing' ), |
||
243 | 'id' => $section . '_disable_pinterest', |
||
244 | 'description' => esc_html__( 'Disable Pinterest button.', 'lsx-sharing' ), |
||
245 | 'type' => 'checkbox', |
||
246 | ) |
||
247 | ); |
||
248 | } |
||
249 | |||
250 | do_action( 'lsx_sharing_settings_section', $cmb, $section ); |
||
251 | $cmb->add_field( |
||
252 | array( |
||
253 | 'id' => $section . '_title_closing', |
||
254 | 'type' => 'tab_closing', |
||
255 | ) |
||
259 |