-2

I've tried to fix an error in Wordpress backend for WPML plugin with this suggestion: https://wpml.org/errata/product-variations-not-display-variation-original-language/

It didn't work and now I get this error:

Parse error: syntax error, unexpected '']?)(" ' (T_CONSTANT_ENCAPSED_STRING) in /home/sweetcelebration.nl/public_html/sweetcelebration.nl/wp-includes/functions.php on line 527

I pasted the code in the beginning of functions.php and removed it when it didn't work. I didn't touch this part of the code, so I'm not sure why this now appears.

function wp_extract_urls( $content ) {
    preg_match_all(
        "#(["']?)("
            . "(?:([w-]+:)?//?)"
            . "[^s()<>]+"
            . "[.]"
            . "(?:"
                . "([wd]+)|"
                . "(?:"
                    . "[^`!()[]{};:'".,<>«»“”‘’s]|"
                    . "(?:[:]d+)?/?"
                . ")+"
            . ")"
        . ")1#",
        $content,
        $post_links
    );

    $post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) );
    return array_values( $post_links );
}

Line 527 is

. "[^`!()[]{};:'".,<>«»“”‘’s]|"

I'm sorry if this is stupid question. I did read other similar questions that were asked before, but didn't find my answer. I'm really hoping someone here can help me. Thank you in advance!

2 Answers2

1

You should escape all " characters (being part of the regex itself) with a backslash:

"#(["']?)("

becomes

"#([\"']?)("

And:

. "[^`!()[]{};:'".,<>«»“”‘’s]|"

becomes:

. "[^`!()[]{};:'\".,<>«»“”‘’s]|"

This should solve it:

preg_match_all(
    "#([\"']?)("
        . "(?:([w-]+:)?//?)"
        . "[^s()<>]+"
        . "[.]"
        . "(?:"
            . "([wd]+)|"
            . "(?:"
                . "[^`!()[]{};:'\".,<>«»“”‘’s]|"
                . "(?:[:]d+)?/?"
            . ")+"
        . ")"
    . ")1#",
    $content,
    $post_links
);
Dygnus
  • 621
  • 6
  • 14
0

The interstitial " marks in that line need to be escaped. E.g.:

. "[^`!()[]{};:'\".,<>«»“”‘’s]|"
Phl3tch
  • 155
  • 3
  • 12