| Conditions | 2 |
| Paths | 1 |
| Total Lines | 95 |
| Code Lines | 64 |
| 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 |
||
| 71 | function lsx_customizer_layout_controls( $lsx_controls ) { |
||
| 72 | $lsx_controls['sections']['lsx-layout'] = array( |
||
| 73 | 'title' => esc_html__( 'Layout', 'lsx' ), |
||
| 74 | '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' ), |
||
| 75 | 'priority' => 22, |
||
| 76 | ); |
||
| 77 | |||
| 78 | $lsx_controls['settings']['lsx_header_layout'] = array( |
||
| 79 | 'default' => 'inline', |
||
| 80 | 'type' => 'theme_mod', |
||
| 81 | 'transport' => 'postMessage', |
||
| 82 | ); |
||
| 83 | |||
| 84 | $lsx_controls['fields']['lsx_header_layout'] = array( |
||
| 85 | 'label' => esc_html__( 'Header', 'lsx' ), |
||
| 86 | 'section' => 'lsx-layout', |
||
| 87 | 'control' => 'LSX_Customize_Header_Layout_Control', |
||
| 88 | 'choices' => array( |
||
| 89 | 'central', |
||
| 90 | 'expanded', |
||
| 91 | 'inline', |
||
| 92 | ), |
||
| 93 | ); |
||
| 94 | |||
| 95 | $lsx_controls['settings']['lsx_header_mobile_layout'] = array( |
||
| 96 | 'default' => 'navigation-bar', |
||
| 97 | 'type' => 'theme_mod', |
||
| 98 | 'transport' => 'postMessage', |
||
| 99 | ); |
||
| 100 | |||
| 101 | $lsx_controls['fields']['lsx_header_mobile_layout'] = array( |
||
| 102 | 'label' => esc_html__( 'Mobile Header', 'lsx' ), |
||
| 103 | 'section' => 'lsx-layout', |
||
| 104 | 'control' => 'LSX_Customize_Mobile_Header_Layout_Control', |
||
| 105 | 'choices' => array( |
||
| 106 | 'navigation-bar', |
||
| 107 | 'hamburger', |
||
| 108 | ), |
||
| 109 | ); |
||
| 110 | |||
| 111 | $lsx_controls['settings']['lsx_layout'] = array( |
||
| 112 | 'default' => '1c', |
||
| 113 | 'type' => 'theme_mod', |
||
| 114 | 'transport' => 'refresh', |
||
| 115 | ); |
||
| 116 | |||
| 117 | $lsx_controls['fields']['lsx_layout'] = array( |
||
| 118 | 'label' => esc_html__( 'Body', 'lsx' ), |
||
| 119 | 'section' => 'lsx-layout', |
||
| 120 | 'control' => 'LSX_Customize_Layout_Control', |
||
| 121 | 'choices' => array( |
||
| 122 | '1c', |
||
| 123 | '2cr', |
||
| 124 | '2cl', |
||
| 125 | ), |
||
| 126 | ); |
||
| 127 | |||
| 128 | $lsx_controls['settings']['lsx_header_fixed'] = array( |
||
| 129 | 'default' => false, |
||
| 130 | 'sanitize_callback' => 'lsx_sanitize_checkbox', |
||
| 131 | 'transport' => 'postMessage', |
||
| 132 | ); |
||
| 133 | |||
| 134 | $lsx_controls['fields']['lsx_header_fixed'] = array( |
||
| 135 | 'label' => esc_html__( 'Fixed Header', 'lsx' ), |
||
| 136 | 'section' => 'lsx-layout', |
||
| 137 | 'type' => 'checkbox', |
||
| 138 | ); |
||
| 139 | |||
| 140 | $lsx_controls['settings']['lsx_header_search'] = array( |
||
| 141 | 'default' => false, |
||
| 142 | 'sanitize_callback' => 'lsx_sanitize_checkbox', |
||
| 143 | 'transport' => 'postMessage', |
||
| 144 | ); |
||
| 145 | |||
| 146 | $lsx_controls['fields']['lsx_header_search'] = array( |
||
| 147 | 'label' => esc_html__( 'Search Box in Header', 'lsx' ), |
||
| 148 | 'section' => 'lsx-layout', |
||
| 149 | 'type' => 'checkbox', |
||
| 150 | ); |
||
| 151 | |||
| 152 | $lsx_controls['selective_refresh']['lsx_header_search'] = array( |
||
| 153 | 'selector' => '#lsx-header-search-css', |
||
| 154 | 'render_callback' => function() { |
||
| 155 | $search_form = get_theme_mod( 'lsx_header_search' ); |
||
| 156 | |||
| 157 | if ( false !== $search_form ) { |
||
| 158 | echo 'body #searchform { display: block; }'; |
||
| 159 | } else { |
||
| 160 | echo 'body #searchform { display: none; }'; |
||
| 161 | } |
||
| 162 | }, |
||
| 163 | ); |
||
| 164 | |||
| 165 | return $lsx_controls; |
||
| 166 | } |
||
| 273 |