Make WordPress Core

Ticket #14077: 14077.6.diff

File 14077.6.diff, 2.1 KB (added by paulwilde, 8 years ago)

Alternative patch which cleans up add_post_type_support() and changes $feature to $features

  • wp-includes/post.php

    diff --git a/wp-includes/post.php b/wp-includes/post.php
    index 3716cba..cbab581 100644
    a b function _add_post_type_submenus() { 
    17291729 * @since 3.0.0
    17301730 *
    17311731 * @param string       $post_type The post type for which to add the feature.
    1732  * @param string|array $feature   The feature being added, accepts an array of
     1732 * @param string|array $features  The feature being added, accepts an array of
    17331733 *                                feature strings or a single string.
    17341734 */
    1735 function add_post_type_support( $post_type, $feature ) {
     1735function add_post_type_support( $post_type, $features ) {
    17361736        global $_wp_post_type_features;
    17371737
    1738         $features = (array) $feature;
    1739         foreach ($features as $feature) {
    1740                 if ( func_num_args() == 2 )
    1741                         $_wp_post_type_features[$post_type][$feature] = true;
    1742                 else
    1743                         $_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
     1738        foreach ( (array) $features as $feature ) {
     1739                if ( func_num_args() == 2 ) {
     1740                        $_wp_post_type_features[ $post_type ][ $feature ] = true;
     1741                } else {
     1742                        $_wp_post_type_features[ $post_type ][ $feature ] = array_slice( func_get_args(), 2 );
     1743                }
    17441744        }
    17451745}
    17461746
    function add_post_type_support( $post_type, $feature ) { 
    17491749 *
    17501750 * @since 3.0.0
    17511751 *
    1752  * @param string $post_type The post type for which to remove the feature.
    1753  * @param string $feature   The feature being removed.
     1752 * @param string       $post_type The post type for which to remove the feature.
     1753 * @param string|array $features  The feature being removed, accepts an array of
     1754 *                                feature strings or a single string.           
    17541755 */
    1755 function remove_post_type_support( $post_type, $feature ) {
     1756function remove_post_type_support( $post_type, $features ) {
    17561757        global $_wp_post_type_features;
    1757 
    1758         if ( isset( $_wp_post_type_features[$post_type][$feature] ) )
    1759                 unset( $_wp_post_type_features[$post_type][$feature] );
     1758       
     1759        foreach ( (array) $features as $feature ) {
     1760                if ( isset( $_wp_post_type_features[ $post_type ][ $feature ] ) ) {
     1761                        unset( $_wp_post_type_features[ $post_type ][ $feature ] );
     1762                }
     1763        }
    17601764}
    17611765
    17621766/**