Skip to content

Commit

Permalink
Fix conflict with Jetpack plugin when loading the core/freeform blo…
Browse files Browse the repository at this point in the history
…ck (#2229)
  • Loading branch information
nylen authored Aug 4, 2017
1 parent d482b4f commit 18e2e28
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
true // enqueue in the footer.
);

gutenberg_fix_jetpack_freeform_block_conflict();
wp_localize_script( 'wp-editor', 'wpEditorL10n', array(
'tinymce' => array(
'baseURL' => includes_url( 'js/tinymce' ),
Expand Down
22 changes: 21 additions & 1 deletion lib/compat.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* PHP configuration compatibility functions for the Gutenberg editor plugin.
* PHP and WordPress configuration compatibility functions for the Gutenberg
* editor plugin.
*
* @package gutenberg
*/
Expand Down Expand Up @@ -67,3 +68,22 @@ function _gutenberg_utf8_split( $str ) {

return $chars;
}

/**
* Fixes a conflict with the Jetpack plugin trying to read an undefined global
* variable `grunionEditorView` during the initialization of the
* `core/freeform` block.
*
* @since 0.7.1
*/
function gutenberg_fix_jetpack_freeform_block_conflict() {
if (
defined( 'JETPACK__VERSION' ) &&
version_compare( JETPACK__VERSION, '5.2.2', '<' )
) {
remove_filter(
'mce_external_plugins',
array( 'Grunion_Editor_View', 'mce_external_plugins' )
);
}
}

0 comments on commit 18e2e28

Please sign in to comment.