Created
October 20, 2022 01:14
-
-
Save seothemes/0396a90533d1d74c7ec54b07554d31eb to your computer and use it in GitHub Desktop.
Merge parent theme style variation with active child theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'theme_json_theme', 'get_parent_theme_style_variation_data' ); | |
/** | |
* Merges parent theme style variation data with active theme.json. | |
* | |
* @since 1.0.0 | |
* | |
* @param mixed $theme_json WP_Theme_JSON_Data | WP_Theme_JSON_Data_Gutenberg. | |
* | |
* @return mixed | |
*/ | |
function get_parent_theme_style_variation_data( $theme_json ) { | |
$parent_style_variation = get_template_directory() . '/styles/dark-mode.json'; | |
$parent_style_json = json_decode( file_get_contents( $parent_style_variation ), true ); | |
return $theme_json->update_with( $parent_style_json ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment