Make WordPress Core

Ticket #35643: 35643.diff

File 35643.diff, 3.6 KB (added by kovshenin, 9 years ago)
  • src/wp-includes/class.wp-dependencies.php

     
    100100                        if ( !in_array($handle, $this->done, true) && isset($this->registered[$handle]) ) {
    101101
    102102                                /*
    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 
    116                                 /*
    117103                                 * Attempt to process the item. If successful,
    118104                                 * add the handle to the done array.
    119105                                 *
  • src/wp-includes/class.wp-scripts.php

     
    135135                if ( isset($this->args[$handle]) )
    136136                        $ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
    137137
     138                /*
     139                 * A single item may alias a set of items, by having dependencies,
     140                 * but no source. Queuing the item queues the dependencies.
     141                 *
     142                 * Example: The extending class WP_Scripts is used to register 'scriptaculous' as a set of registered handles:
     143                 *   <code>add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) );</code>
     144                 *
     145                 * The src property is false.
     146                 */
     147                if ( ! $obj->src ) {
     148                        return true;
     149                }
     150
    138151                $src = $obj->src;
    139152                $cond_before = $cond_after = '';
    140153                $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
  • src/wp-includes/class.wp-styles.php

     
    5656                if ( isset($this->args[$handle]) )
    5757                        $ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
    5858
     59                /* See description in class.wp-scripts.php */
     60                if ( ! $obj->src ) {
     61                        return true;
     62                }
     63
    5964                if ( $this->do_concat ) {
    6065                        if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) {
    6166                                $this->concat .= "$handle,";
  • tests/phpunit/tests/dependencies/scripts.php

     
    166166        $this->assertFalse( wp_register_script( 'duplicate-handler', 'http://example.com' ) );
    167167    }
    168168
     169        /**
     170         * @ticket 35643
     171         */
     172        function test_wp_enqueue_script_footer_alias() {
     173                wp_register_script( 'foo', false, array( 'bar', 'baz' ), '1.0', true );
     174                wp_register_script( 'bar', home_url( 'bar.js' ), array(), '1.0', true );
     175                wp_register_script( 'baz', home_url( 'baz.js' ), array(), '1.0', true );
     176
     177                wp_enqueue_script( 'foo' );
     178
     179                $header = get_echo( 'wp_print_head_scripts' );
     180                $footer = get_echo( 'wp_print_footer_scripts' );
     181
     182                $this->assertEmpty( $header );
     183                $this->assertContains( home_url( 'bar.js' ), $footer );
     184                $this->assertContains( home_url( 'baz.js' ), $footer );
     185        }
    169186}