From 8725644d40c4bbfd68f27998a327dc40122757f6 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 23 Feb 2016 22:50:26 +0000 Subject: [PATCH] Posts: Introduce `get_post_types_by_support()`. Similar to `get_post_types()`, this new function returns a list of post type names that support a specific feature. Props wpsmith, barryceelen, swissspidy. Fixes #34010. Built from https://develop.svn.wordpress.org/trunk@36652 git-svn-id: http://core.svn.wordpress.org/trunk@36619 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 22 ++++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 70a7d73e07..efb7330b52 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1638,6 +1638,28 @@ function post_type_supports( $post_type, $feature ) { return ( isset( $_wp_post_type_features[$post_type][$feature] ) ); } +/** + * Get a list of post type names that support a specific feature. + * + * @since 4.5.0 + * + * @global array $_wp_post_type_features + * + * @param array|string $args Single feature or an array of features the post types should support. + * @param string $operator Optional. The logical operation to perform. 'or' means + * only one element from the array needs to match; 'and' + * means all elements must match; 'not' means no elements may + * match. Default 'and'. + * @return array A list of post type names. + */ +function get_post_types_by_support( $args, $operator = 'and' ) { + global $_wp_post_type_features; + + $features = array_fill_keys( (array) $args, true ); + + return array_keys( wp_filter_object_list( $_wp_post_type_features, $features, $operator ) ); +} + /** * Update the post type for the post ID. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 51d0bf736a..fdaecac3ee 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-36651'; +$wp_version = '4.5-alpha-36652'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.