Ticket #12966: 12966.2.diff
| File 12966.2.diff, 3.5 KB (added by , 16 years ago) |
|---|
-
wp-includes/taxonomy.php
75 75 function get_taxonomies( $args = array(), $output = 'names' ) { 76 76 global $wp_taxonomies; 77 77 78 $taxonomies = array(); 79 foreach ( (array) $wp_taxonomies as $taxname => $taxobj ) 80 if ( empty($args) || array_intersect_assoc((array) $taxobj, $args) ) 81 $taxonomies[$taxname] = $taxobj; 78 $field = ('names' == $output) ? 'name' : false; 82 79 83 if ( 'names' == $output ) 84 return array_keys($taxonomies); 85 86 return $taxonomies; 80 return wp_filter_object_list($wp_taxonomies, $args, $field); 87 81 } 88 82 83 89 84 /** 90 85 * Return all of the taxonomy names that are of $object_type. 91 86 * -
wp-includes/post.php
692 692 * @param mixed $the_post Optional. Post object or post ID. 693 693 * @return bool|string post type or false on failure. 694 694 */ 695 function get_post_type( $the_post = false) {695 function get_post_type( $the_post = false ) { 696 696 global $post; 697 697 698 698 if ( false === $the_post ) … … 736 736 * @since 2.9.0 737 737 * @uses $wp_post_types 738 738 * @see register_post_type 739 * @see get_post_types740 739 * 741 740 * @param array|string $args An array of key => value arguments to match against the post types. 742 741 * Only post types having attributes that match all arguments are returned. … … 746 745 function get_post_types( $args = array(), $output = 'names' ) { 747 746 global $wp_post_types; 748 747 749 $do_names = false; 750 if ( 'names' == $output ) 751 $do_names = true; 748 $field = ('names' == $output) ? 'name' : false; 752 749 753 $post_types = array(); 754 foreach ( (array) $wp_post_types as $post_type ) { 755 if ( empty($args) ) { 756 if ( $do_names ) 757 $post_types[] = $post_type->name; 758 else 759 $post_types[] = $post_type; 760 } elseif ( array_intersect_assoc((array) $post_type, $args) ) { 761 if ( $do_names ) 762 $post_types[] = $post_type->name; 763 else 764 $post_types[] = $post_type; 765 } 766 } 767 768 return $post_types; 750 return wp_filter_object_list($wp_post_types, $args, $field); 769 751 } 770 752 771 753 /** -
wp-includes/functions.php
2901 2901 * @param array|string $list 2902 2902 * @return array Sanitized array of IDs 2903 2903 */ 2904 function wp_parse_id_list( $list) {2904 function wp_parse_id_list( $list ) { 2905 2905 if ( !is_array($list) ) 2906 2906 $list = preg_split('/[\s,]+/', $list); 2907 2907 … … 2909 2909 } 2910 2910 2911 2911 /** 2912 * Filters a list of objects, returning only those that match all arguments 2913 * 2914 * @since 3.0.0 2915 * 2916 * @param array $list An array of objects to filter 2917 * @param array $args An array of key => value arguments to match against each object 2918 * @param bool|string $field A field from the object to place instead of the entire object 2919 * @return array A list of objects or object fields 2920 */ 2921 function wp_filter_object_list( $list, $args = array(), $field = false ) { 2922 if ( !is_array($list) ) 2923 return array(); 2924 2925 $count = count($args); 2926 2927 $filtered = array(); 2928 foreach ( $list as $key => $obj ) 2929 if ( count(array_intersect_assoc(get_object_vars($obj), $args)) == $count ) 2930 $filtered[$key] = $field ? $obj->$field : $obj; 2931 2932 return $filtered; 2933 } 2934 2935 /** 2912 2936 * Determines if default embed handlers should be loaded. 2913 2937 * 2914 2938 * Checks to make sure that the embeds library hasn't already been loaded. If