admin管理员组文章数量:1291452
I am working on removing the default Gutenberg block library stylesheet and replacing it with custom pared-down styles. I do not want the original stylesheet to load on either the front or back end, as it means I'd need to add unnecessary bulk to the custom styles in order to override styles in the default stylesheet.
I've successfully dequeued the styles from the front end using the standard in a wp_enqueue_scripts
action:
function test_function(){
wp_dequeue_style('wp-block-library');
}
add_action( 'wp_enqueue_scripts', 'test_function' );
However, this does not dequeue the styles from the block editor. I have tried dequeuing from an admin_init
action as well, and that also does not remove the styles from the block editor.
Is it possible to dequeue this stylesheet from both the front-end and the admin block editor?
I am working on removing the default Gutenberg block library stylesheet and replacing it with custom pared-down styles. I do not want the original stylesheet to load on either the front or back end, as it means I'd need to add unnecessary bulk to the custom styles in order to override styles in the default stylesheet.
I've successfully dequeued the styles from the front end using the standard in a wp_enqueue_scripts
action:
function test_function(){
wp_dequeue_style('wp-block-library');
}
add_action( 'wp_enqueue_scripts', 'test_function' );
However, this does not dequeue the styles from the block editor. I have tried dequeuing from an admin_init
action as well, and that also does not remove the styles from the block editor.
Is it possible to dequeue this stylesheet from both the front-end and the admin block editor?
Share Improve this question asked May 27, 2021 at 23:59 StudioAlStudioAl 4941 gold badge3 silver badges15 bronze badges 1- you're using the frontend specific enqueue scripts hook, you should use the admin area specific hook instead, though there's probably a better more official way to do this than dequeuing – Tom J Nowell ♦ Commented May 28, 2021 at 0:12
1 Answer
Reset to default 3Of course, five minutes after I post the question, I find a solution: Using
wp_deregister_style('wp-block-library')
(instead of wp_dequeue_style('wp-block-library')
) works for the block editor. It worked in either an admin_init
or an admin_enqueue_scripts
action.
本文标签: wp enqueue scriptDequeue Gutenburg Block Library CSS (39wpblocklibrary39) in Admin
版权声明:本文标题:wp enqueue script - Dequeue Gutenburg Block Library CSS ('wp-block-library') in Admin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741533902a2383918.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论