mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
Introduce the wp_filter_object_list() helper, with an $operator arg. Fixes an intersection bug in get_post_types() and get_taxonomies(). Also switches $operator default from 'or' to 'and' for get_post_stati(). props scribu, fixes #12966.
git-svn-id: https://develop.svn.wordpress.org/trunk@14108 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -67,25 +67,21 @@ add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
|
||||
* @uses $wp_taxonomies
|
||||
* @see register_taxonomy
|
||||
*
|
||||
* @param array $args An array of key => value arguments to match against the taxonomies.
|
||||
* Only taxonomies having attributes that match all arguments are returned.
|
||||
* @param array $args An array of key => value arguments to match against the taxonomy objects.
|
||||
* @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
|
||||
* @param string $operator The logical operation to perform. 'or' means only one element
|
||||
* from the array needs to match; 'and' means all elements must match. The default is 'and'.
|
||||
* @return array A list of taxonomy names or objects
|
||||
*/
|
||||
function get_taxonomies( $args = array(), $output = 'names' ) {
|
||||
function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) {
|
||||
global $wp_taxonomies;
|
||||
|
||||
$taxonomies = array();
|
||||
foreach ( (array) $wp_taxonomies as $taxname => $taxobj )
|
||||
if ( empty($args) || array_intersect_assoc((array) $taxobj, $args) )
|
||||
$taxonomies[$taxname] = $taxobj;
|
||||
$field = ('names' == $output) ? 'name' : false;
|
||||
|
||||
if ( 'names' == $output )
|
||||
return array_keys($taxonomies);
|
||||
|
||||
return $taxonomies;
|
||||
return wp_filter_object_list($wp_taxonomies, $args, $operator, $field);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return all of the taxonomy names that are of $object_type.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user