[Plugin: Glossary] Prevent breaking of links
-
I am not using this code as a wordpress plugin, but adapted the function for my needs elsewhere. One problem I found though is that it will break links, images etc if the glossary words exist these tags. A way around this is to use the following clipboard class at the start of the function and then modify the return to: return $c->paste($content);
Maybe someone else has a better solution?
class Clipboard
{
var $_buf = array();function _tr($n) {
static $dc = “0123456789”;
static $sc = “\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19”;
return intval($n) ? strtr($n, $dc, $sc) :
intval(strtr($n, $sc, $dc));
}
//
function cut($subject, $regexp = null) {
if(is_array($subject)) {
$this->_buf[] = $subject[0];
return “\x01” . $this->_tr(count($this->_buf)) . “\x01”;
}
return preg_replace_callback($regexp,
array(&$this, ‘cut’), $subject);
}
function paste($subject) {
if(is_array($subject))
return $this->_buf[$this->_tr($subject[1]) – 1];
return preg_replace_callback(“~\x01([\x10-\x19]+)\x01~”,
array($this, ‘paste’), $subject);
}
}$html_tag = <<<REGEXP
~
</?\w+
(
“[^”]*” |
‘[^’]*’ |
[^”‘>]+
)*
>
~sx
REGEXP;/////
$c = &new Clipboard;
$content = $c->cut($content, $html_tag);https://www.ads-software.com/extend/plugins/automatic-glossary/
- The topic ‘[Plugin: Glossary] Prevent breaking of links’ is closed to new replies.