Delayed Indexing

A pmwiki recipe to delay the indexing of page by search engines, so it can be first reviewed and edited by the community.

This is a very simple recipe to do, I hope I have done it the best way possible.

You have to load this after xlpage-utf-8.php and also after any changes to $WikiDir.

The source:

V3

<?php if(!defined('PmWiki')) exit();

/*  Copyright 2012 Carlos A. Bonamigo ([email protected])
    This file is a recipe for PmWiki; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.  See pmwiki.php for full details.
*/

SDV($DelayedIndexingMetaText, 'noindex')
SDV($DelayedIndexingSquelch, 3*24*60*60); // 3 days
SDVA($DelayedIndexingExclude, array(
   '!Site\\.AllRecentChanges!',
   '!RecentChanges!', 
   '!Main\\.HomePage!'
));

$PostConfig['DelayedIndexing'] = 1;

function DelayedIndexing($pn){
global $DelayedIndexingSquelch,
  $DelayedIndexingMetaText,
  $DelayedIndexingExclude,
  $MetaRobots,$Now;

if($pn == '') exit();
$pn = ResolvePageName($pn);

$ex = $DelayedIndexingExclude;
$sq = $DelayedIndexingSquelch;
$mt = $DelayedIndexingMetaText;
$lm = PageVar($pn,'$LastModifiedTime');

foreach($ex as $r){
  if(preg_match($r,$pn)) return;
}

if(($lm + $sq) >= $Now)
        $MetaRobots = $mt;

}

V2

<?php if(!defined('PmWiki')) exit();

/*  Copyright 2012 Carlos A. Bonamigo ([email protected])
    This file is a recipe for PmWiki; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.  See pmwiki.php for full details.
*/

$pagename = ResolvePageName($pagename);
SDV($DelayIndexSquelch, 3*24*60*60); // 3 days
SDV($DelayIndexExclude, "/(?:
   Site\\.AllRecentChanges|
   RecentChanges|
   Main\\.HomePage
)/");
if(preg_match($DelayIndexExclude,$pagename)) exit();
if((PageVar($pagename,'$LastModifiedTime') +
    $DelayIndexSquelch) >= $Now) $MetaRobots = "noindex";

V1

<?php if(!defined('PmWiki')) exit();

/*  Copyright 2012 Carlos A. Bonamigo ([email protected])
    This file is a recipe for PmWiki; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.  See pmwiki.php for full details.
*/

$pagename = ResolvePageName($pagename);
SDV($DelayIndexSquelch, 2*24*60*60); // 2 days
if((PageVar($pagename,'$LastModifiedTime')+
    $DelayIndexSquelch) >= $Now) $MetaRobots = "noindex";