Skip to content

Commit

Permalink
Exclude concatenation for js files which have inline js added via wp_…
Browse files Browse the repository at this point in the history
…add_inline_script(). This fixes issues with the Gutenberg editor not loading correctly.
  • Loading branch information
dchymko committed Oct 18, 2018
1 parent 10025c4 commit 818d317
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions jsconcat.php
Expand Up @@ -68,16 +68,6 @@ function do_items( $handles = false, $group = false ) {
$js_url_parsed = parse_url( $js_url );
$extra = $obj->extra;

// Check for scripts added from wp_add_inline_script()
$before_handle = $this->print_inline_script( $handle, 'before', false );
$after_handle = $this->print_inline_script( $handle, 'after', false );
if ( $before_handle ) {
$before_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $before_handle );
}
if ( $after_handle ) {
$after_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $after_handle );
}

// Don't concat by default
$do_concat = false;

Expand All @@ -99,6 +89,18 @@ function do_items( $handles = false, $group = false ) {
else
$js_url_parsed['path'] = substr( $js_realpath, strlen( ABSPATH ) - 1 );

// Check for scripts added from wp_add_inline_script()
$before_handle = $this->print_inline_script( $handle, 'before', false );
$after_handle = $this->print_inline_script( $handle, 'after', false );
if ( $before_handle ) {
$do_concat = false;
$before_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $before_handle );
}
if ( $after_handle ) {
$after_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $after_handle );
$do_concat = false;
}

// Allow plugins to disable concatenation of certain scripts.
$do_concat = apply_filters( 'js_do_concat', $do_concat, $handle );

Expand Down

0 comments on commit 818d317

Please sign in to comment.