您好目前我在我的 wordpress 主题中使用简单天气 JS(http://simpleweatherjs.com/)来显示实时天气以及我使用 redux 框架的选项。我为“您的城市名称”创建了一个文本字段,我的选项唯一 ID 是 >“cpv-hm-cat-op-8”。我的 Redux 框架选项的预览如下。
array(
'id' => 'cpv-hm-cat-op-8',
'type' => 'text',
'title' => __( 'Name of your city', 'redux' ),
'desc' => __( 'Write your city which you want to show in weather', 'redux' ),
'default' => 'New York',
),
现在我想在我的简单天气 JS 文件中使用该选项,并且我想要我的输出,当我输入我的城市名称时,它会在该城市的天气中显示。简单的天气 js 选项看起来像 =>
$.simpleWeather({
location: 'New Jersey',
woeid: '',
unit: 'c',
success: function(weather) {
html = '<h2><i class="symbol-weather icon-'+weather.code+'"></i> '+weather.temp+'°'+weather.units.temp+'</h2>';
html += '<ul><li>'+weather.city+'</li>';
$("#weather").html(html);
},
error: function(error) {
$("#weather").html('<p>'+error+'</p>');
}
});
在这里“位置”我想添加我的 redux 插件选项。但它不工作。
$.simpleWeather({
location: '<?php global $cpv; echo $cpv['cpv-hm-cat-op-8'];?>',
请帮助我如何添加我的 redux 框架选项。