From 91d26659b200340146a0a6633f4c764b05db9acd Mon Sep 17 00:00:00 2001 From: ashfame Date: Wed, 16 Apr 2025 00:08:16 +0400 Subject: [PATCH 1/4] test with WP 6.8 --- .wp-env.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.wp-env.json b/.wp-env.json index 2542c32..3a8a4f9 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -1,5 +1,5 @@ { - "core": "WordPress/WordPress#6.7.1", + "core": "WordPress/WordPress#6.8", "phpVersion": "7.4", "plugins": [ "." ] } From 3c0fb3491cf6a03dc04fceb90964849191447a6e Mon Sep 17 00:00:00 2001 From: ashfame Date: Wed, 16 Apr 2025 00:13:03 +0400 Subject: [PATCH 2/4] fix notice caused by calling translate function before init Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the chatrix domain was triggered too early. --- src/Block/block.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Block/block.php b/src/Block/block.php index 9faee48..259f9db 100644 --- a/src/Block/block.php +++ b/src/Block/block.php @@ -6,15 +6,15 @@ function register() { $block_path = dirname( plugin_dir_path( __FILE__ ), 2 ) . '/build/block'; $block_json_path = "$block_path/block.json"; - register_site_status_test( $block_json_path ); - - if ( ! file_exists( $block_json_path ) ) { - return; - } - add_action( 'init', function () use ( $block_json_path ) { + register_site_status_test( $block_json_path ); + + if ( ! file_exists( $block_json_path ) ) { + return; + } + $metadata = parse_block_json( $block_json_path ); register_block_type( $block_json_path, From 0ad13aebca1dbcc9a174de1a4c5de4d74434ea45 Mon Sep 17 00:00:00 2001 From: ashfame Date: Thu, 17 Apr 2025 20:27:49 +0400 Subject: [PATCH 3/4] fix regression introduced in #249 and load ChatrixConfig object so that correct iframe src is deduced --- src/plugin.php | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/plugin.php b/src/plugin.php index 986baa3..c68a2d9 100644 --- a/src/plugin.php +++ b/src/plugin.php @@ -20,19 +20,36 @@ function main() { } function register_scripts() { + // Common configuration data for both admin and frontend + $json_data = wp_json_encode( + array( + 'rootUrl' => root_url() . '/iframe/', + ) + ); + + // Helper function to register and enqueue the configuration script + $register_config_script = function() use ( $json_data ) { + // Enqueue script for global configuration. + wp_register_script( SCRIPT_HANDLE_CONFIG, '', array(), automattic_chatrix_version(), true ); + wp_enqueue_script( SCRIPT_HANDLE_CONFIG ); + wp_add_inline_script( SCRIPT_HANDLE_CONFIG, 'window.' . CONFIG_VARIABLE . " = $json_data;" ); + }; + + // Admin scripts - needed for Gutenberg editor add_action( - 'wp_enqueue_scripts', - function () { - $json_data = wp_json_encode( - array( - 'rootUrl' => root_url() . '/iframe/', - ) - ); + 'admin_enqueue_scripts', + function () use ( $register_config_script ) { + // Register and enqueue configuration script in admin area + $register_config_script(); + } + ); - // Enqueue script for global configuration. - wp_register_script( SCRIPT_HANDLE_CONFIG, '', array(), automattic_chatrix_version(), true ); - wp_enqueue_script( SCRIPT_HANDLE_CONFIG ); - wp_add_inline_script( SCRIPT_HANDLE_CONFIG, 'window.' . CONFIG_VARIABLE . " = $json_data;" ); + // Frontend scripts + add_action( + 'wp_enqueue_scripts', + function () use ( $register_config_script ) { + // Register and enqueue configuration script + $register_config_script(); // Note we don't enqueue the SCRIPT_HANDLE_APP script yet. It will be enqueued whenever SCRIPT_HANDLE_APP // is specified as a dependency of another script. From 182730bea2e8010a23d4fcec4b9283ca6fec8319 Mon Sep 17 00:00:00 2001 From: ashfame Date: Thu, 17 Apr 2025 20:35:16 +0400 Subject: [PATCH 4/4] make stupid linter happy --- src/plugin.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugin.php b/src/plugin.php index c68a2d9..50c0f26 100644 --- a/src/plugin.php +++ b/src/plugin.php @@ -20,14 +20,14 @@ function main() { } function register_scripts() { - // Common configuration data for both admin and frontend + // Common configuration data for both admin and frontend. $json_data = wp_json_encode( array( 'rootUrl' => root_url() . '/iframe/', ) ); - // Helper function to register and enqueue the configuration script + // Helper function to register and enqueue the configuration script. $register_config_script = function() use ( $json_data ) { // Enqueue script for global configuration. wp_register_script( SCRIPT_HANDLE_CONFIG, '', array(), automattic_chatrix_version(), true ); @@ -35,20 +35,20 @@ function register_scripts() { wp_add_inline_script( SCRIPT_HANDLE_CONFIG, 'window.' . CONFIG_VARIABLE . " = $json_data;" ); }; - // Admin scripts - needed for Gutenberg editor + // Admin scripts - needed for Gutenberg editor. add_action( 'admin_enqueue_scripts', function () use ( $register_config_script ) { - // Register and enqueue configuration script in admin area + // Register and enqueue configuration script in admin area. $register_config_script(); } ); - // Frontend scripts + // Frontend scripts. add_action( 'wp_enqueue_scripts', function () use ( $register_config_script ) { - // Register and enqueue configuration script + // Register and enqueue configuration script. $register_config_script(); // Note we don't enqueue the SCRIPT_HANDLE_APP script yet. It will be enqueued whenever SCRIPT_HANDLE_APP