diff --git a/plugins/wp_model_plugin/php/menu/menu.php b/plugins/wp_model_plugin/php/menu/menu.php index fa806b1..3b428f3 100644 --- a/plugins/wp_model_plugin/php/menu/menu.php +++ b/plugins/wp_model_plugin/php/menu/menu.php @@ -1,6 +1,10 @@ handle, $wp_scripts->queue); + if ($already_enqueued !== false) + return ; + $first_script = $file->handle; wp_enqueue_script( $file->handle, $file->url, $previous_js_basename, $file->version, true); $ajax_url = admin_url( 'admin-ajax.php' ); @@ -25,6 +34,7 @@ function add_ajax_post() { + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @param string : name of the file, with its path from its extension directory @@ -121,12 +131,10 @@ function add_var_to_front($vars, $handle = null) { extract($vars); foreach ($vars as $key => $var) { - $js_var = 'const ' . $key . ' = '; - $js_var .= json_encode($var); - $js_var .= ';'; + $js_var = 'let '.$key.' = '.json_encode($var).';'; wp_add_inline_script($handle, $js_var, 'before'); } -// + // the other way with localize has multiple incidences : // - it creates an object from wich you can access the variables // - so if you call it again wiht the same name, it will overwrite the previous diff --git a/plugins/wp_model_plugin/plugin_hooks.php b/plugins/wp_model_plugin/plugin_hooks.php index b787f1b..020aec1 100644 --- a/plugins/wp_model_plugin/plugin_hooks.php +++ b/plugins/wp_model_plugin/plugin_hooks.php @@ -70,10 +70,6 @@ function main_shortcode() { ) ); - global $wp_scripts; - console_log("wp_scripts->queue: "); - console_log($wp_scripts->queue); - return $html_front; } add_shortcode('wp_model_plugin', 'main_shortcode');