@@ -314,4 +314,82 @@ public static function enqueue_global_css_inline() {
314314 }
315315
316316 new Stackable_Global_Design_System_CSS_Generator ();
317+ }
318+
319+ if ( ! class_exists ( 'Stackable_Block_Style_Inheritance_CSS_Generator ' ) ) {
320+
321+ /**
322+ * Block Style Inheritance CSS Generator - Extends the base class for block theme style inheritance.
323+ */
324+ class Stackable_Block_Style_Inheritance_CSS_Generator extends Stackable_Base_CSS_File_Generator {
325+
326+ /**
327+ * CSS file handle for block style inheritance.
328+ */
329+ protected static function get_css_handle () {
330+ return 'ugb-block-style-inheritance ' ;
331+ }
332+
333+ /**
334+ * CSS file name prefix.
335+ */
336+ protected static function get_css_file_prefix () {
337+ return 'stackable-block-inheritance- ' ;
338+ }
339+
340+ /**
341+ * Option name for caching the CSS file name.
342+ */
343+ protected static function get_cache_option_name () {
344+ return 'stackable_block_inheritance_css_file_name ' ;
345+ }
346+
347+ /**
348+ * Generate the CSS content from block style inheritance filters.
349+ *
350+ * @return string
351+ */
352+ protected static function generate_css_content () {
353+ // Apply the filter that contributes to block style inheritance
354+ $ css_content = apply_filters ( 'stackable_block_style_inheritance_inline_styles_nodep ' , '' );
355+
356+ // Add any additional block inheritance styles that might be needed
357+ $ css_content = apply_filters ( 'stackable_block_inheritance_css_file_content ' , $ css_content );
358+
359+ return trim ( $ css_content );
360+ }
361+
362+ /**
363+ * Initialize
364+ */
365+ function __construct () {
366+ // Add hooks to regenerate CSS when theme.json or block settings change
367+ add_action ( 'switch_theme ' , array ( $ this , 'invalidate_current_css_file ' ) );
368+ add_action ( 'update_option_theme_mods_ ' . get_stylesheet (), array ( $ this , 'invalidate_current_css_file ' ) );
369+ add_action ( 'customize_save_after ' , array ( $ this , 'invalidate_current_css_file ' ) );
370+ }
371+
372+ /**
373+ * Regenerate the CSS file when block style inheritance settings change.
374+ */
375+ public function invalidate_current_css_file () {
376+ static ::invalidate_css_file ();
377+ }
378+
379+ /**
380+ * Enqueue the block inheritance CSS file (alias for backward compatibility).
381+ */
382+ public static function enqueue_block_inheritance_css_file () {
383+ return static ::enqueue_css_file ();
384+ }
385+
386+ /**
387+ * Enqueue the block inheritance CSS as inline styles (useful for debugging or when file generation is disabled).
388+ */
389+ public static function enqueue_block_inheritance_css_inline () {
390+ return static ::enqueue_inline_css ();
391+ }
392+ }
393+
394+ new Stackable_Block_Style_Inheritance_CSS_Generator ();
317395}
0 commit comments