From dc50a4de5a7561703c6380218aec9e2f80726ba2 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Mon, 16 Dec 2024 14:09:35 +0200 Subject: [PATCH] refactor: sub-plugins translation location --- inc/class-blocks-animation.php | 26 ++++++++++++++++++++++---- inc/class-blocks-css.php | 7 +++++-- inc/class-blocks-export-import.php | 8 ++++++-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/inc/class-blocks-animation.php b/inc/class-blocks-animation.php index 4b1362107..e72fa637a 100644 --- a/inc/class-blocks-animation.php +++ b/inc/class-blocks-animation.php @@ -92,7 +92,11 @@ public function enqueue_editor_assets() { ) ); - wp_set_script_translations( 'otter-animation', 'blocks-animation' ); + if ( ! defined( 'BLOCKS_ANIMATION_URL' ) ) { + wp_set_script_translations( 'otter-animation', 'otter-blocks' ); + } else { + wp_set_script_translations( 'otter-animation', 'blocks-animation' ); + } $asset_file = include BLOCKS_ANIMATION_PATH . '/build/animation/anim-count.asset.php'; wp_enqueue_script( @@ -104,7 +108,12 @@ public function enqueue_editor_assets() { ); wp_script_add_data( 'otter-count', 'defer', true ); - wp_set_script_translations( 'otter-count', 'blocks-animation' ); + + if ( ! defined( 'BLOCKS_ANIMATION_URL' ) ) { + wp_set_script_translations( 'otter-count', 'otter-blocks' ); + } else { + wp_set_script_translations( 'otter-count', 'blocks-animation' ); + } wp_enqueue_script( 'otter-typing', @@ -115,7 +124,12 @@ public function enqueue_editor_assets() { ); wp_script_add_data( 'otter-typing', 'defer', true ); - wp_set_script_translations( 'otter-typing', 'blocks-animation' ); + + if ( ! defined( 'BLOCKS_ANIMATION_URL' ) ) { + wp_set_script_translations( 'otter-typing', 'otter-blocks' ); + } else { + wp_set_script_translations( 'otter-typing', 'blocks-animation' ); + } } /** @@ -253,7 +267,11 @@ public function render_welcome_notice() { true ); - wp_set_script_translations( 'otter-animation-welcome-notice-scripts', 'blocks-animation' ); + if ( ! defined( 'BLOCKS_ANIMATION_URL' ) ) { + wp_set_script_translations( 'otter-animation-welcome-notice-scripts', 'otter-blocks' ); + } else { + wp_set_script_translations( 'otter-animation-welcome-notice-scripts', 'blocks-animation' ); + } wp_localize_script( 'otter-animation-welcome-notice-scripts', diff --git a/inc/class-blocks-css.php b/inc/class-blocks-css.php index cf684c7ca..4e5fa47f9 100644 --- a/inc/class-blocks-css.php +++ b/inc/class-blocks-css.php @@ -67,7 +67,6 @@ public function enqueue_editor_assets() { $asset_file['version'], true ); - wp_set_script_translations( 'otter-css', 'blocks-css' ); wp_localize_script( 'otter-css', @@ -87,7 +86,11 @@ public function enqueue_editor_assets() { ) ); - wp_set_script_translations( 'otter-css', 'blocks-css' ); + if ( ! defined( 'BLOCKS_CSS_URL' ) ) { + wp_set_script_translations( 'otter-css', 'otter-blocks' ); + } else { + wp_set_script_translations( 'otter-css', 'blocks-css' ); + } wp_enqueue_style( 'otter-css', diff --git a/inc/class-blocks-export-import.php b/inc/class-blocks-export-import.php index 433bdb9ce..2c77735fd 100644 --- a/inc/class-blocks-export-import.php +++ b/inc/class-blocks-export-import.php @@ -47,8 +47,12 @@ public function enqueue_editor_assets() { $asset_file['version'], true ); - - wp_set_script_translations( 'blocks-export-import', 'blocks-export-import' ); + + if ( ! defined( 'BLOCKS_EXPORT_IMPORT_URL' ) ) { + wp_set_script_translations( 'blocks-export-import', 'otter-blocks' ); + } else { + wp_set_script_translations( 'blocks-export-import', 'blocks-export-import' ); + } } /**