Im search information about it ago several hours but I cannot find a solve.
I have a plugin with a global functions called "get_regions()":
$all_regions = get_regions();
// array('region-1', 'region-2', 'region-3', 'region-4')
Then I need put those values in a select in my block Gutenberg. I have this code in my edit function and it works!
edit: function(props) {
return el(Fragment, {},
el(InspectorControls, {},
el(PanelBody, { title: __( 'Target Countries Settings') },
el(PanelRow, { className: 'components-base-control'},
el(SelectControl, {
label: __('Include Regions'),
multiple : 'true',
options : [
{ label: __( 'region-1' ), value: 'region-1' },
{ label: __( 'region-2' ), value: 'region-2' }
]
},
),
),
),
)
);
}
But it has static values, I need the options in "SelectControl" has those values from the function get_regions()
.
How can I get this values from side server?
Ok I had use the plan B.
I used wp_localize_script()
to send this values.
Regards