| Conditions | 2 |
| Paths | 2 |
| Total Lines | 246 |
| Code Lines | 160 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| 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 |
||
| 51 | public function customize_register( $wp_customize ) { |
||
| 52 | /** |
||
| 53 | * Checkout. |
||
| 54 | */ |
||
| 55 | |||
| 56 | $wp_customize->add_section( 'lsx-wc-checkout', array( |
||
| 57 | 'title' => esc_html__( 'LSX Checkout', 'lsx-customizer' ), |
||
| 58 | 'description' => esc_html__( 'Change the WooCommerce checkout settings.', 'lsx-customizer' ), |
||
| 59 | 'panel' => 'woocommerce', |
||
| 60 | 'priority' => 3, |
||
| 61 | ) ); |
||
| 62 | |||
| 63 | $wp_customize->add_setting( 'lsx_checkout_steps', array( |
||
| 64 | 'default' => true, |
||
| 65 | 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
||
| 66 | ) ); |
||
| 67 | |||
| 68 | $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_checkout_steps', array( |
||
| 69 | 'label' => esc_html__( 'Steps', 'lsx-customizer' ), |
||
| 70 | 'description' => esc_html__( 'Enable the checkout steps header.', 'lsx-customizer' ), |
||
| 71 | 'section' => 'lsx-wc-checkout', |
||
| 72 | 'settings' => 'lsx_checkout_steps', |
||
| 73 | 'type' => 'checkbox', |
||
| 74 | 'priority' => 1, |
||
| 75 | ) ) ); |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Checkout Layout |
||
| 79 | */ |
||
| 80 | $wp_customize->add_setting( 'lsx_wc_checkout_layout', array( |
||
| 81 | 'default' => 'default', |
||
| 82 | 'sanitize_callback' => array( $this, 'sanitize_select' ), |
||
| 83 | ) ); |
||
| 84 | |||
| 85 | $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_checkout_layout', array( |
||
| 86 | 'label' => esc_html__( 'Layout', 'lsx-customizer' ), |
||
| 87 | 'description' => esc_html__( 'WooCommerce checkout layout.', 'lsx-customizer' ), |
||
| 88 | 'section' => 'lsx-wc-checkout', |
||
| 89 | 'settings' => 'lsx_wc_checkout_layout', |
||
| 90 | 'type' => 'select', |
||
| 91 | 'priority' => 2, |
||
| 92 | 'choices' => array( |
||
| 93 | 'default' => esc_html__( 'Default', 'lsx-customizer' ), |
||
| 94 | 'stacked' => esc_html__( 'Stacked', 'lsx-customizer' ), |
||
| 95 | 'columns' => esc_html__( 'Columns', 'lsx-customizer' ), |
||
| 96 | ), |
||
| 97 | ) ) ); |
||
| 98 | |||
| 99 | $wp_customize->add_setting( 'lsx_wc_checkout_thankyou_page', array( |
||
| 100 | 'default' => '0', |
||
| 101 | 'sanitize_callback' => array( $this, 'sanitize_select' ), |
||
| 102 | ) ); |
||
| 103 | |||
| 104 | $choices = array( |
||
| 105 | '0' => esc_html__( 'Default', 'lsx-customizer' ), |
||
| 106 | ); |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Distraction Free Checkout |
||
| 110 | */ |
||
| 111 | $wp_customize->add_setting( 'lsx_distraction_free_checkout', array( |
||
| 112 | 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
||
| 113 | ) ); |
||
| 114 | |||
| 115 | $wp_customize->add_control( new WP_Customize_Control( |
||
| 116 | $wp_customize, |
||
| 117 | 'lsx_distraction_free_checkout', |
||
| 118 | array( |
||
| 119 | 'label' => esc_html__( 'Distraction Free Checkout', 'lsx-customizer' ), |
||
| 120 | 'description' => esc_html__( 'Removes all clutter from the checkout, allowing the customer to focus entirely on that procedure. Removes the stepped cart and checkout.', 'lsx-customizer' ), |
||
| 121 | 'section' => 'lsx-wc-checkout', |
||
| 122 | 'settings' => 'lsx_distraction_free_checkout', |
||
| 123 | 'type' => 'checkbox', |
||
| 124 | 'priority' => 3, |
||
| 125 | ) |
||
| 126 | ) ); |
||
| 127 | |||
| 128 | /** |
||
| 129 | * Two Step Checkout |
||
| 130 | */ |
||
| 131 | $wp_customize->add_setting( 'lsx_two_step_checkout', array( |
||
| 132 | 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
||
| 133 | ) ); |
||
| 134 | |||
| 135 | $wp_customize->add_control( new WP_Customize_Control( |
||
| 136 | $wp_customize, |
||
| 137 | 'lsx_two_step_checkout', |
||
| 138 | array( |
||
| 139 | 'label' => esc_html__( 'Two Step Checkout', 'lsx-customizer' ), |
||
| 140 | 'description' => esc_html__( 'Separates the customer details collection form, and the order summary / payment details form in to two separate pages. Removes the stepped cart and checkout.', 'lsx-customizer' ), |
||
| 141 | 'section' => 'lsx-wc-checkout', |
||
| 142 | 'settings' => 'lsx_two_step_checkout', |
||
| 143 | 'type' => 'checkbox', |
||
| 144 | 'priority' => 4, |
||
| 145 | ) |
||
| 146 | ) ); |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Thank you page options |
||
| 150 | */ |
||
| 151 | $pages = get_pages(); |
||
| 152 | |||
| 153 | foreach ( $pages as $key => $page ) { |
||
| 154 | $choices[ $page->ID ] = $page->post_title; |
||
| 155 | } |
||
| 156 | |||
| 157 | $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_checkout_thankyou_page', array( |
||
| 158 | 'label' => esc_html__( 'Thank You Page', 'lsx-customizer' ), |
||
| 159 | 'description' => esc_html__( 'WooCommerce checkout thank you page.', 'lsx-customizer' ), |
||
| 160 | 'section' => 'lsx-wc-checkout', |
||
| 161 | 'settings' => 'lsx_wc_checkout_thankyou_page', |
||
| 162 | 'type' => 'select', |
||
| 163 | 'priority' => 5, |
||
| 164 | 'choices' => $choices, |
||
| 165 | ) ) ); |
||
| 166 | |||
| 167 | $wp_customize->add_setting( 'lsx_wc_checkout_extra_html', array( |
||
| 168 | 'default' => '', |
||
| 169 | 'sanitize_callback' => 'wp_kses_post', |
||
| 170 | ) ); |
||
| 171 | |||
| 172 | $wp_customize->add_control( new LSX_Customizer_Wysiwyg_Control( $wp_customize, 'lsx_wc_checkout_extra_html', array( |
||
| 173 | 'label' => esc_html__( 'Extra HTML', 'lsx-customizer' ), |
||
| 174 | 'description' => esc_html__( 'Extra HTML to display at checkout page (bottom/right).', 'lsx-customizer' ), |
||
| 175 | 'section' => 'lsx-wc-checkout', |
||
| 176 | 'settings' => 'lsx_wc_checkout_extra_html', |
||
| 177 | 'priority' => 6, |
||
| 178 | 'type' => 'wysiwyg', |
||
| 179 | ) ) ); |
||
| 180 | |||
| 181 | /** |
||
| 182 | * Cart. |
||
| 183 | */ |
||
| 184 | |||
| 185 | $wp_customize->add_setting( 'lsx_wc_cart_menu_item_style', array( |
||
| 186 | 'default' => 'extended', |
||
| 187 | 'sanitize_callback' => array( $this, 'sanitize_select' ), |
||
| 188 | ) ); |
||
| 189 | |||
| 190 | $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_cart_menu_item_style', array( |
||
| 191 | 'label' => esc_html__( 'Menu Item Style', 'lsx-customizer' ), |
||
| 192 | 'description' => esc_html__( 'WooCommerce menu item cart style.', 'lsx-customizer' ), |
||
| 193 | 'section' => 'lsx-wc-cart', |
||
| 194 | 'settings' => 'lsx_wc_cart_menu_item_style', |
||
| 195 | 'type' => 'select', |
||
| 196 | 'priority' => 2, |
||
| 197 | 'choices' => array( |
||
| 198 | 'simple' => esc_html__( 'Simple', 'lsx-customizer' ), |
||
| 199 | 'extended' => esc_html__( 'Extended', 'lsx-customizer' ), |
||
| 200 | ), |
||
| 201 | ) ) ); |
||
| 202 | |||
| 203 | $wp_customize->add_setting( 'lsx_wc_cart_menu_item_position', array( |
||
| 204 | 'default' => 'main-menu-in', |
||
| 205 | 'sanitize_callback' => array( $this, 'sanitize_select' ), |
||
| 206 | ) ); |
||
| 207 | |||
| 208 | $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_cart_menu_item_position', array( |
||
| 209 | 'label' => esc_html__( 'Menu Item Position', 'lsx-customizer' ), |
||
| 210 | 'description' => esc_html__( 'WooCommerce menu item cart position.', 'lsx-customizer' ), |
||
| 211 | 'section' => 'lsx-wc-cart', |
||
| 212 | 'settings' => 'lsx_wc_cart_menu_item_position', |
||
| 213 | 'type' => 'select', |
||
| 214 | 'priority' => 3, |
||
| 215 | 'choices' => array( |
||
| 216 | 'main-menu-in' => esc_html__( 'Main Menu (as last item)', 'lsx-customizer' ), |
||
| 217 | 'main-menu-out' => esc_html__( 'Main Menu (as last item, right aligned)', 'lsx-customizer' ), |
||
| 218 | 'top-menu-left' => esc_html__( 'Top Menu (left)', 'lsx-customizer' ), |
||
| 219 | 'top-menu-right' => esc_html__( 'Top Menu (right)', 'lsx-customizer' ), |
||
| 220 | ), |
||
| 221 | ) ) ); |
||
| 222 | |||
| 223 | $wp_customize->add_setting( 'lsx_wc_cart_extra_html', array( |
||
| 224 | 'default' => '', |
||
| 225 | 'sanitize_callback' => 'wp_kses_post', |
||
| 226 | ) ); |
||
| 227 | |||
| 228 | $wp_customize->add_control( new LSX_Customizer_Wysiwyg_Control( $wp_customize, 'lsx_wc_cart_extra_html', array( |
||
| 229 | 'label' => esc_html__( 'Extra HTML', 'lsx-customizer' ), |
||
| 230 | 'description' => esc_html__( 'Extra HTML to display at cart page (bottom/left).', 'lsx-customizer' ), |
||
| 231 | 'section' => 'lsx-wc-cart', |
||
| 232 | 'settings' => 'lsx_wc_cart_extra_html', |
||
| 233 | 'priority' => 4, |
||
| 234 | 'type' => 'wysiwyg', |
||
| 235 | ) ) ); |
||
| 236 | |||
| 237 | /** |
||
| 238 | * My Account. |
||
| 239 | */ |
||
| 240 | |||
| 241 | $wp_customize->add_section( 'lsx-wc-my-account', array( |
||
| 242 | 'title' => esc_html__( 'LSX My Account', 'lsx-customizer' ), |
||
| 243 | 'description' => esc_html__( 'Change the WooCommerce My Account settings.', 'lsx-customizer' ), |
||
| 244 | 'panel' => 'woocommerce', |
||
| 245 | 'priority' => 4, |
||
| 246 | ) ); |
||
| 247 | |||
| 248 | $wp_customize->add_setting( 'lsx_wc_my_account_menu_item', array( |
||
| 249 | 'default' => false, |
||
| 250 | 'sanitize_callback' => array( $this, 'sanitize_checkbox' ), |
||
| 251 | ) ); |
||
| 252 | |||
| 253 | $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_my_account_menu_item', array( |
||
| 254 | 'label' => esc_html__( 'Menu Item', 'lsx-customizer' ), |
||
| 255 | 'description' => esc_html__( 'Enable the My Account menu item.', 'lsx-customizer' ), |
||
| 256 | 'section' => 'lsx-wc-my-account', |
||
| 257 | 'settings' => 'lsx_wc_my_account_menu_item', |
||
| 258 | 'type' => 'checkbox', |
||
| 259 | 'priority' => 1, |
||
| 260 | ) ) ); |
||
| 261 | |||
| 262 | $wp_customize->add_setting( 'lsx_wc_my_account_menu_item_style', array( |
||
| 263 | 'default' => 'extended', |
||
| 264 | 'sanitize_callback' => array( $this, 'sanitize_select' ), |
||
| 265 | ) ); |
||
| 266 | |||
| 267 | $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_my_account_menu_item_style', array( |
||
| 268 | 'label' => esc_html__( 'Menu Item Style', 'lsx-customizer' ), |
||
| 269 | 'description' => esc_html__( 'WooCommerce menu item My Account style.', 'lsx-customizer' ), |
||
| 270 | 'section' => 'lsx-wc-my-account', |
||
| 271 | 'settings' => 'lsx_wc_my_account_menu_item_style', |
||
| 272 | 'type' => 'select', |
||
| 273 | 'priority' => 2, |
||
| 274 | 'choices' => array( |
||
| 275 | 'simple' => esc_html__( 'Simple', 'lsx-customizer' ), |
||
| 276 | 'extended' => esc_html__( 'Extended', 'lsx-customizer' ), |
||
| 277 | ), |
||
| 278 | ) ) ); |
||
| 279 | |||
| 280 | $wp_customize->add_setting( 'lsx_wc_my_account_menu_item_position', array( |
||
| 281 | 'default' => 'main-menu-in', |
||
| 282 | 'sanitize_callback' => array( $this, 'sanitize_select' ), |
||
| 283 | ) ); |
||
| 284 | |||
| 285 | $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'lsx_wc_my_account_menu_item_position', array( |
||
| 286 | 'label' => esc_html__( 'Menu Item Position', 'lsx-customizer' ), |
||
| 287 | 'description' => esc_html__( 'WooCommerce menu item My Account position.', 'lsx-customizer' ), |
||
| 288 | 'section' => 'lsx-wc-my-account', |
||
| 289 | 'settings' => 'lsx_wc_my_account_menu_item_position', |
||
| 290 | 'type' => 'select', |
||
| 291 | 'priority' => 3, |
||
| 292 | 'choices' => array( |
||
| 293 | 'main-menu-in' => esc_html__( 'Main Menu (as last item)', 'lsx-customizer' ), |
||
| 294 | 'main-menu-out' => esc_html__( 'Main Menu (as last item, right aligned)', 'lsx-customizer' ), |
||
| 295 | 'top-menu-left' => esc_html__( 'Top Menu (left)', 'lsx-customizer' ), |
||
| 296 | 'top-menu-right' => esc_html__( 'Top Menu (right)', 'lsx-customizer' ), |
||
| 297 | ), |
||
| 722 |