Closed Seriousness closed 1 year ago
Now, I'm using the render method of block.json
Maybe you can use the render_block filter https://developer.wordpress.org/reference/hooks/render_block/
First of all: Thank you!
I'll give it another go as soon as the plugin is updated from my other issue.
my try on this:
echo render_block(array(
'blockName' => 'map-block-leaflet/map-block-leaflet',
'attrs' => $mapmeta['attributes']
));
my $mapmeta looks like this, the $map vars are from the metabox customfield:
'attributes' => [
'lat' => [
'type' => 'number',
'default' => $map['latitude']
],
'lng' => [
'type' => 'number',
'default' => $map['longitude']
],
'themeUrl' => [
'type' => 'string',
'default' => 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png'
],
'themeAttribution' => [
'type' => 'string',
'default' => '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> © <a href="https://carto.com/attributions">CARTO</a>'
],
'height' => [
'type' => 'number',
'default' => 220
],
'disableScrollZoom'=> [
'type' => 'boolean',
'default' => true
],
'zoom' => [
'type' => 'number',
'default' => $map['zoom']
],
'themeId' => [
'type' => 'number',
'default' => 1
],
'content' => [
'type' => 'string',
'default' => ''
]
] );
I have done some testing and it seems that the render_block_data filter can help you for this
function update_map_block_leaflet_attrs($block) {
if ( $block['blockName'] === 'map-block-leaflet/map-block-leaflet' ) {
$block['attrs']['lat'] = 40.416775;
$block['attrs']['lng'] = -3.703790;
}
return $block;
}
add_filter( 'render_block_data', 'update_map_block_leaflet_attrs' );
I hope to help you
It seems that "map_block_leaflet_render()" is removed, is there a replacement? I have used it to fill in a custom map by code from custom meta.
Thanks for all the work.