Skip to content

Instantly share code, notes, and snippets.

View jbma's full-sized avatar

Jean-Baptiste Marchand-Arvier jbma

View GitHub Profile
@jbma
jbma / gist:5281220
Last active December 15, 2015 15:19
Vider cache redis à la publicaiton
<?php
add_action ('save_post','purge_redis');
function purge_redis (){
include ('predis.php');
$redis = new Predis\Client('');
$domain = $_SERVER['HTTP_HOST'];
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$url = str_replace('?r=y', '', $url);
<?php
//le chemin de l'image a ajouter
$image_path='';
//le temps d'expiration'
$expire= time() - 360000; //valable 1 heure
//je vérifie que l'image existe et qu'elle n'est pas expirée
if (file_exists ($image_path) && filemtime($image_path) > $expire)
{
//si elle existe je ne fais rien
} //fin if
<?php
//le chemin de l'image a ajouter
$image_path='';
//le temps d'expiration'
$expire= time() - 360000; //valable 1 heure
//je vérifie que l'image existe et qu'elle n'est pas expirée
if (file_exists ($image_path) && filemtime($image_path) > $expire)
{
//si elle existe je ne fais rien
} //fin if
function meta_robots(){
if(is_home() && get_query_var('paged') > 1)){
echo '<meta name="robots" content="noindex,follow" />'."\n";
}
}
add_action('wp_head', 'meta_robots');