Delete a column in edit.php generated with a plugin

Question

I would like to delete a column from the list of my posts in the backoffice.
I found out how to remove the categories and tags column.
I would like to remove the "Status" and "Permissions" column which was added by the PublishPress plugin

While searching for the status, I saw the class PP_Custom_Status with this

public function init()
        {
            global $publishpress;

            // Register custom statuses as a taxonomy
            $this->register_custom_statuses();

            // Register our settings
           ....
           ....

            add_filter('manage_posts_columns', [$this, '_filter_manage_posts_columns']);  
          ....
        }

and this

        public function _filter_manage_posts_columns($posts_columns)
        {
            // Return immediately if the supplied parameter isn't an array (which shouldn't happen in practice?)
            // http://wordpress.org/support/topic/plugin-publishpress-bug-shows-2-drafts-when-there-are-none-leads-to-error-messages
            if (!is_array($posts_columns)) {
                return $posts_columns;
            }

            // Only do it for the post types this module is activated for
            if (!in_array($this->get_current_post_type(), $this->get_post_types_for_module($this->module))) {
                return $posts_columns;
            }

            $result = [];
            foreach ($posts_columns as $key => $value) {
                if ($key == 'title') {
                    $result[$key]     = $value;
                    $result['status'] = __('Status', 'publishpress');
                } else {
                    $result[$key] = $value;
                }
            }

            return $result;
        }

so I tried to do this

add_filter('manage_posts_columns', 'manage_columns_head_for_post');
function manage_columns_head_for_post($defaultsColumn){
        unset($defaultsColumn['status']);
    return $defaultsColumn;
}

but of course it doesn’t work (column status doesn’t exist in $defaultsColumn

Do you know how to remove this column please ?

0
user7734861 2 months 0 Answers 11 views 0

Leave an answer