preg_replace() unknown modifier (WordPress Glossary Plugin)

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

Read More

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!

Related posts

Leave a Reply

1 comment

  1. 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';