diff options
author | Robert Anderson <noisysocks@git.wordpress.org> | 2021-07-09 01:09:08 +0000 |
---|---|---|
committer | Robert Anderson <noisysocks@git.wordpress.org> | 2021-07-09 01:09:08 +0000 |
commit | 5d9c39866937eb857c6261a8a533643e2c4d5fd0 (patch) | |
tree | 26253851506c9c196582514c5b175a7e4a18a89e /src | |
parent | 6bd5962c7d234b3dd59cb271877d9db36c4f27eb (diff) | |
download | wordpress-5d9c39866937eb857c6261a8a533643e2c4d5fd0.tar.gz wordpress-5d9c39866937eb857c6261a8a533643e2c4d5fd0.zip |
Editor: Merge conflicting wp.editor objects into single, non-conflicting object
The `wp-editor` script (`@wordpress/editor` npm package) is exposed as
`window.wp.editor` in WP Admin. This causes problems, though, as many older
scripts expect to see the older `editor` script available at `window.wp.editor`.
The solution is to export all the members of the older `window.wp.editor` module
in the newer module to maintain backwards compatibility.
See #53437.
Props zieladam, spacedmonkey, TimothyBlynJacobs, andraganescu.
git-svn-id: https://develop.svn.wordpress.org/trunk@51387 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src')
-rw-r--r-- | src/wp-includes/script-loader.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 640d1c3f77..b870e87a8f 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -381,6 +381,16 @@ function wp_default_packages_inline_scripts( $scripts ) { 'window.wp.oldEditor = window.wp.editor;', 'after' ); + + // wp-editor module is exposed as window.wp.editor + // Problem: there is quite some code expecting window.wp.oldEditor object available under window.wp.editor + // Solution: fuse the two objects together to maintain backward compatibility + // For more context, see https://github.com/WordPress/gutenberg/issues/33203 + $scripts->add_inline_script( + 'wp-editor', + 'Object.assign( window.wp.editor, window.wp.oldEditor );', + 'after' + ); } /** |