use compact with add_var_to_front
This commit is contained in:
@@ -26,18 +26,6 @@ include_once(dirname(__FILE__) . '/utils/create_html.php');
|
||||
|
||||
function main_shortcode() {
|
||||
|
||||
# # send styles files by name, without extension .css
|
||||
# add_css_to_front( array(
|
||||
# "mystyle",
|
||||
# ));
|
||||
#
|
||||
# # send scripts files by name, without extension .js
|
||||
# add_scripts_to_front( array(
|
||||
# "myscript",
|
||||
# "myscript2",
|
||||
# "myscript3",
|
||||
# ));
|
||||
|
||||
add_files_to_front( array(
|
||||
"mystyle.css",
|
||||
"myscript.js",
|
||||
@@ -45,17 +33,14 @@ function main_shortcode() {
|
||||
"myscript3.js",
|
||||
));
|
||||
|
||||
|
||||
$myvar_1 = "I am one";
|
||||
$myvar_2 = "I am two";
|
||||
# maybe a future version of php will allow to
|
||||
# get the name of a variable :
|
||||
# https://wiki.php.net/rfc/nameof
|
||||
# but for now i have to declare both the variable and its name
|
||||
# (more : https://stackoverflow.com/q/255312/9497573)
|
||||
add_var_to_front( array(
|
||||
"myvar_1" => $myvar_1,
|
||||
"myvar_2" => $myvar_2,
|
||||
# compact creates an array containing the variables and their value
|
||||
# as key => value
|
||||
# from an array of variables names as strings
|
||||
add_var_to_front( compact(
|
||||
"myvar_1",
|
||||
"myvar_2",
|
||||
));
|
||||
|
||||
return create_html( array(
|
||||
|
||||
Reference in New Issue
Block a user