Skip to content

Commit

Permalink
Provide smart defaults for when the function runs in a filter
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Sep 9, 2022
1 parent 7c4d1bb commit 5d3b638
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/compat/wordpress-6.1/merge-theme-json.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<?php

function gutenberg_merge_theme_json( $existing_data, $incoming_data, $origin ) {
function gutenberg_merge_theme_json( $existing_data, $incoming_data, $origin = null ) {
if ( $origin === null && doing_filter( 'global_styles_filter_theme' ) ) {
$origin = 'theme';
}
if ( $origin === null && doing_filter( 'global_styles_filter_default' ) ) {
$origin = 'default';
}
if ( $origin === null && doing_filter( 'global_styles_filter_blocks' ) ) {
$origin = 'core';
}

$existing = new WP_Theme_JSON_Gutenberg( $existing_data, $origin );
$incoming = new WP_Theme_JSON_Gutenberg( $incoming_data, $origin );
$existing->merge( $incoming );
Expand Down

0 comments on commit 5d3b638

Please sign in to comment.