Custom Fields
Re-Envisioned
Support General wyswig editor cutom field in text mode on gutenberg page

  • Creator
    Topic
  • #28733
    Aaron Kessler
    Participant

    I noticed some bug reports on the WYSIWYG editor, so I am not 100% sure if this already has been reported.

    I can't edit WYSIWYG content in text mode:
    Error GIF

    I created the following custom field via the visual editor:

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '_akdev_';
    
        $meta_boxes[] = [
            'title'      => __( 'Page Banner', 'your-text-domain' ),
            'id'         => 'page-banner',
            'post_types' => ['page'],
            'include'    => [
                'relation' => 'OR',
                'template' => ['template_page-banner.php'],
            ],
            'validation' => [
                'rules' => [
                    $prefix . '_akdev_cta_text' => [
                        'required' => true,
                    ],
                    $prefix . '_akdev_cta_url'  => [
                        'url' => true,
                    ],
                ],
            ],
            'tabs'       => [
                '_akdev_text_tab' => [
                    'label' => 'Text',
                    'icon'  => 'text',
                ],
                '_akdev_cta_tab'  => [
                    'label' => 'Call to action',
                    'icon'  => 'admin-links',
                ],
            ],
            'fields'     => [
                [
                    'id'   => $prefix . 'banner_text',
                    'type' => 'wysiwyg',
                    'tab'  => '_akdev_text_tab',
                ],
                [
                    'id'     => $prefix . 'banner_cta',
                    'type'   => 'group',
                    'fields' => [
                        [
                            'name'        => __( 'Text', 'your-text-domain' ),
                            'id'          => $prefix . 'cta_text',
                            'type'        => 'text',
                            'placeholder' => __( 'Call to action', 'your-text-domain' ),
                            'required'    => true,
                        ],
                        [
                            'name'        => __( 'Link', 'your-text-domain' ),
                            'id'          => $prefix . 'cta_url',
                            'type'        => 'url',
                            'placeholder' => __( 'https://example.com', 'your-text-domain' ),
                            'required'    => true,
                        ],
                    ],
                    'tab'    => '_akdev_cta_tab',
                ],
            ],
        ];
    
        return $meta_boxes;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.