WordPress.org

Make WordPress Core

Ticket #34010: 34010a.post.php.patch

File 34010a.post.php.patch, 1.1 KB (added by wpsmith, 6 years ago)

get_post_types_by_support()

  • wp-includes/post.php

     
    11981198}
    11991199
    12001200/**
     1201 * Get a list of post type names that support a specific feature.
     1202 *
     1203 * @since 4.4.0
     1204 *
     1205 * @global array $_wp_post_type_features Associative array of post types with accepted features.
     1206 *
     1207 * @param string|array $feature String of a single post type support feature or array
     1208 *                              (e.g., `'title'` or `array( 'title' => true )`).
     1209 *
     1210 * @return array $post_types Array of post type names that support a feature.
     1211 */
     1212function get_post_types_by_support( $feature ) {
     1213        global $_wp_post_type_features;
     1214        $features   = ! is_array( $feature ) ? array( $feature => true ) : $feature;
     1215        $post_types = array_keys(
     1216                wp_filter_object_list( $_wp_post_type_features, $features )
     1217        );
     1218        return $post_types;
     1219}
     1220
     1221/**
    12011222 * Register a post type. Do not use before init.
    12021223 *
    12031224 * A function for creating or modifying a post type based on the