diff -r c7c34916027a -r 177826044cd9 wp/wp-includes/class.wp-styles.php --- a/wp/wp-includes/class.wp-styles.php Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-includes/class.wp-styles.php Mon Oct 14 18:28:13 2019 +0200 @@ -113,7 +113,7 @@ * * @param WP_Styles $this WP_Styles instance (passed by reference). */ - do_action_ref_array( 'wp_default_styles', array(&$this) ); + do_action_ref_array( 'wp_default_styles', array( &$this ) ); } /** @@ -127,54 +127,76 @@ * @return bool True on success, false on failure. */ public function do_item( $handle ) { - if ( !parent::do_item($handle) ) + if ( ! parent::do_item( $handle ) ) { return false; + } - $obj = $this->registered[$handle]; - if ( null === $obj->ver ) + $obj = $this->registered[ $handle ]; + + if ( null === $obj->ver ) { $ver = ''; - else + } else { $ver = $obj->ver ? $obj->ver : $this->default_version; + } + + if ( isset( $this->args[ $handle ] ) ) { + $ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ]; + } + + $src = $obj->src; + $cond_before = $cond_after = ''; + $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : ''; - if ( isset($this->args[$handle]) ) - $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; + if ( $conditional ) { + $cond_before = "\n"; + } + + $inline_style = $this->print_inline_style( $handle, false ); + + if ( $inline_style ) { + $inline_style_tag = sprintf( "\n", esc_attr( $handle ), $inline_style ); + } else { + $inline_style_tag = ''; + } if ( $this->do_concat ) { - if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) { - $this->concat .= "$handle,"; + if ( $this->in_default_dir( $src ) && ! $conditional && ! isset( $obj->extra['alt'] ) ) { + $this->concat .= "$handle,"; $this->concat_version .= "$handle$ver"; - $this->print_code .= $this->print_inline_style( $handle, false ); + $this->print_code .= $inline_style; return true; } } - if ( isset($obj->args) ) + if ( isset( $obj->args ) ) { $media = esc_attr( $obj->args ); - else + } else { $media = 'all'; + } // A single item may alias a set of items, by having dependencies, but no source. - if ( ! $obj->src ) { - if ( $inline_style = $this->print_inline_style( $handle, false ) ) { - $inline_style = sprintf( "\n", esc_attr( $handle ), $inline_style ); + if ( ! $src ) { + if ( $inline_style_tag ) { if ( $this->do_concat ) { - $this->print_html .= $inline_style; + $this->print_html .= $inline_style_tag; } else { - echo $inline_style; + echo $inline_style_tag; } } + return true; } - $href = $this->_css_href( $obj->src, $ver, $handle ); + $href = $this->_css_href( $src, $ver, $handle ); if ( ! $href ) { return true; } - $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; - $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : ''; + $rel = isset( $obj->extra['alt'] ) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; + $title = isset( $obj->extra['title'] ) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : ''; /** * Filters the HTML link tag of an enqueued style. @@ -188,11 +210,12 @@ * @param string $href The stylesheet's source URL. * @param string $media The stylesheet's media attribute. */ - $tag = apply_filters( 'style_loader_tag', "\n", $handle, $href, $media); - if ( 'rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl'] ) { + $tag = apply_filters( 'style_loader_tag', "\n", $handle, $href, $media ); + + if ( 'rtl' === $this->text_direction && isset( $obj->extra['rtl'] ) && $obj->extra['rtl'] ) { if ( is_bool( $obj->extra['rtl'] ) || 'replace' === $obj->extra['rtl'] ) { - $suffix = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : ''; - $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $obj->src , $ver, "$handle-rtl" )); + $suffix = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : ''; + $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $src, $ver, "$handle-rtl" ) ); } else { $rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" ); } @@ -207,24 +230,18 @@ } } - $conditional_pre = $conditional_post = ''; - if ( isset( $obj->extra['conditional'] ) && $obj->extra['conditional'] ) { - $conditional_pre = "\n"; - } - if ( $this->do_concat ) { - $this->print_html .= $conditional_pre; + $this->print_html .= $cond_before; $this->print_html .= $tag; - if ( $inline_style = $this->print_inline_style( $handle, false ) ) { - $this->print_html .= sprintf( "\n", esc_attr( $handle ), $inline_style ); + if ( $inline_style_tag ) { + $this->print_html .= $inline_style_tag; } - $this->print_html .= $conditional_post; + $this->print_html .= $cond_after; } else { - echo $conditional_pre; + echo $cond_before; echo $tag; $this->print_inline_style( $handle ); - echo $conditional_post; + echo $cond_after; } return true; @@ -302,7 +319,7 @@ * * @since 2.6.0 * - * @param array $to_do The list of enqueued styles about to be processed. + * @param string[] $to_do The list of enqueued style handles about to be processed. */ $this->to_do = apply_filters( 'print_styles_array', $this->to_do ); } @@ -320,12 +337,13 @@ * @return string Style's fully-qualified URL. */ public function _css_href( $src, $ver, $handle ) { - if ( !is_bool($src) && !preg_match('|^(https?:)?//|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) { + if ( ! is_bool( $src ) && ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) { $src = $this->base_url . $src; } - if ( !empty($ver) ) - $src = add_query_arg('ver', $ver, $src); + if ( ! empty( $ver ) ) { + $src = add_query_arg( 'ver', $ver, $src ); + } /** * Filters an enqueued style's fully-qualified URL. @@ -348,12 +366,14 @@ * @return bool True if found, false if not. */ public function in_default_dir( $src ) { - if ( ! $this->default_dirs ) + if ( ! $this->default_dirs ) { return true; + } foreach ( (array) $this->default_dirs as $test ) { - if ( 0 === strpos($src, $test) ) + if ( 0 === strpos( $src, $test ) ) { return true; + } } return false; } @@ -370,7 +390,7 @@ * @return array Handles of items that have been processed. */ public function do_footer_items() { - $this->do_items(false, 1); + $this->do_items( false, 1 ); return $this->done; } @@ -380,9 +400,9 @@ * @since 3.3.0 */ public function reset() { - $this->do_concat = false; - $this->concat = ''; + $this->do_concat = false; + $this->concat = ''; $this->concat_version = ''; - $this->print_html = ''; + $this->print_html = ''; } }