added better comments to explain functions
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
<p>i am a new p</p>
|
<div id="model_plugin_shortcode">
|
||||||
<p class="first_el_to_change">to change</p>
|
<p>i am a new p</p>
|
||||||
<?php
|
<p class="first_el_to_change">to change</p>
|
||||||
|
<?php
|
||||||
foreach($names as $name) {
|
foreach($names as $name) {
|
||||||
include($html_dir."templates/presentation.html");
|
include($html_dir."templates/presentation.html");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
foreach($ages as $age) {
|
foreach($ages as $age) {
|
||||||
?>
|
?>
|
||||||
<p>age <?php echo esc_html($age); ?></p>
|
<p>age <?php echo esc_html($age); ?></p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<p class="third_el_to_change">to change</p>
|
<p class="third_el_to_change">to change</p>
|
||||||
<p>aaaaaand this is the end</p>
|
<p>aaaaaand this is the end</p>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -8,19 +8,22 @@ Version: 1.1.0
|
|||||||
Author URI:
|
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 = true;
|
||||||
$CONSOLE_OFF = false;
|
$CONSOLE_OFF = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * *
|
/*
|
||||||
* inclusions
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*/
|
inclusions
|
||||||
|
*/
|
||||||
|
|
||||||
include_once(dirname(__FILE__) . '/utils/console_log.php');
|
include_once(dirname(__FILE__) . '/utils/console_log.php');
|
||||||
include_once(dirname(__FILE__) . '/utils/add_to_front.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() {
|
function main_shortcode() {
|
||||||
|
|
||||||
@@ -71,9 +75,10 @@ function main_shortcode() {
|
|||||||
add_shortcode('wp_model_plugin', 'main_shortcode');
|
add_shortcode('wp_model_plugin', 'main_shortcode');
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * *
|
/*
|
||||||
* menu plugin
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*/
|
menu plugin
|
||||||
|
*/
|
||||||
|
|
||||||
function plugin_menu() {
|
function plugin_menu() {
|
||||||
add_menu_page(
|
add_menu_page(
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
.first_el_to_change {
|
.first_el_to_change {
|
||||||
border: 1px solid red;
|
border: 1px solid red;
|
||||||
}
|
}
|
||||||
|
#model_plugin_shortcode {
|
||||||
|
border: 1px solid blue;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
@param an array of files
|
||||||
|
*/
|
||||||
function add_files_to_front($files_arr) {
|
function add_files_to_front($files_arr) {
|
||||||
//wp_enqueue_script(<give_it_a_name>, /url/to/file, [depends on], version, defer? );
|
//wp_enqueue_script(<give_it_a_name>, /url/to/file, [depends on], version, defer? );
|
||||||
//wp_enqueue_style( <give_it_a_name>, /url/to/file, [depends on], version, media );
|
//wp_enqueue_style( <give_it_a_name>, /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',
|
@param expect an array of key => value
|
||||||
# simpler way to do it is to use compact when calling the function :
|
with the key being name of the variable, like this :
|
||||||
# add_var_to_front(compact("var1", "var2", "var3"));
|
'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) {
|
function add_var_to_front($var_array) {
|
||||||
extract($var_array);
|
extract($var_array);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
// https://stackify.com/how-to-log-to-console-in-php/
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
https://stackify.com/how-to-log-to-console-in-php/
|
||||||
|
*/
|
||||||
function console_log($output) {
|
function console_log($output) {
|
||||||
global $CONSOLE_OFF;
|
global $CONSOLE_OFF;
|
||||||
if ($CONSOLE_OFF)
|
if ($CONSOLE_OFF)
|
||||||
|
|||||||
@@ -1,15 +1,28 @@
|
|||||||
<?php
|
<?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()
|
@param two arguments :
|
||||||
#
|
1. html files to include in front
|
||||||
# https://stackoverflow.com/a/4402045/9497573
|
- 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 :
|
using ob_start() and ob_get_clean()
|
||||||
# a list of the html files to include in front
|
allows to have php expansion inside the html loaded
|
||||||
# a list of variables to make available to this files
|
in opposition to the methode file_get_contents()
|
||||||
|
|
||||||
|
https://stackoverflow.com/a/4402045/9497573
|
||||||
|
*/
|
||||||
function create_html($files, $vars) {
|
function create_html($files, $vars) {
|
||||||
|
$files = (array)$files;
|
||||||
|
|
||||||
$html_dir = plugin_dir_path(__DIR__).'html/';
|
$html_dir = plugin_dir_path(__DIR__).'html/';
|
||||||
extract($vars);
|
extract($vars);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user