Make WordPress Core

Ticket #35229: 35229.5.diff

File 35229.5.diff, 3.9 KB (added by dd32, 9 years ago)
  • src/wp-includes/class.wp-dependencies.php

    class WP_Dependencies { 
    8686         *
    8787         * @param mixed $handles Optional. Items to be processed: Process queue (false), process item (string), process items (array of strings).
    8888         * @param mixed $group   Group level: level (int), no groups (false).
    8989         * @return array Handles of items that have been processed.
    9090         */
    9191        public function do_items( $handles = false, $group = false ) {
    9292                /*
    9393                 * If nothing is passed, print the queue. If a string is passed,
    9494                 * print that item. If an array is passed, print those items.
    9595                 */
    9696                $handles = false === $handles ? $this->queue : (array) $handles;
    9797                $this->all_deps( $handles );
    9898
    9999                foreach ( $this->to_do as $key => $handle ) {
    100100                        if ( !in_array($handle, $this->done, true) && isset($this->registered[$handle]) ) {
    101 
    102                                 /*
    103                                  * A single item may alias a set of items, by having dependencies,
    104                                  * but no source. Queuing the item queues the dependencies.
    105                                  *
    106                                  * Example: The extending class WP_Scripts is used to register 'scriptaculous' as a set of registered handles:
    107                                  *   <code>add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) );</code>
    108                                  *
    109                                  * The src property is false.
    110                                  */
    111                                 if ( ! $this->registered[$handle]->src ) {
    112                                         $this->done[] = $handle;
    113                                         continue;
    114                                 }
    115 
    116101                                /*
    117102                                 * Attempt to process the item. If successful,
    118103                                 * add the handle to the done array.
    119104                                 *
    120105                                 * Unset the item from the to_do array.
    121106                                 */
    122107                                if ( $this->do_item( $handle, $group ) )
    123108                                        $this->done[] = $handle;
    124109
    125110                                unset( $this->to_do[$key] );
    126111                        }
    127112                }
    128113
    129114                return $this->done;
    130115        }
  • src/wp-includes/class.wp-styles.php

    class WP_Styles extends WP_Dependencies  
    6060                        if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) {
    6161                                $this->concat .= "$handle,";
    6262                                $this->concat_version .= "$handle$ver";
    6363
    6464                                $this->print_code .= $this->print_inline_style( $handle, false );
    6565
    6666                                return true;
    6767                        }
    6868                }
    6969
    7070                if ( isset($obj->args) )
    7171                        $media = esc_attr( $obj->args );
    7272                else
    7373                        $media = 'all';
    7474
    75                 $href = $this->_css_href( $obj->src, $ver, $handle );
    76                 if ( empty( $href ) ) {
    77                         // Turns out there is nothing to print.
     75                if ( ! $obj->src ) {
     76                        if ( $inline_style = $this->print_inline_style( $handle, false ) ) {
     77                                $inline_style = sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style );
     78                                if ( $this->do_concat ) {
     79                                        $this->print_html .= $inline_style;
     80                                } else {
     81                                        echo $inline_style;
     82                                }
     83                        }
    7884                        return true;
    7985                }
     86// Patch note: $href should never have been empty, perhaps it meant `$osb->src`, it's always escaped as a URL nowdays.
     87                $href = $this->_css_href( $obj->src, $ver, $handle );
    8088                $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
    8189                $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : '';
    8290
    8391                /**
    8492                 * Filter the HTML link tag of an enqueued style.
    8593                 *
    8694                 * @since 2.6.0
    8795                 * @since 4.3.0 Introduced the `$href` parameter.
    8896                 *
    8997                 * @param string $html   The link tag for the enqueued style.
    9098                 * @param string $handle The style's registered handle.
    9199                 * @param string $href   The stylesheet's source URL.
    92100                 */
    93101                $tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle, $href );
    94102                if ( 'rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl'] ) {