| Conditions | 1 |
| Paths | 1 |
| Total Lines | 159 |
| 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 |
||
| 38 | public function customize_register( $wp_customize ) { |
||
| 39 | $section_id = 'jetpack_search'; |
||
| 40 | $setting_prefix = Jetpack_Search_Options::OPTION_PREFIX; |
||
| 41 | |||
| 42 | $wp_customize->add_section( |
||
| 43 | $section_id, |
||
| 44 | array( |
||
| 45 | 'title' => esc_html__( 'Jetpack Search', 'jetpack' ), |
||
| 46 | 'description' => __( 'Use these settings to customize the search overlay.', 'jetpack' ), |
||
| 47 | 'capability' => 'edit_theme_options', |
||
| 48 | 'priority' => 200, |
||
| 49 | ) |
||
| 50 | ); |
||
| 51 | |||
| 52 | $id = $setting_prefix . 'color_theme'; |
||
| 53 | $wp_customize->add_setting( |
||
| 54 | $id, |
||
| 55 | array( |
||
| 56 | 'default' => 'light', |
||
| 57 | 'transport' => 'postMessage', |
||
| 58 | 'type' => 'option', |
||
| 59 | ) |
||
| 60 | ); |
||
| 61 | $wp_customize->add_control( |
||
| 62 | $id, |
||
| 63 | array( |
||
| 64 | 'label' => __( 'Theme', 'jetpack' ), |
||
| 65 | 'description' => __( 'A light or dark theme for your search overlay.', 'jetpack' ), |
||
| 66 | 'section' => $section_id, |
||
| 67 | 'type' => 'radio', |
||
| 68 | 'choices' => array( |
||
| 69 | 'light' => __( 'Light', 'jetpack' ), |
||
| 70 | 'dark' => __( 'Dark', 'jetpack' ), |
||
| 71 | ), |
||
| 72 | ) |
||
| 73 | ); |
||
| 74 | |||
| 75 | $id = $setting_prefix . 'opacity'; |
||
| 76 | $wp_customize->add_setting( |
||
| 77 | $id, |
||
| 78 | array( |
||
| 79 | 'default' => 97, |
||
| 80 | 'transport' => 'postMessage', |
||
| 81 | 'type' => 'option', |
||
| 82 | ) |
||
| 83 | ); |
||
| 84 | $wp_customize->add_control( |
||
| 85 | $id, |
||
| 86 | array( |
||
| 87 | 'type' => 'range', |
||
| 88 | 'section' => $section_id, |
||
| 89 | 'label' => __( 'Background Opacity', 'jetpack' ), |
||
| 90 | 'description' => __( 'Select and opacity for the search overlay.', 'jetpack' ), |
||
| 91 | 'input_attrs' => array( |
||
| 92 | 'min' => 85, |
||
| 93 | 'max' => 100, |
||
| 94 | 'step' => 0.5, |
||
| 95 | ), |
||
| 96 | ) |
||
| 97 | ); |
||
| 98 | |||
| 99 | $id = $setting_prefix . 'close_color'; |
||
| 100 | $wp_customize->add_setting( |
||
| 101 | $id, |
||
| 102 | array( |
||
| 103 | 'default' => '#BD3854', |
||
| 104 | 'transport' => 'postMessage', |
||
| 105 | 'type' => 'option', |
||
| 106 | ) |
||
| 107 | ); |
||
| 108 | $wp_customize->add_control( |
||
| 109 | new WP_Customize_Color_Control( |
||
| 110 | $wp_customize, |
||
| 111 | $id, |
||
| 112 | array( |
||
| 113 | 'label' => __( 'Close Button', 'jetpack' ), |
||
| 114 | 'description' => __( 'Select a color and position for the close button.', 'jetpack' ), |
||
| 115 | 'section' => $section_id, |
||
| 116 | ) |
||
| 117 | ) |
||
| 118 | ); |
||
| 119 | |||
| 120 | $id = $setting_prefix . 'highlight_color'; |
||
| 121 | $wp_customize->add_setting( |
||
| 122 | $id, |
||
| 123 | array( |
||
| 124 | 'default' => '#FFC', |
||
| 125 | 'transport' => 'postMessage', |
||
| 126 | 'type' => 'option', |
||
| 127 | ) |
||
| 128 | ); |
||
| 129 | $wp_customize->add_control( |
||
| 130 | new WP_Customize_Color_Control( |
||
| 131 | $wp_customize, |
||
| 132 | $id, |
||
| 133 | array( |
||
| 134 | 'label' => __( 'Highlight Search Terms', 'jetpack' ), |
||
| 135 | 'description' => __( 'Choose a color to highlight matching search terms.', 'jetpack' ), |
||
| 136 | 'section' => $section_id, |
||
| 137 | ) |
||
| 138 | ) |
||
| 139 | ); |
||
| 140 | |||
| 141 | $id = $setting_prefix . 'inf_scroll'; |
||
| 142 | $wp_customize->add_setting( |
||
| 143 | $id, |
||
| 144 | array( |
||
| 145 | 'default' => true, |
||
| 146 | 'transport' => 'postMessage', |
||
| 147 | 'type' => 'option', |
||
| 148 | ) |
||
| 149 | ); |
||
| 150 | $wp_customize->add_control( |
||
| 151 | $id, |
||
| 152 | array( |
||
| 153 | 'type' => 'checkbox', |
||
| 154 | 'section' => $section_id, |
||
| 155 | 'label' => __( 'Infinite Scroll Results', 'jetpack' ), |
||
| 156 | ) |
||
| 157 | ); |
||
| 158 | |||
| 159 | $id = $setting_prefix . 'show_logo'; |
||
| 160 | $wp_customize->add_setting( |
||
| 161 | $id, |
||
| 162 | array( |
||
| 163 | 'default' => true, |
||
| 164 | 'transport' => 'postMessage', |
||
| 165 | 'type' => 'option', |
||
| 166 | ) |
||
| 167 | ); |
||
| 168 | |||
| 169 | $wp_customize->add_control( |
||
| 170 | $id, |
||
| 171 | array( |
||
| 172 | 'type' => 'checkbox', |
||
| 173 | 'section' => $section_id, |
||
| 174 | 'label' => __( 'Display Magnifying Glass Logo', 'jetpack' ), |
||
| 175 | ) |
||
| 176 | ); |
||
| 177 | |||
| 178 | $id = $setting_prefix . 'show_powered_by'; |
||
| 179 | $wp_customize->add_setting( |
||
| 180 | $id, |
||
| 181 | array( |
||
| 182 | 'default' => true, |
||
| 183 | 'transport' => 'postMessage', |
||
| 184 | 'type' => 'option', |
||
| 185 | ) |
||
| 186 | ); |
||
| 187 | $wp_customize->add_control( |
||
| 188 | $id, |
||
| 189 | array( |
||
| 190 | 'type' => 'checkbox', |
||
| 191 | 'section' => $section_id, |
||
| 192 | 'label' => __( 'Display "Powered by Jetpack"', 'jetpack' ), |
||
| 193 | ) |
||
| 194 | ); |
||
| 195 | |||
| 196 | } |
||
| 197 | |||
| 200 |