add_rewrite_rule() accepts an array of query variables in WordPress 4.4

In the upcoming WordPress 4.4, add_rewrite_rule() has a small change [34708]. The second plugin of this function can pass an array of query variables instead of the previous query string.

For example, before:

1
add_rewrite_rule (  'foo/([^/]+)/bar/([^/]+)/?$' ,  'index.?post_type=foo&name=$matches[1]&taxonomy=bar&term=$matches[2] '  ) ;

new:

1
2
3
4
5
6
add_rewrite_rule (  'foo/([^/]+)/bar/([^/]+)/?$' ,  array ( 
	'post_type'  =>  'foo' , 
	'name'       =>  '$matches[1]' , 
	'taxonomy'   =>  'bar' , 
	'term'       =>  '$matches[2]' , 
)  ) ;

Although this is not the biggest change, it is easier to read.

(Note: The $matches variable needs to use single quotes)

Source: https://make.wordpress.org/core/2015/10/07/add_rewrite_rule-accepts-an-array-of-query-vars-in-wordpress-4-4/