From 318efb0f40d89ee4ec972dc3f6062fe43a86f240 Mon Sep 17 00:00:00 2001 From: rezaelahidev Date: Tue, 12 Nov 2024 15:44:31 +0330 Subject: [PATCH] refactor: improved EditorAssetsProvider after inline scripts --- packages/blockera/php/Providers/EditorAssetsProvider.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/blockera/php/Providers/EditorAssetsProvider.php b/packages/blockera/php/Providers/EditorAssetsProvider.php index c1b3542c0..ca1cc2233 100644 --- a/packages/blockera/php/Providers/EditorAssetsProvider.php +++ b/packages/blockera/php/Providers/EditorAssetsProvider.php @@ -177,8 +177,15 @@ function ( string $block_type ) use ( $editor_object, $app ): string { apply_filters( 'blockera/assets/provider/inline-script/register/3rd-party-blocks/attributes', [] ) ); - return implode( ";\n", $blocks_attributes_scripts ) . ' + $script = implode( ";\n", $blocks_attributes_scripts ) . ' ' . $editor_object . '.editor.unstableRegistrationSharedBlockAttributes(' . wp_json_encode( $shared_block_attributes ) . ');'; + + if ( false !== strpos( $inline_script, $script ) ) { + + return $inline_script; + } + + return sprintf( '%s%s', $inline_script . PHP_EOL, $script ); } /**