You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Utilisations de pipelines par Tarteaucitron
|
|
*
|
|
* @plugin Tarteaucitron
|
|
* @copyright 2019
|
|
* @author Peetdu
|
|
* @licence GNU/GPL
|
|
* @package SPIP\Tarteaucitron\Pipelines
|
|
*/
|
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) {
|
|
return;
|
|
}
|
|
|
|
include_spip('inc/tarteaucitron');
|
|
|
|
/**
|
|
* Inserer tarteaucitron.js + le javascript contenant les paramètres venant de la config du plugin
|
|
*
|
|
* @pipeline insert_head
|
|
* @pipeline recuperer_fond
|
|
*
|
|
* @param string $flux
|
|
* Le contenu de la balise #INSERT_HEAD
|
|
* @return mixed
|
|
*/
|
|
function tarteaucitron_insert_head($flux) {
|
|
|
|
if (tarteaucitron_actif()) {
|
|
$tarteaucitron = find_in_path('lib/tarteaucitron/tarteaucitron.js');
|
|
$tarteaucitron_config = recuperer_fond('javascript/tarteaucitron_config');
|
|
// Note importante : ici on ajoute un id à la déclaration du script pour que celui-ci ne soit pas compressé par le Compresseur de SPIP si ce dernier est activé.
|
|
$flux .= "<script type='text/javascript' src='$tarteaucitron' id='tauc'></script>\n"
|
|
."$tarteaucitron_config\n";
|
|
}
|
|
return $flux;
|
|
}
|
|
|
|
/**
|
|
* Inserer les JS correspondants aux services activés dans la configuration du plugin
|
|
*
|
|
* @pipeline affichage_final
|
|
*
|
|
* @param string $flux
|
|
* @return mixed
|
|
*/
|
|
function tarteaucitron_affichage_final($page) {
|
|
if (!test_espace_prive() and tarteaucitron_actif()) {
|
|
$ajouter_services = '<script type="text/javascript">';
|
|
$ajouter_services .= tarteaucitron_liste_services_actifs();
|
|
$ajouter_services .= '</script>';
|
|
|
|
if ($ajouter_services) {
|
|
$page = str_replace('</body>', $ajouter_services. '</body>', $page);
|
|
}
|
|
}
|
|
return $page;
|
|
} |