| Conditions | 7 |
| Paths | 11 |
| Total Lines | 56 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 49 | public function customizer( WP_Customize_Manager $wp_customize ) { |
||
| 50 | |||
| 51 | if ( ! isset( $wp_customize->selective_refresh ) ) { |
||
| 52 | return; |
||
| 53 | } |
||
| 54 | |||
| 55 | $wp_customize->add_panel( 'wpsc', array( |
||
| 56 | 'title' => __( 'Store', 'wp-e-commerce' ), |
||
| 57 | 'description' => __( 'Presentational settings for your store.', 'wp-e-commerce' ), |
||
| 58 | 'priority' => 150, |
||
| 59 | ) ); |
||
| 60 | |||
| 61 | foreach ( $this->sections as $name => $label ) { |
||
| 62 | $wp_customize->add_section( $name, array( |
||
| 63 | 'title' => $label, |
||
| 64 | 'panel' => 'wpsc', |
||
| 65 | ) ); |
||
| 66 | } |
||
| 67 | |||
| 68 | foreach ( $this->settings as $name => $settings ) { |
||
| 69 | |||
| 70 | $wp_customize->add_setting( $name, $settings['setting'] ); |
||
| 71 | |||
| 72 | if ( isset( $settings['control']['class'] ) ) { |
||
| 73 | |||
| 74 | $class = $settings['control']['class']; |
||
| 75 | |||
| 76 | foreach ( $settings['control']['settings'] as $s ) { |
||
| 77 | $wp_customize->add_setting( $s, array( |
||
| 78 | 'default' => '', |
||
| 79 | 'type' => 'option', |
||
| 80 | 'capability' => 'manage_options', |
||
| 81 | 'sanitize_callback' => 'absint' |
||
| 82 | ) ); |
||
| 83 | } |
||
| 84 | |||
| 85 | $wp_customize->add_control( |
||
| 86 | new $class( |
||
| 87 | $wp_customize, |
||
| 88 | $name, |
||
| 89 | array( |
||
| 90 | 'label' => $settings['control']['label'], |
||
| 91 | 'section' => $settings['control']['section'], |
||
| 92 | 'settings' => $settings['control']['settings'] |
||
| 93 | ) |
||
| 94 | ) |
||
| 95 | ); |
||
| 96 | } else { |
||
| 97 | $wp_customize->add_control( $name, $settings['control'] ); |
||
| 98 | } |
||
| 99 | |||
| 100 | if ( isset( $settings['partial'] ) ) { |
||
| 101 | $wp_customize->selective_refresh->add_partial( $name, $settings['partial'] ); |
||
| 102 | } |
||
| 103 | } |
||
| 104 | } |
||
| 105 | } |
||
| 108 |