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