How to detect the usage of Gutenberg












6














The new editor called Gutenberg is here as plugin in 4.9, and as core functionality called Block Editor, in 5.0. Regarding to it, it is often needed to determine programmatically which editor is used to edit post or page in the site console. How to do it?



Update: There are number of outdated answers to similar question:





  • gutenberg_post_has_blocks() - this function exists only in Gutenberg plugin, and not in 5.0 Core


  • is_gutenberg_page() - the same


  • the_gutenberg_project() - the same


  • has_blocks() - does not work (returns false) when Classic Editor is on and its option "Default editor for all users" = "Block Editor"


  • answer simply produces fatal error Call to undefined function get_current_screen()


So, before commenting this question and answer, please take a work to check what do you propose. Check it now, with 4.9 and current version of WordPress, and all possible combinations of Classic Editor and Gutenberg/Block Editor. I will be happy to discuss tested solution, not links to something.










share|improve this question
























  • add_action( 'admin_enqueue_scripts', 'wpse_gutenberg_editor_test' ); function wpse_gutenberg_editor_test() { if( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // your gutenberg editor related CODE here } else { // this is not gutenberg. // this may not even be any editor, you need to check the screen. } }
    – vikrant zilpe
    Nov 30 '18 at 11:06










  • please check this :artiss.blog/2018/09/detecting-per-post-use-of-gutenberg
    – vikrant zilpe
    Nov 30 '18 at 11:08










  • and this davidsword.ca/development/…
    – vikrant zilpe
    Nov 30 '18 at 11:09






  • 2




    @vikrantzilpe please do not rely to an outdated information. It is better to test what you are writing. For example, the_gutenberg_project() function exists only in Gutenberg plugin, but not in the WP 5.0 Core.
    – KAGG Design
    Nov 30 '18 at 11:23








  • 3




    Possible duplicate of check if Gutenberg is currently in use
    – T.Todua
    Jan 2 at 9:05
















6














The new editor called Gutenberg is here as plugin in 4.9, and as core functionality called Block Editor, in 5.0. Regarding to it, it is often needed to determine programmatically which editor is used to edit post or page in the site console. How to do it?



Update: There are number of outdated answers to similar question:





  • gutenberg_post_has_blocks() - this function exists only in Gutenberg plugin, and not in 5.0 Core


  • is_gutenberg_page() - the same


  • the_gutenberg_project() - the same


  • has_blocks() - does not work (returns false) when Classic Editor is on and its option "Default editor for all users" = "Block Editor"


  • answer simply produces fatal error Call to undefined function get_current_screen()


So, before commenting this question and answer, please take a work to check what do you propose. Check it now, with 4.9 and current version of WordPress, and all possible combinations of Classic Editor and Gutenberg/Block Editor. I will be happy to discuss tested solution, not links to something.










share|improve this question
























  • add_action( 'admin_enqueue_scripts', 'wpse_gutenberg_editor_test' ); function wpse_gutenberg_editor_test() { if( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // your gutenberg editor related CODE here } else { // this is not gutenberg. // this may not even be any editor, you need to check the screen. } }
    – vikrant zilpe
    Nov 30 '18 at 11:06










  • please check this :artiss.blog/2018/09/detecting-per-post-use-of-gutenberg
    – vikrant zilpe
    Nov 30 '18 at 11:08










  • and this davidsword.ca/development/…
    – vikrant zilpe
    Nov 30 '18 at 11:09






  • 2




    @vikrantzilpe please do not rely to an outdated information. It is better to test what you are writing. For example, the_gutenberg_project() function exists only in Gutenberg plugin, but not in the WP 5.0 Core.
    – KAGG Design
    Nov 30 '18 at 11:23








  • 3




    Possible duplicate of check if Gutenberg is currently in use
    – T.Todua
    Jan 2 at 9:05














6












6








6


3





The new editor called Gutenberg is here as plugin in 4.9, and as core functionality called Block Editor, in 5.0. Regarding to it, it is often needed to determine programmatically which editor is used to edit post or page in the site console. How to do it?



Update: There are number of outdated answers to similar question:





  • gutenberg_post_has_blocks() - this function exists only in Gutenberg plugin, and not in 5.0 Core


  • is_gutenberg_page() - the same


  • the_gutenberg_project() - the same


  • has_blocks() - does not work (returns false) when Classic Editor is on and its option "Default editor for all users" = "Block Editor"


  • answer simply produces fatal error Call to undefined function get_current_screen()


So, before commenting this question and answer, please take a work to check what do you propose. Check it now, with 4.9 and current version of WordPress, and all possible combinations of Classic Editor and Gutenberg/Block Editor. I will be happy to discuss tested solution, not links to something.










share|improve this question















The new editor called Gutenberg is here as plugin in 4.9, and as core functionality called Block Editor, in 5.0. Regarding to it, it is often needed to determine programmatically which editor is used to edit post or page in the site console. How to do it?



Update: There are number of outdated answers to similar question:





  • gutenberg_post_has_blocks() - this function exists only in Gutenberg plugin, and not in 5.0 Core


  • is_gutenberg_page() - the same


  • the_gutenberg_project() - the same


  • has_blocks() - does not work (returns false) when Classic Editor is on and its option "Default editor for all users" = "Block Editor"


  • answer simply produces fatal error Call to undefined function get_current_screen()


So, before commenting this question and answer, please take a work to check what do you propose. Check it now, with 4.9 and current version of WordPress, and all possible combinations of Classic Editor and Gutenberg/Block Editor. I will be happy to discuss tested solution, not links to something.







block-editor






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 8:41







KAGG Design

















asked Nov 30 '18 at 10:01









KAGG DesignKAGG Design

1,224312




1,224312












  • add_action( 'admin_enqueue_scripts', 'wpse_gutenberg_editor_test' ); function wpse_gutenberg_editor_test() { if( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // your gutenberg editor related CODE here } else { // this is not gutenberg. // this may not even be any editor, you need to check the screen. } }
    – vikrant zilpe
    Nov 30 '18 at 11:06










  • please check this :artiss.blog/2018/09/detecting-per-post-use-of-gutenberg
    – vikrant zilpe
    Nov 30 '18 at 11:08










  • and this davidsword.ca/development/…
    – vikrant zilpe
    Nov 30 '18 at 11:09






  • 2




    @vikrantzilpe please do not rely to an outdated information. It is better to test what you are writing. For example, the_gutenberg_project() function exists only in Gutenberg plugin, but not in the WP 5.0 Core.
    – KAGG Design
    Nov 30 '18 at 11:23








  • 3




    Possible duplicate of check if Gutenberg is currently in use
    – T.Todua
    Jan 2 at 9:05


















  • add_action( 'admin_enqueue_scripts', 'wpse_gutenberg_editor_test' ); function wpse_gutenberg_editor_test() { if( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // your gutenberg editor related CODE here } else { // this is not gutenberg. // this may not even be any editor, you need to check the screen. } }
    – vikrant zilpe
    Nov 30 '18 at 11:06










  • please check this :artiss.blog/2018/09/detecting-per-post-use-of-gutenberg
    – vikrant zilpe
    Nov 30 '18 at 11:08










  • and this davidsword.ca/development/…
    – vikrant zilpe
    Nov 30 '18 at 11:09






  • 2




    @vikrantzilpe please do not rely to an outdated information. It is better to test what you are writing. For example, the_gutenberg_project() function exists only in Gutenberg plugin, but not in the WP 5.0 Core.
    – KAGG Design
    Nov 30 '18 at 11:23








  • 3




    Possible duplicate of check if Gutenberg is currently in use
    – T.Todua
    Jan 2 at 9:05
















add_action( 'admin_enqueue_scripts', 'wpse_gutenberg_editor_test' ); function wpse_gutenberg_editor_test() { if( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // your gutenberg editor related CODE here } else { // this is not gutenberg. // this may not even be any editor, you need to check the screen. } }
– vikrant zilpe
Nov 30 '18 at 11:06




add_action( 'admin_enqueue_scripts', 'wpse_gutenberg_editor_test' ); function wpse_gutenberg_editor_test() { if( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // your gutenberg editor related CODE here } else { // this is not gutenberg. // this may not even be any editor, you need to check the screen. } }
– vikrant zilpe
Nov 30 '18 at 11:06












please check this :artiss.blog/2018/09/detecting-per-post-use-of-gutenberg
– vikrant zilpe
Nov 30 '18 at 11:08




please check this :artiss.blog/2018/09/detecting-per-post-use-of-gutenberg
– vikrant zilpe
Nov 30 '18 at 11:08












and this davidsword.ca/development/…
– vikrant zilpe
Nov 30 '18 at 11:09




and this davidsword.ca/development/…
– vikrant zilpe
Nov 30 '18 at 11:09




2




2




@vikrantzilpe please do not rely to an outdated information. It is better to test what you are writing. For example, the_gutenberg_project() function exists only in Gutenberg plugin, but not in the WP 5.0 Core.
– KAGG Design
Nov 30 '18 at 11:23






@vikrantzilpe please do not rely to an outdated information. It is better to test what you are writing. For example, the_gutenberg_project() function exists only in Gutenberg plugin, but not in the WP 5.0 Core.
– KAGG Design
Nov 30 '18 at 11:23






3




3




Possible duplicate of check if Gutenberg is currently in use
– T.Todua
Jan 2 at 9:05




Possible duplicate of check if Gutenberg is currently in use
– T.Todua
Jan 2 at 9:05










2 Answers
2






active

oldest

votes


















8














There are several variants:




  • WordPress 4.9, Gutenberg plugin is not active

  • WordPress 4.9, Gutenberg plugin is active

  • WordPress 5.0, Block Editor by default

  • WordPress 5.0, Classic Editor plugin is active

  • WordPress 5.0, Classic Editor plugin is active, but in site console in “Settings > Writing” the option “Use the Block editor by default…” is selected


All the mentioned variants can be processed by the following code:



/**
* Check if Block Editor is active.
* Must only be used after plugins_loaded action is fired.
*
* @return bool
*/
function is_active() {
// Gutenberg plugin is installed and activated.
$gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );

// Block editor since 5.0.
$block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );

if ( ! $gutenberg && ! $block_editor ) {
return false;
}

if ( is_classic_editor_plugin_active() ) {
$editor_option = get_option( 'classic-editor-replace' );
$block_editor_active = array( 'no-replace', 'block' );

return in_array( $editor_option, $block_editor_active, true );
}

return true;
}

/**
* Check if Classic Editor plugin is active.
*
* @return bool
*/
function is_classic_editor_plugin_active() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}

if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
return true;
}

return false;
}


Function returns true if block editor is active by any means, and false – in the case if classic editor is here. This function must only be used after plugins_loaded action is fired.



P.S. Due release of version 1.2 of Classic Editor plugin, code is updated, as classic-editor-replace options now takes values not replace and no-replace, but classic and block.






share|improve this answer























  • not going o downvote, but it is not a fail safe answer. You should do detection based on actions or filters being triggered, not based n the existence of a file or a function. There are several ways to disable gutenberg and the classic editor is only one of them.
    – Mark Kaplun
    Nov 30 '18 at 16:02










  • or to say it differently, you should never even try to detect if gutenberg is used or not, but instead just hook whatever functionality you need on the relevant gutenberg hooks in addition to hooking on the tinymce hooks
    – Mark Kaplun
    Nov 30 '18 at 16:05



















1














You can use



add_action( 'enqueue_block_editor_assets', 'your_function_name' );


which is only fired when editing content with Gutenberg.






share|improve this answer





















  • This code works only on editor page.
    – KAGG Design
    Dec 3 '18 at 4:09










  • What about enqueue_block_assets?
    – Marc
    Dec 3 '18 at 16:43










  • has_action( 'enqueue_block_assets' ) does the same what has_filter( 'replace_editor' in my code. It returns true if Classic Editor active and sets Classic Editor as default. It is better to check what you propose before writing.
    – KAGG Design
    Dec 10 '18 at 8:46











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "110"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f320653%2fhow-to-detect-the-usage-of-gutenberg%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









8














There are several variants:




  • WordPress 4.9, Gutenberg plugin is not active

  • WordPress 4.9, Gutenberg plugin is active

  • WordPress 5.0, Block Editor by default

  • WordPress 5.0, Classic Editor plugin is active

  • WordPress 5.0, Classic Editor plugin is active, but in site console in “Settings > Writing” the option “Use the Block editor by default…” is selected


All the mentioned variants can be processed by the following code:



/**
* Check if Block Editor is active.
* Must only be used after plugins_loaded action is fired.
*
* @return bool
*/
function is_active() {
// Gutenberg plugin is installed and activated.
$gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );

// Block editor since 5.0.
$block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );

if ( ! $gutenberg && ! $block_editor ) {
return false;
}

if ( is_classic_editor_plugin_active() ) {
$editor_option = get_option( 'classic-editor-replace' );
$block_editor_active = array( 'no-replace', 'block' );

return in_array( $editor_option, $block_editor_active, true );
}

return true;
}

/**
* Check if Classic Editor plugin is active.
*
* @return bool
*/
function is_classic_editor_plugin_active() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}

if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
return true;
}

return false;
}


Function returns true if block editor is active by any means, and false – in the case if classic editor is here. This function must only be used after plugins_loaded action is fired.



P.S. Due release of version 1.2 of Classic Editor plugin, code is updated, as classic-editor-replace options now takes values not replace and no-replace, but classic and block.






share|improve this answer























  • not going o downvote, but it is not a fail safe answer. You should do detection based on actions or filters being triggered, not based n the existence of a file or a function. There are several ways to disable gutenberg and the classic editor is only one of them.
    – Mark Kaplun
    Nov 30 '18 at 16:02










  • or to say it differently, you should never even try to detect if gutenberg is used or not, but instead just hook whatever functionality you need on the relevant gutenberg hooks in addition to hooking on the tinymce hooks
    – Mark Kaplun
    Nov 30 '18 at 16:05
















8














There are several variants:




  • WordPress 4.9, Gutenberg plugin is not active

  • WordPress 4.9, Gutenberg plugin is active

  • WordPress 5.0, Block Editor by default

  • WordPress 5.0, Classic Editor plugin is active

  • WordPress 5.0, Classic Editor plugin is active, but in site console in “Settings > Writing” the option “Use the Block editor by default…” is selected


All the mentioned variants can be processed by the following code:



/**
* Check if Block Editor is active.
* Must only be used after plugins_loaded action is fired.
*
* @return bool
*/
function is_active() {
// Gutenberg plugin is installed and activated.
$gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );

// Block editor since 5.0.
$block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );

if ( ! $gutenberg && ! $block_editor ) {
return false;
}

if ( is_classic_editor_plugin_active() ) {
$editor_option = get_option( 'classic-editor-replace' );
$block_editor_active = array( 'no-replace', 'block' );

return in_array( $editor_option, $block_editor_active, true );
}

return true;
}

/**
* Check if Classic Editor plugin is active.
*
* @return bool
*/
function is_classic_editor_plugin_active() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}

