humanmade / Custom-Meta-Boxes

Lets you easily create metaboxes with custom fields that will blow your mind.
522 stars 124 forks source link

WYSIWYG editor not loading the editor but the raw HTML code #434

Closed q2amarket closed 7 years ago

q2amarket commented 7 years ago

I am trying to add this into my plugin for CPT. Here is my code. I hope it is correct. However, the editor is not loading but outputting raw HTML code as below.

Method

public function add_card_meta_boxes( array $meta_boxes ) {

    $meta_boxes[] = [
        'title'    => 'Add Card Items',
        'pages'    => 'card',
        'context'  => 'normal',
        'priority' => 'high',
        'fields'   => [
            [
                'id'                  => 'item_group',
                'name'                => 'Item Group',
                'type'                => 'group',
                'repeatable'          => TRUE,
                'string-repeat-field' => 'Add Item',
                'tring-delete-field'  => 'Remove Item',
                'fields'              => [
                    [
                        'id'   => 'item_title',
                        'name' => 'item title',
                        'type' => 'text',
                    ],
                    [
                        'id'      => 'example-field-wysiwyg',
                        'name'    => 'A WYSIWYG editor field',
                        'type'    => 'wysiwyg',
                        'options' => [
                            'textarea_rows' => 5
                        ]
                    ]
                ]
            ]
        ],
        'desc'     => 'Add card items for the card.',
    ];

    return $meta_boxes;

}

Output for WYSIWYG

<div id="wp-item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0-wrap" class="wp-core-ui wp-editor-wrap tmce-active"><link rel="stylesheet" id="editor-buttons-css" href="http://apollocorner.co/wp-includes/css/editor.min.css?ver=4.7.5" type="text/css" media="all" /><div id="wp-item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0-editor-tools" class="wp-editor-tools hide-if-no-js"><div id="wp-item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0-media-buttons" class="wp-media-buttons"><button type="button" id="insert-media-button" class="button insert-media add_media" data-editor="item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0"><span class="wp-media-buttons-icon"></span> Add Media</button></div><div class="wp-editor-tabs"><button type="button" id="item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0-tmce" class="wp-switch-editor switch-tmce" data-wp-editor-id="item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0">Visual</button><button type="button" id="item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0-html" class="wp-switch-editor switch-html" data-wp-editor-id="item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0">Text</button></div></div><div id="wp-item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0-editor-container" class="wp-editor-container"><div id="qt_item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0_toolbar" class="quicktags-toolbar"></div><textarea class="wp-editor-area" rows="5" autocomplete="off" cols="40" name="item_group[cmb-group-0][example-field-wysiwyg][cmb-field-0]" id="item_group-cmb-group-0-example-field-wysiwyg-cmb-field-0"></textarea></div></div>

mikeselander commented 7 years ago

@q2amarket Can you tell me which branch of the plugin you're using?

q2amarket commented 7 years ago

Your question is right. I was using older version. I have updated it to CM2 and all is well. Thanks for the great lib.