Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move the inline script to gutenberg_override_script
  • Loading branch information
adamziel committed Jul 8, 2021
commit f4601f76cf5f8657840d2aee6b5a363067fbb5d6
12 changes: 12 additions & 0 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ function gutenberg_override_script( $scripts, $handle, $src, $deps = array(), $v
$output = sprintf( "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ '%s' ] }, 'default' );", $ltr );
$scripts->add_inline_script( 'wp-i18n', $output, '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
*/
wp_add_inline_script(
'wp-editor',
'Object.assign(window.wp.editor, window.wp.oldEditor);',
'after'
);
}

/**
Expand Down
16 changes: 0 additions & 16 deletions lib/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@ function gutenberg_use_widgets_block_editor() {
);
}

/**
* 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
*
* @return void
*/
function gutenberg_enqueue_wp_old_editor_compatibility_snippet() {
wp_add_inline_script(
'wp-editor',
'Object.assign(window.wp.editor, window.wp.oldEditor);',
'after'
);
}

/**
* Returns the settings required by legacy widgets blocks.
*
Expand Down