if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
return true;
}

return false;
}


Function returns true if block editor is active by any means, and false – in the case if classic editor is here. This function must only be used after plugins_loaded action is fired.



P.S. Due release of version 1.2 of Classic Editor plugin, code is updated, as classic-editor-replace options now takes values not replace and no-replace, but classic and block.






share|improve this answer























  • not going o downvote, but it is not a fail safe answer. You should do detection based on actions or filters being triggered, not based n the existence of a file or a function. There are several ways to disable gutenberg and the classic editor is only one of them.
    – Mark Kaplun
    Nov 30 '18 at 16:02










  • or to say it differently, you should never even try to detect if gutenberg is used or not, but instead just hook whatever functionality you need on the relevant gutenberg hooks in addition to hooking on the tinymce hooks
    – Mark Kaplun
    Nov 30 '18 at 16:05














8












8








8






There are several variants:




  • WordPress 4.9, Gutenberg plugin is not active

  • WordPress 4.9, Gutenberg plugin is active

  • WordPress 5.0, Block Editor by default

  • WordPress 5.0, Classic Editor plugin is active

  • WordPress 5.0, Classic Editor plugin is active, but in site console in “Settings > Writing” the option “Use the Block editor by default…” is selected


All the mentioned variants can be processed by the following code:



/**
* Check if Block Editor is active.
* Must only be used after plugins_loaded action is fired.
*
* @return bool
*/
function is_active() {
// Gutenberg plugin is installed and activated.
$gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );

