Ah, got it. My mistake:
wp_dequeue_style('xoo-wsc-style');
wp_deregister_style('xoo-wsc-style');
-
This reply was modified 1 year, 6 months ago by
cutu234.
Ah, not yet! Unfortunately, this will also remove the main plugin CSS stylesheet, since both uses the same base for the ID.
How would I remove only the inline CSS, while keeping the main stylesheet?
Plugin Author
xootix
(@xootix)
Hello @cutu234
It isn’t added via stylesheet because its dynamic in nature. The CSS is generated from your settings options and changes when you change the options.
The few lines of inline CSS won’t do any harm but still if you want to remove it, you can use this PHP snippet.
add_action( 'wp_print_styles', function()
{
// Remove previous inline style
wp_styles()->add_data( 'xoo-wsc-style', 'after', '' );
} );
However, you will need to first copy the generated inline CSS and paste it in your custom stylesheet & you will need to repeat this every time you change a styling option in the settings.
There is another way to handle this & it will need a plugin update from my end. This approach is followed by the plugins which require huge amount of inline styling such as Elementor, they dynamically generate CSS files.
Initially, in our case there wasn’t a need for this because of few lines of inline CSS but over the period of time, the styling options have increased which led to increase in inline style, I still think its not that huge and won’t do any harm in performance, however, I am considering now to shift to this method of generating dynamic CSS files.
-
This reply was modified 1 year, 6 months ago by
xootix.
Awesome, thank you very much! That did the trick. Don’t get me wrong. I don’t think that a little bit inline CSS will do any harm. I just like to keep things tidy. For me, it’s much easier for maintenance. Most users will not even notice the inline CSS.
No need for major changes. I’m more than happy with the code snippet.