diff --git a/plugins/wp_model_plugin/html/index.html b/plugins/wp_model_plugin/html/index.html index 0767c80..529c290 100644 --- a/plugins/wp_model_plugin/html/index.html +++ b/plugins/wp_model_plugin/html/index.html @@ -1,7 +1,8 @@ -

i am a new p

-

to change

- +
+

i am a new p

+

to change

+ diff --git a/plugins/wp_model_plugin/html/index2.html b/plugins/wp_model_plugin/html/index2.html index 094ffdc..4ad6346 100644 --- a/plugins/wp_model_plugin/html/index2.html +++ b/plugins/wp_model_plugin/html/index2.html @@ -1,9 +1,10 @@ - -

age

- -

to change

-

aaaaaand this is the end

+ +

age

+ +

to change

+

aaaaaand this is the end

+
diff --git a/plugins/wp_model_plugin/plugin_hooks.php b/plugins/wp_model_plugin/plugin_hooks.php index ad7664c..ec8a6d6 100644 --- a/plugins/wp_model_plugin/plugin_hooks.php +++ b/plugins/wp_model_plugin/plugin_hooks.php @@ -8,19 +8,22 @@ Version: 1.1.0 Author URI: */ -/* * * * * * * * * * * * * * * * * * * * * * * * - * globale variable to desable server side - * console_log all at once - */ + +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +globale variable to desable server side +console_log all at once +*/ $CONSOLE_OFF = true; $CONSOLE_OFF = false; -/* * * * * * * * * * * * * * * * * * * * * * * * - * inclusions - */ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +inclusions +*/ include_once(dirname(__FILE__) . '/utils/console_log.php'); include_once(dirname(__FILE__) . '/utils/add_to_front.php'); @@ -29,9 +32,10 @@ include_once(dirname(__FILE__) . '/utils/create_html.php'); -/* * * * * * * * * * * * * * * * * * * * * * * * - * plugin shortcode - */ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +plugin shortcode +*/ function main_shortcode() { @@ -71,9 +75,10 @@ function main_shortcode() { add_shortcode('wp_model_plugin', 'main_shortcode'); -/* * * * * * * * * * * * * * * * * * * * * * * * - * menu plugin - */ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +menu plugin +*/ function plugin_menu() { add_menu_page( diff --git a/plugins/wp_model_plugin/styles/mystyle.css b/plugins/wp_model_plugin/styles/mystyle.css index 76d5017..bf327c8 100644 --- a/plugins/wp_model_plugin/styles/mystyle.css +++ b/plugins/wp_model_plugin/styles/mystyle.css @@ -1,3 +1,7 @@ .first_el_to_change { border: 1px solid red; } +#model_plugin_shortcode { + border: 1px solid blue; + padding: 10px; +} diff --git a/plugins/wp_model_plugin/utils/add_to_front.php b/plugins/wp_model_plugin/utils/add_to_front.php index 9f9c34b..46a21e2 100644 --- a/plugins/wp_model_plugin/utils/add_to_front.php +++ b/plugins/wp_model_plugin/utils/add_to_front.php @@ -1,5 +1,9 @@ , /url/to/file, [depends on], version, defer? ); //wp_enqueue_style( , /url/to/file, [depends on], version, media ); @@ -31,11 +35,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")); +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +@param 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); diff --git a/plugins/wp_model_plugin/utils/console_log.php b/plugins/wp_model_plugin/utils/console_log.php index 9b98328..0417430 100644 --- a/plugins/wp_model_plugin/utils/console_log.php +++ b/plugins/wp_model_plugin/utils/console_log.php @@ -1,6 +1,9 @@ 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);