WordPress.org

Make WordPress Core

Ticket #36392: 36392.2.patch

File 36392.2.patch, 2.6 KB (added by ocean90, 4 years ago)
  • src/wp-includes/class.wp-scripts.php

     
    363363                $tag = apply_filters( 'script_loader_tag', $tag, $handle, $src );
    364364
    365365                if ( $this->do_concat ) {
    366                         if ( $after_handle ) {
     366                        if ( $before_handle ) {
    367367                                $this->print_html_before .= $tag;
    368368                        } else {
    369369                                $this->print_html .= $tag;
  • tests/phpunit/tests/dependencies/scripts.php

     
    481481                $print_scripts = get_echo( '_print_scripts' );
    482482
    483483                $ver = get_bloginfo( 'version' );
    484                 $expected  = "<script type='text/javascript' src='/directory/two.js?ver={$ver}'></script>\n";
     484                $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5B%5D=one,four&amp;ver={$ver}'></script>\n";
     485                $expected .= "<script type='text/javascript' src='/directory/two.js?ver={$ver}'></script>\n";
    485486                $expected .= "<script type='text/javascript'>\nconsole.log(\"after two\");\n</script>\n";
    486487                $expected .= "<script type='text/javascript' src='/directory/three.js?ver={$ver}'></script>\n";
    487488                $expected .= "<script type='text/javascript'>\nconsole.log(\"after three\");\n</script>\n";
    488                 $expected .= "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5B%5D=one,four&amp;ver={$ver}'></script>\n";
    489489
    490490                $this->assertEquals( $expected, $print_scripts );
    491491        }
     
    520520                $this->assertEquals( '', $wp_scripts->print_html );
    521521        }
    522522
     523        /**
     524         * @ticket 36392
     525         */
     526        public function test_wp_add_inline_script_concat_with_core_dependency() {
     527                global $wp_scripts;
     528
     529                wp_default_scripts( $wp_scripts );
     530
     531                $wp_scripts->base_url = '';
     532                $wp_scripts->do_concat = true;
     533
     534                $ver = get_bloginfo( 'version' );
     535                $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5B%5D=jquery-core,jquery-migrate&amp;ver={$ver}'></script>\n";
     536                $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
     537                $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
     538
     539                wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null );
     540                wp_add_inline_script( 'test-example', 'console.log("after");' );
     541
     542                wp_print_scripts();
     543                $print_scripts = get_echo( '_print_scripts' );
     544
     545                $this->assertEquals( $expected, $print_scripts );
     546        }
    523547}