Preg_match(): missing closing parenthesis

Viewed 315

A plugin is generating the following error:

Got error 'PHP message: PHP Warning: preg_match(): Compilation failed: missing closing parenthesis at offset 946 - DeferJS.php on line 78

The line of code that generates the error:

if ( preg_match( '#(' . $exclude_defer_js . ')#i', $tag['url'] ) ) {

Thanks for any help

1 Answers

$exclude_defer_js must contain special characters.

Use preg_quote:

if ( preg_match( '#' . preg_quote($exclude_defer_js, '#') . '#i', $tag['url'] ) ) { 
Related