MB Blocks 1.8.0 stops enqueueing assets on frontend

Support MB Blocks MB Blocks 1.8.0 stops enqueueing assets on frontendResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #49846
    Johannes GrossJohannes Gross
    Participant

    Hello,

    After the recent MB Block 1.8.0 update, the CSS file enqueued through enqueue_assets is not anymore loaded on the frontend. Downgrading back to MB Block 1.7.6 fixes it. Can you take a look? Here is my markup:

    $meta_boxes[] = array(
    		'id'              => 'twt-modules',
    		'title'           => 'TWT Modules',
    		'type'            => 'block',
    		'icon'            => 'editor-table',
    		'category'        => 'layout',
    		'context'         => 'normal',
    		'render_template' => get_stylesheet_directory() . '/blocks/twt-modules.php',
    		'enqueue_assets' => function() {
    			wp_enqueue_style('twt-modules', get_stylesheet_directory_uri().'/blocks/twt-modules.css', array(), filemtime(get_stylesheet_directory()."/blocks/twt-modules.css"));
    		},
    		'supports'        => array(
    			'anchor'          => true,
    			'customClassName' => true
    		),
    		'fields'          => array(
    			array(
    				'name'          => '',
    				'id'            => 'modules',
    				'type'          => 'group',
    				'clone'         => true,
    				'sort_clone'    => true,
    				'collapsible'   => true,
    				'default_state' => 'collapsed',
    				'group_title'   => '{label}',
    				'fields'        => array(
    					array(
    						'name' => 'Label',
    						'id'   => 'label',
    						'type' => 'text',
    					),
    					array(
    						'name' => 'URL',
    						'id'   => 'url',
    						'type' => 'text',
    					),
    					array(
    						'name' => 'Image',
    						'id'   => 'img',
    						'type' => 'single_image',
    					)
    				)
    			)
    		)
    	);
    #49852
    PeterPeter
    Moderator

    Hello Johannes,

    Thank you for reaching out.

    I notice that we can register the style file with relative path like this

    'enqueue_style' => '/wp-content/themes/metabox-theme/blocks/hero-content/hero-style.css',

    instead of the absolute path

    'enqueue_style' => get_stylesheet_directory() . '/blocks/hero-content/hero-style.css',

    can you please recheck this on your site?

    #49854
    Johannes GrossJohannes Gross
    Participant

    Good idea! Unfortunately, switching it to the relative static path did not fix it for me either. I tried it both through 'enqueue_style' and 'enqueue_assets'.

    #49926
    Johannes GrossJohannes Gross
    Participant

    After updating to 1.8.2, scripts and styles are now loading on all pages - regardless if the custom block is used or not. Before, it was only loading them if the block was used. Can you please look into this?

    #49928
    PeterPeter
    Moderator

    Hello Johannes,

    Can you please use the setting enqueue_style setting instead of the setting enqueue_block_assets and recheck the issue?

    #49932
    Johannes GrossJohannes Gross
    Participant

    That fixed it. Thank you!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.