开发者

preg_replace() unknown modifier (Wordpress Glossary Plugin) [duplicate]

This question already has answers here: Warning: preg_replace(): Unknown modifier (3 answers) Closed 3 years ago.

I installed the "Tooltip Glossary" plugin on a Wordpress site, but after some entries containing HTML tags were entered, it basically stopped working. I have stripped tags out of all the of开发者_如何学JAVAfending glossary entries, but am now getting these error messages on every page:

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'b' in /afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary.php on line 90

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'b' in /afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary.php on line 101

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'd' in /afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary.php on line 90

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'd' in /afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary.php on line 101

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'l' in /afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary.php on line 90

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'l' in /afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary.php on line 101

Can someone help me figure out what's wrong? I've uploaded the php file for the plugin here: http://www.box.net/shared/1nonkcm9yq

Specifically, line 90 is

$content_temp = preg_replace($glossary_search, $glossary_replace, $content);

and line 101 is

$content_temp = preg_replace($link_search, $link_replace, $content_temp);

Thanks so much!


You have a forward slash in your title. It's breaking the regular expression, because / is also the outer delimiter.

You need to add preg_quote() where $glossary_search is constructed (line 83):

$glossary_title = $glossary_item->post_title;
$glossary_title = preg_quote($glossary_title, "/");
$glossary_search = '/\b'.$glossary_title.'s*?\b(?=([^"]*"[^"]*")*[^"]*$)/i';

And also line 94:

$link_search = '/<a'.$timestamp.'>('.preg_quote($glossary_item->post_title, "/").'[A-Za-z]*?)<\/a'.$timestamp.'>/i';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