Regex escape mathes before using them as regex to prevent delimiter problems.
This commit is contained in:
parent
153664d1f1
commit
4d3fbaa9e0
|
@ -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 ] );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue