Support Forum » User Profile

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Block Title in initial block state #41847
    hello@logicdesign.co.uk[email protected]
    Participant

    Found a bug as a result of the above where the default data wont save. Another hacky workaround is to edit the compiled JS file in mb-blocks/assets/blocks.js adding the below just after line 160

    $(el.current).find('input').trigger('change');

    (I realise it's not a good idea to edit plugins)

    in reply to: Block Title in initial block state #41846
    hello@logicdesign.co.uk[email protected]
    Participant

    Have a workaround for this, but it's not ideal as to implement you'll need edit the plugin.

    I install the plugin into the theme so it's not an issue, but if it's via the WP Plugins system the edits will get overridden.

    File: mb-blocks/src/Block.php

    Find $attributes = wp_unslash( $attributes ); on line 81 and add the following after that.

    `
    if ( empty($attributes['data']) && ! empty($this->meta_box['defaults']) ) {
    $attributes['data'] = $this->meta_box['defaults'];
    }

    `

    Then on the block config array, you can add a defaults array key containing any default values you want the block to render with. In doing this you bypass the UX issue described.

    in reply to: Editor Color Palette #40225
    hello@logicdesign.co.uk[email protected]
    Participant

    Hi Sam - I normally stick the colours in an array and return these from a php function, so it can go into both add_theme_support('editor-color-palette', theme_colours()); and also the 'palettes' atrribute for the metabox color field.

    Doing it like this is an ok hack, normally id just use the theme_colours() function to populate a select field though as that gives named colours e.g. 'Primary' => 'is-primary-color' and add the value/class to the html element

    in reply to: Render block preview when add the block #32165
    hello@logicdesign.co.uk[email protected]
    Participant

    Quick/dirty work around for this would be to just use the mb_blocks_preview JS callback.

    e.g.

    
        function init__container(e)
        {
            console.log('init container');
            console.log($(e.target));
    
            if ( $(e.target).find('> .components-placeholder').length > 0 ) {
                setTimeout(() => { 
                    $('.mb-block-edit select, .mb-block-edit input').trigger('change')
                }, 1000);
            }
        }
    
        $(document).on('mb_blocks_preview/odin-container', init__container);
    
Viewing 4 posts - 1 through 4 (of 4 total)