Make WordPress Core

Opened 4 weeks ago

#61068 new defect (bug)

Wrong processing post_status for custom post_status

Reported by: unknownmark's profile uNknownMark Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.5
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

I have added a custom post status with the register_post_status function with such args.

<?php
            $args = array(
                'label'                     => _x( 'Processing', 'Status General Name', 'text_domain' ),
                'public'                    => true,
                'show_in_admin_all_list'    => true,
                'show_in_admin_status_list' => true,
                'exclude_from_search'       => false,
                '_builtin'                  => false,
                'internal'                  => false,
                'protected'                 => false,
                'private'                   => false,
                'publicly_queryable'        => true,
            );

            register_post_status( 'cm_processing', $args );


            $args = array(
                'label'                     => _x( 'Completed', 'Status General Name', 'text_domain' ),
                'public'                    => true,
                'show_in_admin_all_list'    => true,
                'show_in_admin_status_list' => true,
                'exclude_from_search'       => false,
                '_builtin'                  => false,
                'internal'                  => false,
                'protected'                 => false,
                'private'                   => false,
                'publicly_queryable'        => true,
            );

            register_post_status( 'cm_completed', $args );

But when I created a new post and set the status "processing" it saved as a draft. Same story if I edit already existing posts.
As far as I see main problem with post status processing happened in function

_wp_translate_postdata

in the file

wp-admin/includes/post.php

Looks like resetting custom post status happened in this piece of code

<?php
        // What to do based on which button they pressed.
        if ( isset( $post_data['saveasdraft'] ) && '' !== $post_data['saveasdraft'] ) {
                $post_data['post_status'] = 'draft';
        }
        if ( isset( $post_data['saveasprivate'] ) && '' !== $post_data['saveasprivate'] ) {
                $post_data['post_status'] = 'private';
        }
        if ( isset( $post_data['publish'] ) && ( '' !== $post_data['publish'] )
                && ( ! isset( $post_data['post_status'] ) || 'private' !== $post_data['post_status'] )
        ) {
                $post_data['post_status'] = 'publish';
        }
        if ( isset( $post_data['advanced'] ) && '' !== $post_data['advanced'] ) {
                $post_data['post_status'] = 'draft';
        }
        if ( isset( $post_data['pending'] ) && '' !== $post_data['pending'] ) {
                $post_data['post_status'] = 'pending';
        }

P.S. Any working workaround while waiting to fix it?

Change History (0)

Note: See TracTickets for help on using tickets.