Make WordPress Core


Ignore:
Timestamp:
07/28/2011 06:24:00 PM (12 years ago)
Author:
azaozz
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class.wp-styles.php

    r18464 r18480  
    4747
    4848        if ( $this->do_concat ) {
    49             if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) {
     49            if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) {
    5050                $this->concat .= "$handle,";
    5151                $this->concat_version .= "$handle$ver";
    5252
    53                 if ( !empty($this->registered[$handle]->extra['data']) )
    54                     $this->print_code .= $this->registered[$handle]->extra['data'];
     53                $this->print_code .= $this->get_data( $handle, 'after' );
    5554
    5655                return true;
     
    9897    }
    9998
    100     function add_inline_style( $handle, $data ) {
    101         if ( !$data )
     99    function add_inline_style( $handle, $code ) {
     100        if ( !$code )
    102101            return false;
    103102
    104         if ( !empty( $this->registered[$handle]->extra['data'] ) )
    105             $data .= "\n" . $this->registered[$handle]->extra['data'];
     103        $after = $this->get_data( $handle, 'after' );
     104        if ( !$after )
     105            $after = array();
    106106
    107         return $this->add_data( $handle, 'data', $data );
     107        $after[] = $code;
     108
     109        return $this->add_data( $handle, 'after', $after );
    108110    }
    109111
    110112    function print_inline_style( $handle, $echo = true ) {
    111         if ( empty($this->registered[$handle]->extra['data']) )
     113        $output = $this->get_data( $handle, 'after' );
     114
     115        if ( empty( $output ) )
    112116            return false;
    113117
    114         $output = $this->registered[$handle]->extra['data'];
     118        $output = implode( "\n", $output );
    115119
    116120        if ( !$echo )
     
    152156        return false;
    153157    }
    154    
     158
    155159    function do_footer_items() { // HTML 5 allows styles in the body, grab late enqueued items and output them in the footer.
    156160        $this->do_items(false, 1);
Note: See TracChangeset for help on using the changeset viewer.