Comments (5)
Yes, this bug is still there. A quick fix is to comment out the initiation of the blocks setup in line 170 of safe-svg.php.
From
Blocks\setup();
to
//Blocks\setup();
But you will have to do that after every plugin update.
A more robust workaround would be an action to allow the deactivation of the blocks setup in the functions.php when not needed. Something like this:
Change the code in safe-svg.php from
public function setup_blocks() {
Blocks\setup();
}
to
public function setup_blocks() {
add_action('safe_svg_blocks', function () {
if (isset($this->disabled)) {
return;
}
else {
Blocks\setup();
}
});
do_action('safe_svg_blocks', $this);
}
public function safe_svg_blocks_disable() {
$this->disabled = true;
}
Now you can disable the blogs setup with the following action in functions.php:
add_action('safe_svg_blocks', function (SafeSvg\safe_svg $safe_svg_blocks) {
$safe_svg_blocks->safe_svg_blocks_disable();
});
from safe-svg.
Curious if there are additional reproduction steps that could be provided here? I've tried reproducing this myself but the only time I see that CSS being loaded is if I'm on a post or page that uses the Safe SVG block. All other posts, pages, home page, etc don't load that CSS.
I've tried testing both on content created with the Block Editor and content created with the Classic Editor, both posts and pages but I never see that CSS load unless the block is being used.
from safe-svg.
As thomasbachem described: An old-style custom WordPress theme without blocks and upgraded to recent WP + Safe SVG versions.
from safe-svg.
@dkotter I was able to reproduce this issue in a classic theme(twentyfourteen). So this issue is actually a WP core behaviour and not a safe-svg plugin specific issue. On non-block themes, WordPress renders styles of all blocks regardless of if they're rendered or not. This happens in wp_enqueue_registered_block_scripts_and_styles function which is hooked on enqueue_block_assets action.
So all WP would render styles of all the blocks registered by all the plugins. To disable this behaviour and render a style only when the block is loaded, add this filter in the code and it should be sorted:
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
Since this is a WP core behaviour, I don't think we need to create a workaround for it in our code.
from safe-svg.
kirtangajjar the propblem of this solution is that you now get the "global-styles-inline-css"-style injected in the html, which kinda defeats the purpose.
from safe-svg.
Related Issues (20)
- When svg optimization is turned on, a javascript error can occur that breaks saving content HOT 1
- Clean up NPM dependencies and update node to v20
- The plugin hasn't been tested with an upcoming version of WordPress
- SVGs have a 10mb size Limit
- Release version 2.2.3
- Uncaught TypeError: Cannot read properties of undefined (reading 'isSavingPost') HOT 6
- Fatal Error in Version 2.2.3, Calling member function attributes() on a Bool HOT 4
- Release version 2.2.4
- Allow the `current_user_can_upload_svg` method to be filtered HOT 3
- PHP 8.3 Compatibility HOT 4
- SafeSVG fatal error
- Fatal error in safe-svg/includes/blocks.php:51 when accessing the Wordpress Customizer HOT 2
- Incompability with e-payeye-payments
- SVG dimensions broken after 2.2.3 HOT 2
- The plugin hasn't been tested with an upcoming version of WordPress HOT 1
- Release version 2.2.5
- PHP 8.3 compatibility HOT 3
- No RDF metadata HOT 3
- Cypress dependency in runtime dependencies
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from safe-svg.