preg_replace() 未知修饰符(Wordpress 术语表插件)

发布于 2024-10-15 19:48:37 字数 1667 浏览 4 评论 0原文

我在 WordPress 网站上安装了 "Tooltip Glossary" 插件,但在一些包含 HTML 的条目之后输入标签后,它基本上停止工作。我已经从所有有问题的术语表条目中删除了标签,但现在每个页面上都收到这些错误消息:

警告:preg_replace() [function.preg-replace]:/afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary 中未知修饰符“b” .php 第 90 行

警告:preg_replace() [function.preg-replace]:/afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary 中未知修饰符“b” .php 第 101 行

警告:preg_replace() [function.preg-replace]:/afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary 中未知的修饰符“d” .php 第 90 行

警告:preg_replace() [function.preg-replace]:/afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary 中未知的修饰符“d” .php 第 101 行

警告:preg_replace() [function.preg-replace]:/afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary 中未知修饰符“l” .php 第 90 行

警告:preg_replace() [function.preg-replace]:/afs/ir.stanford.edu/group/hopes/cgi-bin/wordpress/wp-content/plugins/tooltipglossary/glossary 中未知修饰符“l” .php 第 101 行

有人能帮我找出问题所在吗?我已经在这里上传了该插件的 php 文件: http://www.box.net/shared/ 1nonkcm9yq

具体来说,第 90 行是

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

第 101 行是

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

非常感谢!

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 offending 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别理我 2024-10-22 19:48:37

您的标题中有一个正斜杠。它破坏了正则表达式,因为 / 也是外部分隔符。

您需要在构建 $glossary_search 的位置添加 preg_quote() (第 83 行):

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

以及第 94 行:

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

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';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文