Skip to content

Commit

Permalink
Fix issue Automattic#8546 - instead of removing window.require and wi…
Browse files Browse the repository at this point in the history
…ndow.define from global scope and thus breaking mailchimp script, set window.define.amd to fool just real amd modules.

Mailchimp script seem to expect usable definitions of require and define, once we remove them it breaks. Since the purpose of this commit is to fix scripts like jquery-ui that will resort to define() if define.amd is defined - it is enough to unset define.amd. This is a very ugly solution, but it works.
  • Loading branch information
adamziel committed Jan 17, 2018
1 parent a0966bb commit c609360
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/shortcodes/mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,6 @@ static function shortcode( $lcase_attrs ) {

$displayed_once = true;

return "\n\n" . '<script type="text/javascript" data-dojo-config="' . esc_attr( implode( ', ', $config_vars ) ) . '">jQuery.getScript( "//downloads.mailchimp.com/js/signup-forms/popup/embed.js", function( data, textStatus, jqxhr ) { require(["mojo/signup-forms/Loader"], function(L) { L.start(' . wp_json_encode( $js_vars ) . ') }); window.require = window.define = undefined; } );</script>' . "\n\n";
return "\n\n" . '<script type="text/javascript" data-dojo-config="' . esc_attr( implode( ', ', $config_vars ) ) . '">jQuery.getScript( "//downloads.mailchimp.com/js/signup-forms/popup/embed.js", function( data, textStatus, jqxhr ) { require(["mojo/signup-forms/Loader"], function(L) { L.start(' . wp_json_encode( $js_vars ) . ') }); window.define.amd = undefined; } );</script>' . "\n\n";
}
}

0 comments on commit c609360

Please sign in to comment.