WordPress开发者和主题制作者的搜索引擎



get_taxonomies_for_attachments ›

Since3.5.0
已弃用n/a
get_taxonomies_for_attachments ( $output = 'names' )
参数:
  • (string) $output Optional. The type of taxonomy output to return. Accepts 'names' or 'objects'. Default 'names'.
    Required: No
    默认: 'names'
查看:
返回:
  • (string[]|WP_Taxonomy[]) Array of names or objects of registered taxonomies for attachments.
定义在:
文档:

Retrieves all of the taxonomies that are registered for attachments.

Handles mime-type-specific taxonomies such as attachment:image and attachment:video.



源码

function get_taxonomies_for_attachments( $output = 'names' ) {
	$taxonomies = array();

	foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) {
		foreach ( $taxonomy->object_type as $object_type ) {
			if ( 'attachment' === $object_type || 0 === strpos( $object_type, 'attachment:' ) ) {
				if ( 'names' === $output ) {
					$taxonomies[] = $taxonomy->name;
				} else {
					$taxonomies[ $taxonomy->name ] = $taxonomy;
				}
				break;
			}
		}
	}

	return $taxonomies;
}