<?php
/*
 * Plugin Name: Zelty Eshop
 * Description: Plugin commande en ligne de Zelty
 * Version: 1.0
 * Author: Zelty
 * */
function zelty_eshop($atts, $content = null) {
extract(shortcode_atts(array(
« zkey » =>  »,
« theme » =>  »,
« offset » =>  »
), $atts, ‘zeshop’));
$output = ‘<script id= »zelty-order-iframe »>’.PHP_EOL;
$output .= ‘<!–‘.PHP_EOL;
$output .= ‘(function(){‘.PHP_EOL;
$output .= ‘window._zwg = window._zwg || {} ‘.PHP_EOL;
$output .= ‘window._zwg.key = \ ».$zkey.’\ ».PHP_EOL;
if ($theme) {
$output .= ‘window._zwg.theme = \ ».$theme.’\ ».PHP_EOL;
}
if ($offset) {
$output .= ‘window._zwg.offset = ‘.(int)$offset.PHP_EOL;
}
$output .= ‘var z = document.createElement(\’script\’)’.PHP_EOL;
$output .= ‘z.type = \’text/javascript\ ».PHP_EOL;
$output .= ‘z.src = \’https://order.zelty.fr/loader-iframe.js\ ».PHP_EOL;
$output .= ‘var allScripts = document.getElementsByTagName(\’script\’),’.PHP_EOL;
$output .= ‘s = allScripts[allScripts.length – 1];’.PHP_EOL;
$output .= ‘s.parentNode.insertBefore(z, s)’.PHP_EOL;
$output .= ‘})();’.PHP_EOL;
$output .= ‘–>’.PHP_EOL;
$output .= ‘</script>’;
return $output;
}
add_shortcode(‘zeshop’, ‘zelty_eshop’);