This question already has answers here: check if Gutenberg is currently in use (9 answers) Closed 6 years ago.admin管理员组文章数量:1130349
Previously I could use is_gutenberg_page(), but this function seems to be gone after 5.0 release.
Any tips on how to check if current admin page is gutenberg editor?
This question already has answers here: check if Gutenberg is currently in use (9 answers) Closed 6 years ago.Previously I could use is_gutenberg_page(), but this function seems to be gone after 5.0 release.
Any tips on how to check if current admin page is gutenberg editor?
Share Improve this question asked Dec 8, 2018 at 6:17 Marvin3Marvin3 6631 gold badge10 silver badges20 bronze badges 2- please try this code but i am not confirm – vikrant zilpe Commented Dec 8, 2018 at 7:35
- global $current_screen; $current_screen = get_current_screen(); if ( ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ) || ( function_exists('is_gutenberg_page')) && is_gutenberg_page() ) ) { // DO SOMETHING } – vikrant zilpe Commented Dec 8, 2018 at 7:35
1 Answer
Reset to default 3In 5.0 new function was introduced (docs):
WP_Screen::is_block_editor( bool $set = null )
which sets or returns whether the block editor is loading on the current screen.
So you can do that check using this code:
global $current_screen;
$current_screen = get_current_screen();
if ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ) {
// DO SOMETHING
}
You can also add to this condition
|| ( function_exists('is_gutenberg_page')) && is_gutenberg_page() )
to be compatible with older versions.
This question already has answers here: check if Gutenberg is currently in use (9 answers) Closed 6 years ago.Previously I could use is_gutenberg_page(), but this function seems to be gone after 5.0 release.
Any tips on how to check if current admin page is gutenberg editor?
This question already has answers here: check if Gutenberg is currently in use (9 answers) Closed 6 years ago.Previously I could use is_gutenberg_page(), but this function seems to be gone after 5.0 release.
Any tips on how to check if current admin page is gutenberg editor?
Share Improve this question asked Dec 8, 2018 at 6:17 Marvin3Marvin3 6631 gold badge10 silver badges20 bronze badges 2- please try this code but i am not confirm – vikrant zilpe Commented Dec 8, 2018 at 7:35
- global $current_screen; $current_screen = get_current_screen(); if ( ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ) || ( function_exists('is_gutenberg_page')) && is_gutenberg_page() ) ) { // DO SOMETHING } – vikrant zilpe Commented Dec 8, 2018 at 7:35
1 Answer
Reset to default 3In 5.0 new function was introduced (docs):
WP_Screen::is_block_editor( bool $set = null )
which sets or returns whether the block editor is loading on the current screen.
So you can do that check using this code:
global $current_screen;
$current_screen = get_current_screen();
if ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ) {
// DO SOMETHING
}
You can also add to this condition
|| ( function_exists('is_gutenberg_page')) && is_gutenberg_page() )
to be compatible with older versions.
本文标签: How to check if current admin page is Gutenberg editor
版权声明:本文标题:How to check if current admin page is Gutenberg editor? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749116714a2318319.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论