ThemeFuse / Unyson

A WordPress framework that facilitates the development of WP themes
http://unyson.io
922 stars 218 forks source link

Addable Box does not work in CPT with activated Guttenberg editor. #3992

Open goran468 opened 4 years ago

goran468 commented 4 years ago

Hello.

In case if Custom Post Type uses Guttenberg editor the addable boxes do not work. It allows to create items in boxes and save them, but after refreshing the page it is impossible to edit items or remove them (but still possible to add new). The JavaScript console gives this error on expand/remove click: uncaught exception: Object

We have tested it in several themes, including TwentyTwenty and It does not depends on theme or plugins. Here is detailed environment:

WordPress 5.4.1
Unyson 2.7.23 
TwentyTwenty Theme
Plugins installed: Unyson only

Example of options for CPT:

$options = array(
    'items' => array(
        'label' => esc_html__( 'List', 'lte' ),
        'type' => 'addable-box',
        'value' => array(),
        'box-options' => array(
            'header' => array(
                'label' => esc_html__( 'Header', 'lte' ),
                'type' => 'text',
            ),              
        ),
        'template' => '{{- header }}',
    ),                  
);

CPT registration:

$args = array(
    'labels'             => $labels,
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'show_in_rest'       => true,
    'menu_icon'          => 'dashicons-hammer', 
    'query_var'          => true,
    'rewrite'            => array( 'slug' => 'services' ),
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false,
    'menu_position'      => null,
    'supports'           => array( 'title', 'editor', 'thumbnail')
);

register_post_type( 'services', $args );

The Guttenberg editor must be enabled for post in order to repeat the issue. In case if Elementor/WPBakery/Classic Editor are used all works correctly. If show_in_rest set to false: 'show_in_rest' => false,

Addable boxes also work correctly. So the conflict seems to be caused by the Guttenberg only.

Thank you.

iamjoshade commented 4 years ago

is it possible to send a screenshot

goran468 commented 4 years ago

image

Here is a screenshot from our theme on local server, the same situation in clean TwentyTwenty. It also does not depend on data entered in Guttenberg or Boxes. If it is impossible to repeat, we can create custom theme based on WordPress default.

After commenting show_in_rest the boxes work correctly. // 'show_in_rest' => true,

Thank you.