// Block editor since 5.0.
$block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );

if ( ! $gutenberg && ! $block_editor ) {
return false;
}

if ( is_classic_editor_plugin_active() ) {
$editor_option = get_option( 'classic-editor-replace' );
$block_editor_active = array( 'no-replace', 'block' );

return in_array( $editor_option, $block_editor_active, true );
}

return true;
}

/**
* Check if Classic Editor plugin is active.
*
* @return bool
*/
function is_classic_editor_plugin_active() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}

if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
return true;
}

return false;
}


Function returns true if block editor is active by any means, and false – in the case if classic editor is here. This function must only be used after plugins_loaded action is fired.



P.S. Due release of version 1.2 of Classic Editor plugin, code is updated, as classic-editor-replace options now takes values not replace and no-replace, but classic and block.






share|improve this answer














There are several variants:




  • WordPress 4.9, Gutenberg plugin is not active

  • WordPress 4.9, Gutenberg plugin is active

  • WordPress 5.0, Block Editor by default

  • WordPress 5.0, Classic Editor plugin is active

  • WordPress 5.0, Classic Editor plugin is active, but in site console in “Settings > Writing” the option “Use the Block editor by default…” is selected


All the mentioned variants can be processed by the following code:



/**
* Check if Block Editor is active.
* Must only be used after plugins_loaded action is fired.
*
* @return bool
*/
function is_active() {
// Gutenberg plugin is installed and activated.
$gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );

