Make WordPress Core

Ticket #34010: 34010.with-operator.diff

File 34010.with-operator.diff, 1.1 KB (added by barryceelen, 8 years ago)

Include and/or operator

  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index 59506f8..2b814b8 100644
    function post_type_supports( $post_type, $feature ) { 
    15521552}
    15531553
    15541554/**
     1555 * Get a list of post type names that support a specific feature.
     1556 *
     1557 * @since 4.5.0
     1558 *
     1559 * @global array $_wp_post_type_features
     1560 *
     1561 * @param array|string $args     Single feature or an array of features the post types should support.
     1562 * @param string       $operator Optional. The logical operation to perform. 'or' means only one
     1563 *                               element from the array needs to match; 'and' means all elements
     1564 *                               must match. Accepts 'or' or 'and'. Default 'and'.
     1565 * @return array A list of post type names.
     1566 */
     1567function get_post_types_by_support( $args, $operator = 'and' ) {
     1568                global $_wp_post_type_features;
     1569
     1570                $features = array_fill_keys( (array) $args, true );
     1571
     1572                return array_keys( wp_filter_object_list( $_wp_post_type_features, $features, $operator ) );
     1573}
     1574
     1575/**
    15551576 * Update the post type for the post ID.
    15561577 *
    15571578 * The page or post cache will be cleaned for the post ID.