我几个小时前就在搜索关于它的信息,但我找不到解决办法。
我有一个具有名为“get_regions()”的全局函数的插件:
$all_regions = get_regions();
// array('region-1', 'region-2', 'region-3', 'region-4')然后,我需要将这些值放在我的区块Gutenberg中的select中。我在我的编辑函数中有这段代码,它可以工作!
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' }
]
},
),
),
),
)
);
}但是它有静态值,我需要"SelectControl“中的选项有来自函数get_regions()的那些值。
如何从侧服务器获取这些值?
发布于 2018-12-07 15:31:33
好的,我用了B计划。
我使用wp_localize_script()发送这个值。
问候
https://stackoverflow.com/questions/53663047
复制相似问题