Conditions | 11 |
Paths | 32 |
Total Lines | 56 |
Code Lines | 30 |
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 |
||
59 | public function customizer( $wp_customize ) { |
||
60 | // Start panels. |
||
61 | if ( ! empty( $this->controls['panels'] ) ) { |
||
62 | foreach ( $this->controls['panels'] as $panel_slug => $args ) { |
||
63 | $this->add_panel( $panel_slug, $args, $wp_customize ); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | // Start sections. |
||
68 | if ( ! empty( $this->controls['sections'] ) ) { |
||
69 | foreach ( $this->controls['sections'] as $section_slug => $args ) { |
||
70 | $this->add_section( $section_slug, $args, $wp_customize ); |
||
71 | } |
||
72 | } |
||
73 | |||
74 | // Start settings. |
||
75 | if ( ! empty( $this->controls['settings'] ) ) { |
||
76 | foreach ( $this->controls['settings'] as $settings_slug => $args ) { |
||
77 | $this->add_setting( $settings_slug, $args, $wp_customize ); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | // Start fields. |
||
82 | if ( ! empty( $this->controls['fields'] ) ) { |
||
83 | foreach ( $this->controls['fields'] as $field_slug => $args ) { |
||
84 | $this->add_control( $field_slug, $args, $wp_customize ); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | // Start selective refresh. |
||
89 | if ( ! empty( $this->controls['selective_refresh'] ) ) { |
||
90 | foreach ( $this->controls['selective_refresh'] as $field_slug => $args ) { |
||
91 | $this->add_selective_refresh( $field_slug, $args, $wp_customize ); |
||
92 | } |
||
93 | } |
||
94 | |||
95 | $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; |
||
96 | $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; |
||
97 | $wp_customize->get_setting( 'background_color' )->transport = 'postMessage'; |
||
98 | |||
99 | $wp_customize->selective_refresh->add_partial( |
||
100 | 'blogname', |
||
101 | array( |
||
102 | 'selector' => 'h1.site-title a', |
||
103 | 'render_callback' => function() { |
||
104 | bloginfo( 'name' ); |
||
105 | }, |
||
106 | ) |
||
107 | ); |
||
108 | |||
109 | $wp_customize->selective_refresh->add_partial( |
||
110 | 'blogdescription', |
||
111 | array( |
||
112 | 'selector' => '.site-description', |
||
113 | 'render_callback' => function() { |
||
114 | bloginfo( 'description' ); |
||
115 | }, |
||
224 |