最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - Prevent wp-includescssdistcomponentsstyle.css being renderedloaded on the client side of my WP app

matteradmin1PV0评论

My host provider updated my application's version of WordPress to 6.7.2. Since then I have noticed on the frontend / public facing / client side of my application the following CSS file is now being loaded "wp-includes/css/dist/components/style.css"

I'm not sure where this has come from but in the theme I wrote for my application I added the following code to my functions.php file:

/**
 * REMOVE GUTENBERG BLOCK LIBRARY CSS FROM LOADING ON FRONTEND
 */
function remove_wp_block_library_css()
{
    wp_dequeue_style("wp-block-library");
    wp_dequeue_style("wp-block-library-theme");
    wp_dequeue_style("wc-block-style"); // REMOVE WOOCOMMERCE BLOCK CSS
    wp_dequeue_style("global-styles"); // REMOVE THEME.JSON
}

remove_action("wp_enqueue_scripts", "wp_enqueue_global_styles");
remove_action("wp_footer", "wp_enqueue_global_styles", 1);
add_action("wp_enqueue_scripts", "remove_wp_block_library_css", 100);

function wps_deregister_styles()
{
    wp_dequeue_style("global-styles");
}

add_action("wp_enqueue_scripts", "wps_deregister_styles", 100); 

Previously, before the upgrade it prevented any Gutenburg / Wordpress styling being rendered. Obviously the above isn't enough? Has anyone else experienced this and managed to prevent the "wp-includes/css/dist/components/style.css" being output/loaded without the use of a third party plugin?

Post a comment

comment list (0)

  1. No comments so far