use compact with add_var_to_front
This commit is contained in:
@@ -31,7 +31,14 @@ function add_files_to_front($files_arr) {
|
||||
}
|
||||
}
|
||||
|
||||
# this function expect an array of key => value
|
||||
# with the key being name of the variable, like this :
|
||||
# 'my_var' => 'value',
|
||||
# simpler way to do it is to use compact when calling the function :
|
||||
# add_var_to_front(compact("var1", "var2", "var3"));
|
||||
function add_var_to_front($var_array) {
|
||||
extract($var_array);
|
||||
|
||||
foreach ($var_array as $key => $var)
|
||||
{
|
||||
$js_var = 'const ' . $key . ' = ';
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<?php
|
||||
|
||||
function template($file) {
|
||||
$template_dir_path = plugin_dir_path(__DIR__).'html/templates/';
|
||||
include($template_dir_path.$file);
|
||||
}
|
||||
|
||||
# using ob_start() and ob_get_clean()
|
||||
# allows to have php expansion inside the html loaded
|
||||
# in opposition to the methode file_get_contents()
|
||||
|
||||
Reference in New Issue
Block a user