imath / wp-statuses

WordPress plugin to ease Custom Post Statuses integration
GNU General Public License v2.0
161 stars 27 forks source link

Compatibility with CPT locked templates #36

Closed leorospo closed 4 years ago

leorospo commented 5 years ago

Locked templates in custom post types will let an advise appear every time you try to add a new post.

The content of your post doesn't match the template assigned to your post type.

How to replicate the issue

Example code

Register a test CPT

<?php
add_action( 'init', function() {
    $args = array(
        'public' => true,
        'label'  => 'News',
        'show_in_rest' => true,
        'template_lock' => 'all',
        'template' => array(
            array( 'core/paragraph', array(
            ) ),
            array( 'core/image', array(
                'align' => 'right',
            ) ),
        ),
    );
    register_post_type( 'news', $args );
} );

Register a custom post status

<?php
function example_register_post_status()
{
    register_post_status('revised', array(
        'label'                     => 'Revised',
        'public'                    => false,
        'exclude_from_search'       => true,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'post_type'                 => array('news'),
        'label_count'               => _n_noop('Revised <span class="count">(%s)</span>', 'Revised<span class="count">(%s)</span>'),
        // Plugin specific attributes
        'show_in_metabox_dropdown'    => true,
        'show_in_inline_dropdown'     => true,
        'show_in_press_this_dropdown' => true,
        'labels'                      => array(
            'metabox_dropdown'  => 'Revised',
            'inline_dropdown'   => 'Revised',
        ),
        'dashicon'              => 'dashicons-yes-alt',
    ));
}
add_action('init', 'example_register_post_status');

The problem

If you try to add a new post in the news CPT the editor will not immediatly display the edit interface, but will instead show an arror message

The content of your post doesn't match the template assigned to your post type.

If you instead try to edit an already existing post it works like it is supposed to.

What have i tried to solve the problem

I really hope this can be fixed, because I greatly prefer this solution to the one offered by th edit flow plugin

I hope i've explained myself without too many errors. For any clarification don't hesitate to ask.

imath commented 5 years ago

Thanks for your feedback. I'll try to find a fix asap.

leorospo commented 4 years ago

hey @imath Have you had time to have a look at the issue?

imath commented 4 years ago

No unfortunately, but thanks a lot for reminding it to me: i hope i'll have a chance to look at it soon.

imath commented 4 years ago

Hi @leorospo

The above PR (#40) should fix the issue. I'll give it more test asap. Don't hesitate to do so too ;)

leorospo commented 4 years ago

I'll give it a shot as soon as I can! Thanks :)