| 1 |
import $ from 'jquery'; |
| 2 |
|
| 3 |
import { unregisterBlockType } from '@wordpress/blocks'; |
| 4 |
const { |
| 5 |
GHOSTKIT, |
| 6 |
_wpLoadBlockEditor: wpLoadBlockEditor, |
| 7 |
_wpLoadGutenbergEditor: wpLoadGutenbergEditor, |
| 8 |
} = window; |
| 9 |
|
| 10 |
let loadBlocksEditor = null; |
| 11 |
|
| 12 |
if (typeof wpLoadBlockEditor !== 'undefined') { |
| 13 |
// Using Gutenberg plugin |
| 14 |
loadBlocksEditor = wpLoadBlockEditor; |
| 15 |
} else if (typeof wpLoadGutenbergEditor !== 'undefined') { |
| 16 |
// Using WP core Gutenberg |
| 17 |
loadBlocksEditor = wpLoadGutenbergEditor; |
| 18 |
} |
| 19 |
|
| 20 |
$(() => { |
| 21 |
if (loadBlocksEditor && GHOSTKIT) { |
| 22 |
loadBlocksEditor.then(() => { |
| 23 |
if (GHOSTKIT.disabledBlocks) { |
| 24 |
Object.keys(GHOSTKIT.disabledBlocks).forEach((name) => { |
| 25 |
if (GHOSTKIT.disabledBlocks[name]) { |
| 26 |
unregisterBlockType(name); |
| 27 |
} |
| 28 |
}); |
| 29 |
} |
| 30 |
}); |
| 31 |
} |
| 32 |
}); |
| 33 |
|