diff --git a/public/themes/wordplate/functions.php b/public/themes/wordplate/functions.php index 4a1dbd7..94316b1 100644 --- a/public/themes/wordplate/functions.php +++ b/public/themes/wordplate/functions.php @@ -23,15 +23,24 @@ wp_get_environment_type() === 'local' && is_array(wp_remote_get('http://localhost:5173/')) // is Vite.js running ) { - wp_enqueue_script_module('vite', 'http://localhost:5173/@vite/client'); - wp_enqueue_script_module('wordplate', 'http://localhost:5173/resources/js/index.js'); + wp_enqueue_script('vite', 'http://localhost:5173/@vite/client'); + wp_enqueue_script('wordplate', 'http://localhost:5173/resources/js/index.js'); } elseif (file_exists($manifestPath)) { $manifest = json_decode(file_get_contents($manifestPath), true); - wp_enqueue_script_module('wordplate', get_theme_file_uri('assets/' . $manifest['resources/js/index.js']['file'])); + wp_enqueue_script('wordplate', get_theme_file_uri('assets/' . $manifest['resources/js/index.js']['file'])); wp_enqueue_style('wordplate', get_theme_file_uri('assets/' . $manifest['resources/js/index.js']['css'][0])); } }); +// Load scripts as modules. +add_filter('script_loader_tag', function (string $tag, string $handle, string $src) { + if (in_array($handle, ['vite', 'wordplate'])) { + return ''; + } + + return $tag; +}, 10, 3); + // Remove admin menu items. add_action('admin_init', function () { remove_menu_page('edit-comments.php'); // Comments