Conditions | 2 |
Paths | 1 |
Total Lines | 95 |
Code Lines | 64 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
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_layout'] = array( |
||
31 | 'default' => 'inline', |
||
32 | 'type' => 'theme_mod', |
||
33 | 'transport' => 'postMessage', |
||
34 | ); |
||
35 | |||
36 | $lsx_controls['fields']['lsx_header_layout'] = array( |
||
37 | 'label' => esc_html__( 'Header', 'lsx' ), |
||
38 | 'section' => 'lsx-layout', |
||
39 | 'control' => 'LSX_Customize_Header_Layout_Control', |
||
40 | 'choices' => array( |
||
41 | 'central', |
||
42 | 'expanded', |
||
43 | 'inline', |
||
44 | ), |
||
45 | ); |
||
46 | |||
47 | $lsx_controls['settings']['lsx_header_mobile_layout'] = array( |
||
48 | 'default' => 'navigation-bar', |
||
49 | 'type' => 'theme_mod', |
||
50 | 'transport' => 'postMessage', |
||
51 | ); |
||
52 | |||
53 | $lsx_controls['fields']['lsx_header_mobile_layout'] = array( |
||
54 | 'label' => esc_html__( 'Mobile Header', 'lsx' ), |
||
55 | 'section' => 'lsx-layout', |
||
56 | 'control' => 'LSX_Customize_Mobile_Header_Layout_Control', |
||
57 | 'choices' => array( |
||
58 | 'navigation-bar', |
||
59 | 'hamburger', |
||
60 | ), |
||
61 | ); |
||
62 | |||
63 | $lsx_controls['settings']['lsx_layout'] = array( |
||
64 | 'default' => '1c', |
||
65 | 'type' => 'theme_mod', |
||
66 | 'transport' => 'refresh', |
||
67 | ); |
||
68 | |||
69 | $lsx_controls['fields']['lsx_layout'] = array( |
||
70 | 'label' => esc_html__( 'Body', 'lsx' ), |
||
71 | 'section' => 'lsx-layout', |
||
72 | 'control' => 'LSX_Customize_Layout_Control', |
||
73 | 'choices' => array( |
||
74 | '1c', |
||
75 | '2cr', |
||
76 | '2cl', |
||
77 | ), |
||
78 | ); |
||
79 | |||
80 | $lsx_controls['settings']['lsx_header_fixed'] = array( |
||
81 | 'default' => false, |
||
82 | 'sanitize_callback' => 'lsx_sanitize_checkbox', |
||
83 | 'transport' => 'postMessage', |
||
84 | ); |
||
85 | |||
86 | $lsx_controls['fields']['lsx_header_fixed'] = array( |
||
87 | 'label' => esc_html__( 'Fixed Header', 'lsx' ), |
||
88 | 'section' => 'lsx-layout', |
||
89 | 'type' => 'checkbox', |
||
90 | ); |
||
91 | |||
92 | $lsx_controls['settings']['lsx_header_search'] = array( |
||
93 | 'default' => false, |
||
94 | 'sanitize_callback' => 'lsx_sanitize_checkbox', |
||
95 | 'transport' => 'postMessage', |
||
96 | ); |
||
97 | |||
98 | $lsx_controls['fields']['lsx_header_search'] = array( |
||
99 | 'label' => esc_html__( 'Search Box in Header', 'lsx' ), |
||
100 | 'section' => 'lsx-layout', |
||
101 | 'type' => 'checkbox', |
||
102 | ); |
||
103 | |||
104 | $lsx_controls['selective_refresh']['lsx_header_search'] = array( |
||
105 | 'selector' => '#lsx-header-search-css', |
||
106 | 'render_callback' => function() { |
||
107 | $search_form = get_theme_mod( 'lsx_header_search' ); |
||
108 | |||
109 | if ( false !== $search_form ) { |
||
110 | echo 'body #searchform { display: block; }'; |
||
111 | } else { |
||
112 | echo 'body #searchform { display: none; }'; |
||
113 | } |
||
114 | }, |
||
115 | ); |
||
116 | |||
117 | return $lsx_controls; |
||
118 | } |
||
225 |