public function addRemovePostTypeSupport($props)
    {
        // Check props
        if (empty($props)) {
            return;
        }

        add_action('init', function () use ($props) {
            // Set available supports
            $available = ['title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'post-formats'];

            // Iterate on all
            foreach ($props as $posttype => $args) {
                if (!post_type_exists($posttype) || empty($args)) {
                    continue;
                }

                // Iterate on actions
                foreach ($args as $action => $supports) {
                    if (!in_array($action, ['add', 'remove']) || empty($supports)) {
                        continue;
                    }

                    // Extract only available supports
                    $supports = !is_array($supports) ? [$supports] : $supports;
                    $supps = array_intersect($supports, $available);

                    // Action on supports
                    if ('add' === $action) {
                        // Add supports
                        add_post_type_support($posttype, $supps);
                    } else {
                        // Remove supports one by one
                        foreach ($supps as $s) {
                            remove_post_type_support($posttype, $s);
                        }
                    }
                }
            }
        });
    }
public function addRemovePostTypeSupport($props)
    {
        // Check props
        if (empty($props)) {
            return;
        }

        add_action('init', function () use ($props) {
            // Set available supports
            $available = ['title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'post-formats'];

            // Iterate on all
            foreach ($props as $posttype => $args) {
                if (!post_type_exists($posttype) || empty($args)) {
                    continue;
                }

                // Iterate on actions
                foreach ($args as $action => $supports) {
                    if (!in_array($action, ['add', 'remove']) || empty($supports)) {
                        continue;
                    }

                    // Extract only available supports
                    $supports = !is_array($supports) ? [$supports] : $supports;
                    $supps = array_intersect($supports, $available);

                    // Action on supports
                    if ('add' === $action) {
                        // Add supports
                        add_post_type_support($posttype, $supps);
                    } else {
                        // Remove supports one by one
                        foreach ($supps as $s) {
                            remove_post_type_support($posttype, $s);
                        }
                    }
                }
            }
        });
    }
public function addRemovePostTypeSupport ( $ props ) { // Check props if ( empty ( $ props ) ) { return ; } add_action ( 'init' , function ( ) use ( $ props ) { // Set available supports $ available = [ 'title' , 'editor' , 'author' , 'thumbnail' , 'excerpt' , 'trackbacks' , 'custom-fields' , 'comments' , 'revisions' , 'page-attributes' , 'post-formats' ] ; // Iterate on all foreach ( $ props as $ posttype => $ args ) { if ( ! post_type_exists ( $ posttype ) || empty ( $ args ) ) { continue ; } // Iterate on actions foreach ( $ args as $ action => $ supports ) { if ( ! in_array ( $ action , [ 'add' , 'remove' ] ) || empty ( $ supports ) ) { continue ; } // Extract only available supports $ supports = ! is_array ( $ supports ) ? [ $ supports ] : $ supports ; $ supps = array_intersect ( $ supports , $ available ) ; // Action on supports if ( 'add' === $ action ) { // Add supports add_post_type_support ( $ posttype , $ supps ) ; } else { // Remove supports one by one foreach ( $ supps as $ s ) { remove_post_type_support ( $ posttype , $ s ) ; } } } } } ) ; }
Add or Remove post type supports to WP.

@param array $props
Add or Remove post type supports to WP .