| 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 | ||
| 195 | 	public function get_fields( $cmb, $section, $args ) { | ||
| 196 | $cmb->add_field( | ||
| 197 | array( | ||
| 198 | 'id' => 'settings_' . $section . '_sharing', | ||
| 199 | 'type' => 'title', | ||
| 200 | 'name' => $args['title'], | ||
| 201 | 'default' => $args['title'], | ||
| 202 | 'description' => $args['desc'], | ||
| 203 | ) | ||
| 204 | ); | ||
| 205 | 		if ( 'global' === $section ) { | ||
| 206 | $cmb->add_field( | ||
| 207 | array( | ||
| 208 | 'name' => esc_html__( 'Disable all', 'lsx-sharing' ), | ||
| 209 | 'id' => $section . '_disable_all', | ||
| 210 | 'description' => esc_html__( 'Disable all share buttons on the site', 'lsx-sharing' ), | ||
| 211 | 'type' => 'checkbox', | ||
| 212 | ) | ||
| 213 | ); | ||
| 214 | 		} else { | ||
| 215 | $cmb->add_field( | ||
| 216 | array( | ||
| 217 | 'name' => esc_html__( 'Disable', 'lsx-sharing' ), | ||
| 218 | 'id' => $section . '_disable_pt', | ||
| 219 | 'description' => esc_html__( 'Disable the share buttons on this post type', 'lsx-sharing' ), | ||
| 220 | 'type' => 'checkbox', | ||
| 221 | ) | ||
| 222 | ); | ||
| 223 | } | ||
| 224 | |||
| 225 | $cmb->add_field( | ||
| 226 | array( | ||
| 227 | 'name' => esc_html__( 'Label text', 'lsx-sharing' ), | ||
| 228 | 'id' => $section . '_label_text', | ||
| 229 | 'description' => esc_html__( 'A default label for the sharing.', 'lsx-sharing' ), | ||
| 230 | 'type' => 'text', | ||
| 231 | ) | ||
| 232 | ); | ||
| 233 | 		if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'facebook' ) ) ) { | ||
| 234 | $cmb->add_field( | ||
| 235 | array( | ||
| 236 | 'name' => esc_html__( 'Disable Facebook', 'lsx-sharing' ), | ||
| 237 | 'id' => $section . '_disable_facebook', | ||
| 238 | 'description' => esc_html__( 'Disable Facebook share button.', 'lsx-sharing' ), | ||
| 239 | 'type' => 'checkbox', | ||
| 240 | ) | ||
| 241 | ); | ||
| 242 | } | ||
| 243 | 		if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'twitter' ) ) ) { | ||
| 244 | $cmb->add_field( | ||
| 245 | array( | ||
| 246 | 'name' => esc_html__( 'Disable Twitter', 'lsx-sharing' ), | ||
| 247 | 'id' => $section . '_disable_twitter', | ||
| 248 | 'description' => esc_html__( 'Disable Twitter share button.', 'lsx-sharing' ), | ||
| 249 | 'type' => 'checkbox', | ||
| 250 | ) | ||
| 251 | ); | ||
| 252 | } | ||
| 253 | 		if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'pinterest' ) ) ) { | ||
| 254 | $cmb->add_field( | ||
| 255 | array( | ||
| 256 | 'name' => esc_html__( 'Disable Pinterest', 'lsx-sharing' ), | ||
| 257 | 'id' => $section . '_disable_pinterest', | ||
| 258 | 'description' => esc_html__( 'Disable Pinterest button.', 'lsx-sharing' ), | ||
| 259 | 'type' => 'checkbox', | ||
| 260 | ) | ||
| 261 | ); | ||
| 262 | } | ||
| 263 | |||
| 264 | do_action( 'lsx_sharing_settings_section', $cmb, $section ); | ||
| 265 | $cmb->add_field( | ||
| 266 | array( | ||
| 267 | 'id' => $section . '_title_closing', | ||
| 268 | 'type' => 'tab_closing', | ||
| 269 | ) | ||
| 273 |