Conditions | 29 |
Paths | 12250 |
Total Lines | 103 |
Code Lines | 61 |
Lines | 6 |
Ratio | 5.83 % |
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 |
||
141 | public function do_item( $handle ) { |
||
142 | if ( !parent::do_item($handle) ) |
||
143 | return false; |
||
144 | |||
145 | $obj = $this->registered[$handle]; |
||
146 | View Code Duplication | if ( null === $obj->ver ) |
|
147 | $ver = ''; |
||
148 | else |
||
149 | $ver = $obj->ver ? $obj->ver : $this->default_version; |
||
150 | |||
151 | View Code Duplication | if ( isset($this->args[$handle]) ) |
|
152 | $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; |
||
153 | |||
154 | if ( $this->do_concat ) { |
||
155 | if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) { |
||
156 | $this->concat .= "$handle,"; |
||
157 | $this->concat_version .= "$handle$ver"; |
||
|
|||
158 | |||
159 | $this->print_code .= $this->print_inline_style( $handle, false ); |
||
160 | |||
161 | return true; |
||
162 | } |
||
163 | } |
||
164 | |||
165 | if ( isset($obj->args) ) |
||
166 | $media = esc_attr( $obj->args ); |
||
167 | else |
||
168 | $media = 'all'; |
||
169 | |||
170 | // A single item may alias a set of items, by having dependencies, but no source. |
||
171 | if ( ! $obj->src ) { |
||
172 | if ( $inline_style = $this->print_inline_style( $handle, false ) ) { |
||
173 | $inline_style = sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style ); |
||
174 | if ( $this->do_concat ) { |
||
175 | $this->print_html .= $inline_style; |
||
176 | } else { |
||
177 | echo $inline_style; |
||
178 | } |
||
179 | } |
||
180 | return true; |
||
181 | } |
||
182 | |||
183 | $href = $this->_css_href( $obj->src, $ver, $handle ); |
||
184 | if ( ! $href ) { |
||
185 | return true; |
||
186 | } |
||
187 | |||
188 | $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; |
||
189 | $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : ''; |
||
190 | |||
191 | /** |
||
192 | * Filters the HTML link tag of an enqueued style. |
||
193 | * |
||
194 | * @since 2.6.0 |
||
195 | * @since 4.3.0 Introduced the `$href` parameter. |
||
196 | * @since 4.5.0 Introduced the `$media` parameter. |
||
197 | * |
||
198 | * @param string $html The link tag for the enqueued style. |
||
199 | * @param string $handle The style's registered handle. |
||
200 | * @param string $href The stylesheet's source URL. |
||
201 | * @param string $media The stylesheet's media attribute. |
||
202 | */ |
||
203 | $tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle, $href, $media); |
||
204 | if ( 'rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl'] ) { |
||
205 | if ( is_bool( $obj->extra['rtl'] ) || 'replace' === $obj->extra['rtl'] ) { |
||
206 | $suffix = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : ''; |
||
207 | $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $obj->src , $ver, "$handle-rtl" )); |
||
208 | } else { |
||
209 | $rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" ); |
||
210 | } |
||
211 | |||
212 | /** This filter is documented in wp-includes/class.wp-styles.php */ |
||
213 | $rtl_tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle, $rtl_href, $media ); |
||
214 | |||
215 | if ( $obj->extra['rtl'] === 'replace' ) { |
||
216 | $tag = $rtl_tag; |
||
217 | } else { |
||
218 | $tag .= $rtl_tag; |
||
219 | } |
||
220 | } |
||
221 | |||
222 | $conditional_pre = $conditional_post = ''; |
||
223 | if ( isset( $obj->extra['conditional'] ) && $obj->extra['conditional'] ) { |
||
224 | $conditional_pre = "<!--[if {$obj->extra['conditional']}]>\n"; |
||
225 | $conditional_post = "<![endif]-->\n"; |
||
226 | } |
||
227 | |||
228 | if ( $this->do_concat ) { |
||
229 | $this->print_html .= $conditional_pre; |
||
230 | $this->print_html .= $tag; |
||
231 | if ( $inline_style = $this->print_inline_style( $handle, false ) ) { |
||
232 | $this->print_html .= sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style ); |
||
233 | } |
||
234 | $this->print_html .= $conditional_post; |
||
235 | } else { |
||
236 | echo $conditional_pre; |
||
237 | echo $tag; |
||
238 | $this->print_inline_style( $handle ); |
||
239 | echo $conditional_post; |
||
240 | } |
||
241 | |||
242 | return true; |
||
243 | } |
||
244 | |||
408 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.