3 * BouncingOrange SPIP SEO plugin
7 * @author Pierre ROUSSET (p.rousset@gmail.com)
8 * @copyright Copyright (c) 2009 BouncingOrange (http://www.bouncingorange.com)
9 * @license http://opensource.org/licenses/gpl-2.0.php General Public License (GPL 2.0)
12 if (!defined("_ECRIRE_INC_VERSION")) return;
15 * Insertion dans le pipeline affichage_final (SPIP)
16 * Remplacement des métas et title dans le <head>
17 * Remplace les métas et title du squelette et celles insérées via insert_head également
20 * Le contenu de la page
22 * Le contenu de la page modifié
24 function seo_affichage_final($flux){
25 preg_match('/<head>(.*)<\/head>/mis', $flux, $head);
26 $head = isset($head[1]) ?
$head[1] : false;
29 * On n'agit que si on a un head
30 * sinon c'est tout et n'importe quoi
36 include_spip('inc/config');
38 $forcer_squelette = lire_config('seo/forcer_squelette', 'no');
39 if ($forcer_squelette!='yes')
42 include_spip('seo_fonctions');
44 $meta_tags = calculer_meta_tags();
46 foreach ($meta_tags as $key => $value){
47 $meta = generer_meta_tags(array($key => $value));
50 * Si le tag est <title>
53 $flux_meta = preg_replace("/(<\s*$key.*?>.*?<\/\s*$key.*?>)/mi", $meta, $flux, 1);
55 * Le tag est une <meta>
58 $flux_meta = preg_replace("/(<\s*meta\s*name=\"$key\"\s*content=\".*?\".*?>)/mi", $meta, $flux, 1);
61 * Si $flux == $flux_meta
62 * C'est que _SEO_FORCER_SQUELETTE est placé
63 * On ajoute les metas juste avant </head>
65 if ($flux==$flux_meta)
66 $flux_meta = str_replace('</head>', "\n" . $meta . "</head>", $flux);