Block variation styles are parsed and processed through wp_render_block_style_variation_support_styles(). This is marked as private and thus should not be called by third-party code outside WordPress core. This function is called by virtue of being hooked into the render_block_data hook.
Thus, if you have a subset of known block structures that may appear, you could consider running some block renders somewhere. These renders would not pass their output anywhere but only specifically for their side effects, one being to generate their required block style variations.
You could create the block markup as a string and then use do_blocks() to render them:
do_blocks(
<<<HTML
<!-- wp:paragraph {"className":"is-style-foo"} -->
<p class="is-style-foo">Render this style for its side effects.</p>
<!-- /wp:paragraph -->
HTML
);
Related Posts:
- How to add more elements to an already existing section in Gutenberg
- Working with a non-React external library in a custom block
- Masonry gallery block is working in the block editor but not the template editor
- How to import the imagesLoaded and Masonry libs that come with WP in a Gutenberg block?
- Embedded data and the _fields parameter in getEntityRecords
- Force-update the meta variable first set using `var [ meta, setMeta = useEntityProp( ‘postType’, postType, ‘meta’ );`
- How to build BOTH non-block components and blocks present in the /src directory using @wordpress/scripts
- How to add an additional dependency to a block index.asset.php file
- Why is the Gutenberg editor not recognizing my updates?
- How to transform a shortcode into a block
- How to re-render Gutenberg component when object instance is available
- useSelect() plus resolver result is serving cached data incorrectly
- Gutenberg DatePicker component with time set to zero
- How to render HTML content using the Interactivity API?
- Extend WordPress Gutenberg core/navigation-link
- How to auto rename JS files to prevent browser cache issues
- How to render initial posts on page load in a Gutenberg block using the Interactivity API?
- Trigger Javascript on Gutenberg (Block Editor) Save
- What are all the query parameters for getEntityRecords?
- Show control conditionally in Gutenberg
- Get loading state of wp data selector
- How to get the ToggleControl Gutenberg component working for a PHP Block
- Is there a core Sortable component in Gutenberg?
- Is there an equivalent of the PHP function sanitize_key in Gutenberg?
- Is there a client side API for handling transients or options?
- What do the args for Gutenberg subpackage “hooks” function “doAction” mean?
- How do I fire a snackbar notice in admin?
- Gutenberg Modify core taxonomy panel element via wp.hooks.addFilter
- What is “open()” in MediaUpload?
- Why is this gutenberg custom format button only available from the toolbar as a dropdown?
- Adding a text element in between title and blocks container
- Setting HTML properties in a Gutenberg plugin using WordPress settings
- Provide specific example for block variation
- Set current tab on a Gutenberg TabPanel component from outside that component
- Block editor: How to check if block editor has initialized and populated the data store?
- Gutenberg block “This block appears to have been modified externally” on save
- How to get value of selected page template in Gutenberg editor?
- @wordpress/components Button variants not styled
- Block Editor: How to get title and post content within the WordPress admin UI in Javascript?
- Custom block SelectControl works but equivalent ComboboxControl gives errors – where’s my mistake?
- Gutenberg passing block attributes to component in ES6/ESNext
- Can the index.asset.php file be used with the enqueue_block_editor_assets action?
- How can I add Block Style support to the core HTML block in Gutenberg?
- var is undefined in a Gutenberg block
- Using wp.data.select get actual tags (not id’s) used in post
- can a buttongroup have a label?
- How to remove p / br elements from gutenbergs editor
- Programatically update posts in database from one block to another using transform
- InnerBlocks restricting does not work on nested blocks
- Gutenberg: Block validation Failed Richtext undefined
- Add A Tag To A Post Through JavaScript In Gutenberg UI?
- Add custom HTML markup to Gutenberg RichText
- Listening change event of taxonomy term checkboxes in Gutenberg editor
- How to return div with custom attributes(Coding a Gutenberg Block)
- Gutenberg get core data – search
- Get Block Attributes in JSON REST API
- Open Featured Image Modal in WordPress Gutenberg onClick of a button
- How to add classes and events to image in javascript using Gutenberg?
- Checks when fetching data from multiple REST API endpoints in Gutenberg
- Using apiFetch for retrieving post data in Gutenberg
- Looping over wordpress meta to create “ ‘s?
- How to display post content in the block editor
- How to load an additional script for a block in the block editor?
- Gutenberg consume wp-json data and reflect in frontend the content
- How can I import one custom block into another?
- Gutenberg Blocks: how to determine an index of the current inner block?
- Gutenberg select excerpt, use generated excerpt or use more block excerpt
- find out reason of “Updating failed” in Post-editor
- Gutenberg RangeControl
- Custom Gutenberg block: access dom element via JavaScript
- Add a Page Screen is Visually Blank
- Including dependencies using @wordpress/dependency-extraction-webpack-plugin
- Gutenberg sidebar show input field on toggle
- Get the ID of a page in Parent combobox in editor
- Uncaught TypeError: r is not a function
- Update block once an API request returns with a value
- How do I make a savable preview like Youtube Gutenberg block?
- iFrame onLoad in custom Gutenberg block
- WordPress Gutenberg: Attribute overwritten by block duplicate
- Filtering Gutenberg Components, not Blocks
- How to delete child block for associated parent block
- Passing object to FormTokenField suggestions
- How to add a new attribute to core wp block editor without npm?
- How do i get an Inline style in Gutenberg Block show up in front end?
- WordPress adds and tags into HTML blocks after saving
- How do i fix type error
- Gutenberg core/file add style support in js/ json
- Create Youtube embed block with createBlock
- Event when Modal is opened/visible
- Jest Unit tests for High order component containing Block Editor
- Separate typography controls for titles and meta in a custom block?
- Include Block Variation Within InnerBlocks
- Gutenberg block: add a multi-select for posts
- Cannot call a class as a function in block plugin react component
- configure additonal build files in the @wordpress/create-block
- Metabox conditionals depending on post format and template in Gutenberg
- How to access current discussion settings in gutenberg via JS?
- Why Is wp.editor Not Adding the ”Add Media” Button When I Initialize It?
- How to get selected category objects in the block editor?
- Add a React search box to blog home error – Cannot read properties of undefined (reading ‘jsx’)