Conditions | 1 |
Paths | 1 |
Total Lines | 126 |
Code Lines | 4 |
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 |
||
97 | protected function content_template() { |
||
98 | ?> |
||
99 | <label> |
||
100 | <span class="customize-control-title"> |
||
101 | {{{ data.label }}} |
||
102 | </span> |
||
103 | <# if ( data.description ) { #> |
||
104 | <span class="description customize-control-description">{{{ data.description }}}</span> |
||
105 | <# } #> |
||
106 | </label> |
||
107 | <div class="background-wrapper"> |
||
108 | |||
109 | <!-- background-color --> |
||
110 | <div class="background-color"> |
||
111 | <h4>{{ data.l10n['background-color'] }}</h4> |
||
112 | <input type="text" data-default-color="{{ data.default['background-color'] }}" data-alpha="true" value="{{ data.value['background-color'] }}" class="kirki-color-control color-picker" {{{ data.link }}} /> |
||
113 | </div> |
||
114 | |||
115 | <!-- background-image --> |
||
116 | <div class="background-image"> |
||
117 | <h4>{{ data.l10n['background-image'] }}</h4> |
||
118 | <div class="attachment-media-view background-image-upload"> |
||
119 | <# if ( data.value['background-image'] ) { #> |
||
120 | <div class="thumbnail thumbnail-image"> |
||
121 | <img src="{{ data.value['background-image'] }}" alt="" /> |
||
122 | </div> |
||
123 | <# } else { #> |
||
124 | <div class="placeholder"> |
||
125 | {{ data.l10n['no-file-selected'] }} |
||
126 | </div> |
||
127 | <# } #> |
||
128 | <div class="actions"> |
||
129 | <button class="button background-image-upload-remove-button<# if ( ! data.value['background-image'] ) { #> hidden <# } #>"> |
||
130 | {{ data.l10n['remove'] }} |
||
131 | </button> |
||
132 | <button type="button" class="button background-image-upload-button"> |
||
133 | {{ data.l10n['select-file'] }} |
||
134 | </button> |
||
135 | </div> |
||
136 | </div> |
||
137 | </div> |
||
138 | |||
139 | <!-- background-repeat --> |
||
140 | <div class="background-repeat"> |
||
141 | <h4>{{ data.l10n['background-repeat'] }}</h4> |
||
142 | <# |
||
143 | var repeats = [ |
||
144 | 'no-repeat', |
||
145 | 'repeat-all', |
||
146 | 'repeat-x', |
||
147 | 'repeat-y' |
||
148 | ]; |
||
149 | #> |
||
150 | <select {{{ data.inputAttrs }}} {{{ data.link }}}> |
||
151 | <# _.each( repeats, function( repeat ) { #> |
||
152 | <option value="{{ repeat }}"<# if ( repeat === data.value['background-repeat'] ) { #> selected <# } #>>{{ data.l10n[ repeat ] }}</option> |
||
153 | <# }); #> |
||
154 | </select> |
||
155 | </div> |
||
156 | |||
157 | <!-- background-position --> |
||
158 | <div class="background-position"> |
||
159 | <h4>{{ data.l10n['background-position'] }}</h4> |
||
160 | <# |
||
161 | var positions = [ |
||
162 | 'left top', |
||
163 | 'left center', |
||
164 | 'left bottom', |
||
165 | 'right top', |
||
166 | 'right center', |
||
167 | 'right bottom', |
||
168 | 'center top', |
||
169 | 'center center', |
||
170 | 'center bottom' |
||
171 | ]; |
||
172 | #> |
||
173 | <select {{{ data.inputAttrs }}} {{{ data.link }}}> |
||
174 | <# _.each( positions, function( position ) { #> |
||
175 | <option value="{{ position }}"<# if ( position === data.value['background-position'] ) { #> selected <# } #>>{{ data.l10n[ position ] }}</option> |
||
176 | <# }); #> |
||
177 | </select> |
||
178 | </div> |
||
179 | |||
180 | <!-- background-size --> |
||
181 | <div class="background-size"> |
||
182 | <h4>{{ data.l10n['background-size'] }}</h4> |
||
183 | <# |
||
184 | var sizes = [ |
||
185 | 'cover', |
||
186 | 'contain', |
||
187 | 'auto' |
||
188 | ]; |
||
189 | #> |
||
190 | <div class="buttonset"> |
||
191 | <# _.each( sizes, function( size ) { #> |
||
192 | <input {{{ data.inputAttrs }}} class="switch-input screen-reader-text" type="radio" value="{{ size }}" name="_customize-bg-{{{ data.id }}}-size" id="{{ data.id }}{{ size }}" {{{ data.link }}}<# if ( size === data.value['background-size'] ) { #> checked="checked" <# } #>> |
||
193 | <label class="switch-label switch-label-<# if ( size === data.value['background-size'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}{{ size }}"> |
||
194 | {{ data.l10n[ size ] }} |
||
195 | </label> |
||
196 | </input> |
||
197 | <# }); #> |
||
198 | </div> |
||
199 | </div> |
||
200 | |||
201 | <!-- background-attachment --> |
||
202 | <div class="background-attachment"> |
||
203 | <h4>{{ data.l10n['background-attachment'] }}</h4> |
||
204 | <# |
||
205 | var attachments = [ |
||
206 | 'scroll', |
||
207 | 'fixed', |
||
208 | 'local' |
||
209 | ]; |
||
210 | #> |
||
211 | <div class="buttonset"> |
||
212 | <# _.each( attachments, function( attachment ) { #> |
||
213 | <input {{{ data.inputAttrs }}} class="switch-input screen-reader-text" type="radio" value="{{ attachment }}" name="_customize-bg-{{{ data.id }}}-attachment" id="{{ data.id }}{{ attachment }}" {{{ data.link }}}<# if ( attachment === data.value['background-attachment'] ) { #> checked="checked" <# } #>> |
||
214 | <label class="switch-label switch-label-<# if ( attachment === data.value['background-attachment'] ) { #>on <# } else { #>off<# } #>" for="{{ data.id }}{{ attachment }}"> |
||
215 | {{ data.l10n[ attachment ] }} |
||
216 | </label> |
||
217 | </input> |
||
218 | <# }); #> |
||
219 | </div> |
||
220 | </div> |
||
221 | <?php |
||
222 | } |
||
223 | |||
272 |