From ce47d4137a9d142e4b9404b12c2acb8c474cac3d Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sat, 1 May 2021 23:31:34 +0200 Subject: [PATCH] fix: remove unnecessary translations from front-end By removing the previous dependencies, an `Uncaught TypeError` was generated. In fact, translations are useless in front-end since the meta can be translated in the block editor. This way, there are no errors and no unnecessary scripts. --- post-types-query.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/post-types-query.php b/post-types-query.php index 547377a..e934b46 100644 --- a/post-types-query.php +++ b/post-types-query.php @@ -53,7 +53,7 @@ * @since 0.1.0 */ function ptqblock_enqueue_livereload() { - wp_enqueue_script( 'livereload', 'http://localhost:35729/livereload.js', array(), PTQBLOCK_VERSION, true ); + wp_enqueue_script( 'livereload', 'https://localhost:35729/livereload.js', array(), PTQBLOCK_VERSION, true ); } if ( isset( $ptqblock_current_env ) && 'development' === $ptqblock_current_env ) { @@ -296,7 +296,7 @@ function ptqblock_block_init() { wp_register_script( 'ptqblock-i18n', plugins_url( 'build/index.js', __FILE__ ), - array(), + $asset_file['dependencies'], $asset_file['version'], true ); @@ -306,7 +306,6 @@ function ptqblock_block_init() { array( 'title' => __( 'Post Types Query Block', 'PTQBlock' ), 'description' => __( 'Display a list of posts based on (custom) post types.', 'PTQBlock' ), - 'script' => 'ptqblock-i18n', 'editor_script' => 'ptqblock-i18n', 'render_callback' => 'ptqblock_render_post_types_block', ) @@ -337,17 +336,3 @@ function ptqblock_enqueue_admin_scripts() { ); } add_action( 'admin_enqueue_scripts', 'ptqblock_enqueue_admin_scripts' ); - -/** - * Enqueue translation scripts - * - * @since 0.1.0 - */ -function ptqblock_enqueue_scripts() { - wp_set_script_translations( - 'ptqblock-i18n', - 'PTQBlock', - plugin_dir_path( __FILE__ ) . 'languages' - ); -} -add_action( 'wp_enqueue_scripts', 'ptqblock_enqueue_scripts' );