diff --git a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php index 183b6ee39df12..fa700dd478310 100644 --- a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php @@ -150,25 +150,22 @@ public static function get_plugin_theme_data() { if ( null === static::$plugins ) { $plugins_data = array(); $active_plugin_paths = wp_get_active_and_valid_plugins(); + $plugin_json = new WP_Theme_JSON_Gutenberg(); foreach ( $active_plugin_paths as $path ) { $config = static::read_json_file( dirname( $path ) . '/theme.json' ); if ( ! empty( $config ) ) { + $plugin_meta_data = get_plugin_data( $path, false, false ); + if ( isset( $plugin_meta_data['TextDomain'] ) ) { + $config = static::translate( $config, $plugin_meta_data['TextDomain'] ); + } + // TODO, this is where we could potentially introduce different merge + // strategies for plugin provided data. + $plugin_json->merge( + new WP_Theme_JSON_Gutenberg( $config ) + ); $plugins_data[ $path ] = $config; } } - // have configs from plugins, now let's register and merge. - $plugin_json = new WP_Theme_JSON_Gutenberg(); - foreach ( $plugins_data as $plugin_path => $plugin_config ) { - $plugin_meta_data = get_plugin_data( $plugin_path, false, false ); - if ( isset( $plugin_meta_data['TextDomain'] ) ) { - $plugin_config = static::translate( $plugin_config, $plugin_meta_data['TextDomain'] ); - } - // TODO, this is where we could potentially introduce different merge - // strategies for plugin provided data. - $plugin_json->merge( - new WP_Theme_JSON_Gutenberg( $plugin_config ) - ); - } static::$plugins = $plugin_json; } return static::$plugins;