// Block editor since 5.0.
$block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );

if ( ! $gutenberg && ! $block_editor ) {
return false;
}

if ( is_classic_editor_plugin_active() ) {
$editor_option = get_option( 'classic-editor-replace' );
$block_editor_active = array( 'no-replace', 'block' );

return in_array( $editor_option, $block_editor_active, true );
}

return true;
}

/**
* Check if Classic Editor plugin is active.
*
* @return bool
*/
function is_classic_editor_plugin_active() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}

if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
return true;
}

return false;
}


Function returns true if block editor is active by any means, and false – in the case if classic editor is here. This function must only be used after plugins_loaded action is fired.



P.S. Due release of version 1.2 of Classic Editor plugin, code is updated, as classic-editor-replace options now takes values not replace and no-replace, but classic and block.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 14 '18 at 18:42

























answered Nov 30 '18 at 10:01









KAGG DesignKAGG Design

1,224312




1,224312












  • not going o downvote, but it is not a fail safe answer. You should do detection based on actions or filters being triggered, not based n the existence of a file or a function. There are several ways to disable gutenberg and the classic editor is only one of them.
    – Mark Kaplun
    Nov 30 '18 at 16:02










  • or to say it differently, you should never even try to detect if gutenberg is used or not, but instead just hook whatever functionality you need on the relevant gutenberg hooks in addition to hooking on the tinymce hooks
    – Mark Kaplun
    Nov 30 '18 at 16:05


















  • not going o downvote, but it is not a fail safe answer. You should do detection based on actions or filters being triggered, not based n the existence of a file or a function. There are several ways to disable gutenberg and the classic editor is only one of them.
    – Mark Kaplun
    Nov 30 '18 at 16:02










  • or to say it differently, you should never even try to detect if gutenberg is used or not, but instead just hook whatever functionality you need on the relevant gutenberg hooks in addition to hooking on the tinymce hooks
    – Mark Kaplun
    Nov 30 '18 at 16:05
















