tag with the CSS class alt
*/
$lnCfg['begin'] = '
Linknotes:
';
$lnCfg['end'] = '
';
$lnCfg['seperate'] = '
';
$lnCfg = (object) $lnCfg;
class linknotes
{
var $hlgn;
var $vlgn;
var $clas;
var $lnge;
var $styl;
var $cspn;
var $rspn;
var $a;
var $s;
var $c;
var $pnct;
function linknotes()
{
$this->hlgn = "(?:\<(?!>)|(?|\<\>|\=|[()]+)";
$this->vlgn = "[\-^~]";
$this->clas = "(?:\([^)]+\))";
$this->lnge = "(?:\[[^]]+\])";
$this->styl = "(?:\{[^}]+\})";
$this->cspn = "(?:\\\\\d+)";
$this->rspn = "(?:\/\d+)";
$this->a = "(?:{$this->hlgn}?{$this->vlgn}?|{$this->vlgn}?{$this->hlgn}?)";
$this->s = "(?:{$this->cspn}?{$this->rspn}?|{$this->rspn}?{$this->cspn}?)";
$this->c = "(?:{$this->clas}?{$this->styl}?{$this->lnge}?|{$this->styl}?{$this->lnge}?{$this->clas}?|{$this->lnge}?{$this->styl}?{$this->clas}?)";
$this->pnct = '[\!"#\$%&\'()\*\+,\-\./:;<=>\?@\[\\\]\^_`{\|}\~]';
}
function linkify($text)
{
$text = preg_replace_callback('/
:([\s[{(]|[[:punct:]])? # $pre
" # start
(' . $this->c . ') # $atts
([^"]+) # $text
\s?
(?:\(([^)]+)\)(?="))? # $title
":
(\S+\b) # $url
(\/)? # $slash
([^\w\/;]*) # $post
(?=\s|$)
/Ux', array(&$this, "linkd"), $text);
if ($this->are_links) {
$linknotes = $this->begin;
for ($i=1; $i <= $this->i; $i++) {
$linknotes .= '
'.$i.' '.$this->links[$i].$this->seperate;
}
$linknotes .= $this->end;
$text = $text.$linknotes;
}
return $text;
}
function linkd($m)
{
$this->are_links = true;
list(, $pre, $atts, $title, $text, $url, $slash, $post) = $m;
if ($text) $text = ' - ' . $text;
$this->i++;
$this->links[$this->i] = $pre . '
' . $title . '' . $text . $post;
return "
id.'-'.$this->i."'\" id=\"noted-$this->id-$this->i\" title=\"$title$text\">[$this->i]";
}
function shelve($val)
{
$this->shelf[] = $val;
return ' <' . count($this->shelf) . '>';
}
}
function linknotes( $string ) {
global $lnCfg,$id;
$ln = new linknotes;
$ln->begin = $lnCfg->begin;
$ln->end = $lnCfg->end;
$ln->seperate = $lnCfg->seperate;
$ln->id = $id;
return $ln->linkify($string); //$string
}
add_filter('the_content', 'linknotes', 5);