Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. Built from https://develop.svn.wordpress.org/trunk@42343 git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -113,7 +113,7 @@ class WP_Styles extends WP_Dependencies {
|
||||
*
|
||||
* @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,21 +127,24 @@ class WP_Styles extends WP_Dependencies {
|
||||
* @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];
|
||||
if ( isset( $this->args[ $handle ] ) ) {
|
||||
$ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ];
|
||||
}
|
||||
|
||||
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( $obj->src ) && ! isset( $obj->extra['conditional'] ) && ! isset( $obj->extra['alt'] ) ) {
|
||||
$this->concat .= "$handle,";
|
||||
$this->concat_version .= "$handle$ver";
|
||||
|
||||
$this->print_code .= $this->print_inline_style( $handle, false );
|
||||
@@ -150,10 +153,11 @@ class WP_Styles extends WP_Dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
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 ) {
|
||||
@@ -173,8 +177,8 @@ class WP_Styles extends WP_Dependencies {
|
||||
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 +192,11 @@ class WP_Styles extends WP_Dependencies {
|
||||
* @param string $href The stylesheet's source URL.
|
||||
* @param string $media The stylesheet's media attribute.
|
||||
*/
|
||||
$tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle, $href, $media);
|
||||
if ( 'rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl'] ) {
|
||||
$tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\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( $obj->src, $ver, "$handle-rtl" ) );
|
||||
} else {
|
||||
$rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" );
|
||||
}
|
||||
@@ -320,12 +324,13 @@ class WP_Styles extends WP_Dependencies {
|
||||
* @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 +353,14 @@ class WP_Styles extends WP_Dependencies {
|
||||
* @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 +377,7 @@ class WP_Styles extends WP_Dependencies {
|
||||
* @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 +387,9 @@ class WP_Styles extends WP_Dependencies {
|
||||
* @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 = '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user