| Conditions | 2 |
| Paths | 1 |
| Total Lines | 97 |
| Code Lines | 65 |
| 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 |
||
| 23 | function lsx_customizer_layout_controls( $lsx_controls ) { |
||
| 24 | $lsx_controls['sections']['lsx-layout'] = array( |
||
| 25 | 'title' => esc_html__( 'Layout', 'lsx' ), |
||
| 26 | 'description' => esc_html__( 'Change the layout sitewide. If your homepage is set to use a page with a template, the following will not apply to it.', 'lsx' ), |
||
| 27 | 'priority' => 22, |
||
| 28 | ); |
||
| 29 | |||
| 30 | $lsx_controls['settings']['lsx_header_fixed'] = array( |
||
| 31 | 'default' => false, |
||
| 32 | 'sanitize_callback' => 'lsx_sanitize_checkbox', |
||
| 33 | 'transport' => 'postMessage', |
||
| 34 | ); |
||
| 35 | |||
| 36 | $lsx_controls['fields']['lsx_header_fixed'] = array( |
||
| 37 | 'label' => esc_html__( 'Fixed Header', 'lsx' ), |
||
| 38 | 'section' => 'lsx-layout', |
||
| 39 | 'type' => 'checkbox', |
||
| 40 | ); |
||
| 41 | |||
| 42 | $lsx_controls['settings']['lsx_header_search'] = array( |
||
| 43 | 'default' => false, |
||
| 44 | 'sanitize_callback' => 'lsx_sanitize_checkbox', |
||
| 45 | 'transport' => 'postMessage', |
||
| 46 | ); |
||
| 47 | |||
| 48 | $lsx_controls['fields']['lsx_header_search'] = array( |
||
| 49 | 'label' => esc_html__( 'Search Box in Header', 'lsx' ), |
||
| 50 | 'section' => 'lsx-layout', |
||
| 51 | 'type' => 'checkbox', |
||
| 52 | ); |
||
| 53 | |||
| 54 | $lsx_controls['selective_refresh']['lsx_header_search'] = array( |
||
| 55 | 'selector' => '#lsx-header-search-css', |
||
| 56 | 'render_callback' => function() { |
||
| 57 | $search_form = get_theme_mod( 'lsx_header_search' ); |
||
| 58 | |||
| 59 | if ( false !== $search_form ) { |
||
| 60 | echo 'body #searchform { display: block; }'; |
||
| 61 | } else { |
||
| 62 | echo 'body #searchform { display: none; }'; |
||
| 63 | } |
||
| 64 | }, |
||
| 65 | ); |
||
| 66 | |||
| 67 | $lsx_controls['settings']['lsx_header_layout'] = array( |
||
| 68 | 'default' => 'inline', |
||
| 69 | 'type' => 'theme_mod', |
||
| 70 | 'transport' => 'postMessage', |
||
| 71 | ); |
||
| 72 | |||
| 73 | $lsx_controls['fields']['lsx_header_layout'] = array( |
||
| 74 | 'label' => esc_html__( 'Header', 'lsx' ), |
||
| 75 | 'section' => 'lsx-layout', |
||
| 76 | 'control' => 'LSX_Customize_Header_Layout_Control', |
||
| 77 | 'choices' => array( |
||
| 78 | 'central', |
||
| 79 | 'expanded', |
||
| 80 | 'inline', |
||
| 81 | ), |
||
| 82 | ); |
||
| 83 | |||
| 84 | $lsx_controls['settings']['lsx_header_mobile_layout'] = array( |
||
| 85 | 'default' => 'navigation-bar', |
||
| 86 | 'type' => 'theme_mod', |
||
| 87 | 'transport' => 'postMessage', |
||
| 88 | ); |
||
| 89 | |||
| 90 | $lsx_controls['fields']['lsx_header_mobile_layout'] = array( |
||
| 91 | 'label' => esc_html__( 'Mobile Header', 'lsx' ), |
||
| 92 | 'section' => 'lsx-layout', |
||
| 93 | 'control' => 'LSX_Customize_Mobile_Header_Layout_Control', |
||
| 94 | 'choices' => array( |
||
| 95 | 'navigation-bar', |
||
| 96 | 'hamburger', |
||
| 97 | ), |
||
| 98 | ); |
||
| 99 | |||
| 100 | $lsx_controls['settings']['lsx_layout'] = array( |
||
| 101 | 'default' => '1c', |
||
| 102 | 'type' => 'theme_mod', |
||
| 103 | 'transport' => 'refresh', |
||
| 104 | ); |
||
| 105 | |||
| 106 | $lsx_controls['fields']['lsx_layout'] = array( |
||
| 107 | 'label' => esc_html__( 'Body', 'lsx' ), |
||
| 108 | 'section' => 'lsx-layout', |
||
| 109 | 'control' => 'LSX_Customize_Layout_Control', |
||
| 110 | 'choices' => array( |
||
| 111 | '1c', |
||
| 112 | '2cr', |
||
| 113 | '2cl', |
||
| 114 | ), |
||
| 115 | ); |
||
| 116 | |||
| 117 | $lsx_controls = apply_filters( 'lsx_layout_customizer_controls', $lsx_controls ); |
||
| 118 | |||
| 119 | return $lsx_controls; |
||
| 120 | } |
||
| 290 |