Skip to content

Commit

Permalink
Merge pull request #4 from alleyinteractive/hotfix/merge-block-regist…
Browse files Browse the repository at this point in the history
…ry-updates

Merge registry updates with old values
  • Loading branch information
mboynes authored Dec 12, 2024
2 parents c903946 + 0d23de2 commit 2e31686
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Blocks/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ function ($arr, $block_type) {
}

public static function update_registry( $registry ) {
return update_option( WP_GRAPHQL_GUTENBERG_REGISTRY_OPTION_NAME, $registry, false );
// Merge the new registry with the old registry. This will ensure that we don't remove any blocks that were
// available in another context (e.g. another post type) but not this one.
$old_values = get_option( WP_GRAPHQL_GUTENBERG_REGISTRY_OPTION_NAME, [] ) ?? [];
return update_option( WP_GRAPHQL_GUTENBERG_REGISTRY_OPTION_NAME, array_merge( $old_values, $registry ), false );
}

/**
Expand Down

0 comments on commit 2e31686

Please sign in to comment.