Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion resources/backend/js/gutenberg-block-formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Register Gutenberg Block Toolbar formatters if the Gutenberg Editor is loaded on screen.
// This prevents JS errors if this script is accidentally enqueued on a non-
// Gutenberg editor screen, or the Classic Editor Plugin is active.
if (typeof wp !== 'undefined' && typeof wp.blockEditor !== 'undefined') {
if (convertKitGutenbergEnabled()) {
// Register each ConvertKit formatter in Gutenberg.
for (const formatter in convertkit_block_formatters) {
convertKitGutenbergRegisterBlockFormatter(
Expand Down
16 changes: 15 additions & 1 deletion resources/backend/js/gutenberg.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Register Gutenberg Blocks if the Gutenberg Editor is loaded on screen.
// This prevents JS errors if this script is accidentally enqueued on a non-
// Gutenberg editor screen, or the Classic Editor Plugin is active.
if (typeof wp !== 'undefined' && typeof wp.blockEditor !== 'undefined') {
if (convertKitGutenbergEnabled()) {
// Register each ConvertKit Block in Gutenberg.
for (const block in convertkit_blocks) {
convertKitGutenbergRegisterBlock(convertkit_blocks[block]);
Expand Down Expand Up @@ -942,3 +942,17 @@ function convertKitEditingPostInGutenberg() {
// If the user is editing a post in the block editor, wp.editPost will be defined.
return typeof wp !== 'undefined' && typeof wp.editPost !== 'undefined';
}

/**
* Checks if the Gutenberg editor is loaded on screen.
*
* Returns true when editing a Post, Page or Custom Post Type in the block editor,
* or using the site editor.
*
* @since 3.0.8
*
* @return {boolean} Block editor is loaded
*/
function convertKitGutenbergEnabled() {
return typeof wp !== 'undefined' && typeof wp.blockEditor !== 'undefined';
}