Regex escape mathes before using them as regex to prevent delimiter problems.

This commit is contained in:
Barry Kooij 2014-10-21 15:20:19 +02:00
parent 153664d1f1
commit 4d3fbaa9e0
1 changed files with 3 additions and 2 deletions

View File

@ -530,9 +530,10 @@ function wc_fix_rewrite_rules( $rules ) {
$product_permalink = empty( $permalinks['product_base'] ) ? _x( 'product', 'slug', 'woocommerce' ) : $permalinks['product_base'];
// Fix the rewrite rules when the product permalink have %product_cat% flag
if ( preg_match( '`/(?:.+)(/%product_cat%)`' , $product_permalink, $matches ) ) {
if ( preg_match( '`/(.+)(/%product_cat%)`' , $product_permalink, $matches ) ) {
foreach ( $rules as $rule => $rewrite ) {
if ( preg_match( '/^' . $matches[0] . '\/\(/', $rule ) && preg_match( '/^(index\.php\?product_cat)(?!(.*product))/', $rewrite ) ) {
if ( preg_match( '`^' . preg_quote( $matches[1], '`' ) . '/\(`', $rule ) && preg_match( '/^(index\.php\?product_cat)(?!(.*product))/', $rewrite ) ) {
unset( $rules[ $rule ] );
}
}