Introduce WP_Dependencies::get_data() method, change scripts and styles priority to follow the "natural" order in HTML, i.e. the last one wins, props scribu, see #11520

git-svn-id: https://develop.svn.wordpress.org/trunk@18480 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2011-07-28 18:24:00 +00:00
parent d6f842b4c2
commit 0191ed92cd
5 changed files with 65 additions and 34 deletions
+15 -11
View File
@@ -46,12 +46,11 @@ class WP_Styles extends WP_Dependencies {
$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']) ) {
if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) {
$this->concat .= "$handle,";
$this->concat_version .= "$handle$ver";
if ( !empty($this->registered[$handle]->extra['data']) )
$this->print_code .= $this->registered[$handle]->extra['data'];
$this->print_code .= $this->get_data( $handle, 'after' );
return true;
}
@@ -97,21 +96,26 @@ class WP_Styles extends WP_Dependencies {
return true;
}
function add_inline_style( $handle, $data ) {
if ( !$data )
function add_inline_style( $handle, $code ) {
if ( !$code )
return false;
if ( !empty( $this->registered[$handle]->extra['data'] ) )
$data .= "\n" . $this->registered[$handle]->extra['data'];
$after = $this->get_data( $handle, 'after' );
if ( !$after )
$after = array();
return $this->add_data( $handle, 'data', $data );
$after[] = $code;
return $this->add_data( $handle, 'after', $after );
}
function print_inline_style( $handle, $echo = true ) {
if ( empty($this->registered[$handle]->extra['data']) )
$output = $this->get_data( $handle, 'after' );
if ( empty( $output ) )
return false;
$output = $this->registered[$handle]->extra['data'];
$output = implode( "\n", $output );
if ( !$echo )
return $output;
@@ -151,7 +155,7 @@ class WP_Styles extends WP_Dependencies {
}
return false;
}
function do_footer_items() { // HTML 5 allows styles in the body, grab late enqueued items and output them in the footer.
$this->do_items(false, 1);
return $this->done;