not going o downvote, but it is not a fail safe answer. You should do detection based on actions or filters being triggered, not based n the existence of a file or a function. There are several ways to disable gutenberg and the classic editor is only one of them.
– Mark Kaplun
Nov 30 '18 at 16:02




not going o downvote, but it is not a fail safe answer. You should do detection based on actions or filters being triggered, not based n the existence of a file or a function. There are several ways to disable gutenberg and the classic editor is only one of them.
– Mark Kaplun
Nov 30 '18 at 16:02












or to say it differently, you should never even try to detect if gutenberg is used or not, but instead just hook whatever functionality you need on the relevant gutenberg hooks in addition to hooking on the tinymce hooks
– Mark Kaplun
Nov 30 '18 at 16:05




or to say it differently, you should never even try to detect if gutenberg is used or not, but instead just hook whatever functionality you need on the relevant gutenberg hooks in addition to hooking on the tinymce hooks
– Mark Kaplun
Nov 30 '18 at 16:05













1














You can use



add_action( 'enqueue_block_editor_assets', 'your_function_name' );


which is only fired when editing content with Gutenberg.






share|improve this answer





















  • This code works only on editor page.
    – KAGG Design
    Dec 3 '18 at 4:09










  • What about enqueue_block_assets?
    – Marc
    Dec 3 '18 at 16:43










  • has_action( 'enqueue_block_assets' ) does the same what has_filter( 'replace_editor' in my code. It returns true if Classic Editor active and sets Classic Editor as default. It is better to check what you propose before writing.
    – KAGG Design
    Dec 10 '18 at 8:46
















1














You can use



add_action( 'enqueue_block_editor_assets', 'your_function_name' );


which is only fired when editing content with Gutenberg.






share|improve this answer





















  • This code works only on editor page.
    – KAGG Design
    Dec 3 '18 at 4:09










  • What about enqueue_block_assets?
    – Marc
    Dec 3 '18 at 16:43










  • has_action( 'enqueue_block_assets' ) does the same what has_filter( 'replace_editor' in my code. It returns true if Classic Editor active and sets Classic Editor as default. It is better to check what you propose before writing.
    – KAGG Design
    Dec 10 '18 at 8:46














1












1








1






You can use



add_action( 'enqueue_block_editor_assets', 'your_function_name' );


which is only fired when editing content with Gutenberg.






share|improve this answer












You can use



add_action( 'enqueue_block_editor_assets', 'your_function_name' );


which is only fired when editing content with Gutenberg.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 30 '18 at 16:27









MarcMarc

111




111












  • This code works only on editor page.
    – KAGG Design
    Dec 3 '18 at 4:09










  • What about enqueue_block_assets?
    – Marc
    Dec 3 '18 at 16:43










  • has_action( 'enqueue_block_assets' ) does the same what has_filter( 'replace_editor' in my code. It returns true if Classic Editor active and sets Classic Editor as default. It is better to check what you propose before writing.
    – KAGG Design
    Dec 10 '18 at 8:46


















  • This code works only on editor page.
    – KAGG Design
    Dec 3 '18 at 4:09










  • What about enqueue_block_assets?
    – Marc
    Dec 3 '18 at 16:43










  • has_action( 'enqueue_block_assets' ) does the same what has_filter( 'replace_editor' in my code. It returns true if Classic Editor active and sets Classic Editor as default. It is better to check what you propose before writing.
    – KAGG Design
    Dec 10 '18 at 8:46
















This code works only on editor page.
– KAGG Design
Dec 3 '18 at 4:09




This code works only on editor page.
– KAGG Design
Dec 3 '18 at 4:09












What about enqueue_block_assets?
– Marc
Dec 3 '18 at 16:43




What about enqueue_block_assets?
– Marc
Dec 3 '18 at 16:43












has_action( 'enqueue_block_assets' ) does the same what has_filter( 'replace_editor' in my code. It returns true if Classic Editor active and sets Classic Editor as default. It is better to check what you propose before writing.
– KAGG Design
Dec 10 '18 at 8:46




has_action( 'enqueue_block_assets' ) does the same what has_filter( 'replace_editor' in my code. It returns true if Classic Editor active and sets Classic Editor as default. It is better to check what you propose before writing.
– KAGG Design
Dec 10 '18 at 8:46


















draft saved

draft discarded




















































Thanks for contributing an answer to WordPress Development Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f320653%2fhow-to-detect-the-usage-of-gutenberg%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How do I know what Microsoft account the skydrive app is syncing to?

When does type information flow backwards in C++?

Grease: Live!