added better comments to explain functions

This commit is contained in:
asus
2024-02-09 14:31:00 +01:00
parent c41b184221
commit 0c0b406de0
7 changed files with 77 additions and 43 deletions

View File

@@ -1,15 +1,28 @@
<?php
# using ob_start() and ob_get_clean()
# allows to have php expansion inside the html loaded
# in opposition to the methode file_get_contents()
#
# https://stackoverflow.com/a/4402045/9497573
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@param two arguments :
1. html files to include in front
- can be a string of 1 filename
- or an array of strings of filenames
( https://stackoverflow.com/q/4747876/9497573 )
2. list of variables to make available to this files
- in the form of key => val
- recommanded to do it with compact()
ex: create_html( "file.html", compact("var1","var2",) );
ex: create_html( array("file1.html", "file2.html"), array("var1"=>"value") );
@return a string of html code
# takes two arguments :
# a list of the html files to include in front
# a list of variables to make available to this files
using ob_start() and ob_get_clean()
allows to have php expansion inside the html loaded
in opposition to the methode file_get_contents()
https://stackoverflow.com/a/4402045/9497573
*/
function create_html($files, $vars) {
$files = (array)$files;
$html_dir = plugin_dir_path(__DIR__).'html/';
extract($vars);