我正在尝试使用以下语法在WordPress管理类中加载Google Maps API:
add_action('admin_enqueue_scripts', array(&$this, 'load_google_maps'));
Run Code Online (Sandbox Code Playgroud)
...
function load_google_maps()
{
// The actual API key is configured in an options page
$key = get_option('google_maps_api_key');
$gmaps_url = 'http://maps.googleapis.com/maps/api/js?key=' . $key . '&sensor=false';
wp_enqueue_script('google-maps', $gmaps_url, NULL, NULL);
}
Run Code Online (Sandbox Code Playgroud)
WordPress正在将"&"转换为"&".这实际上使Google服务器拒绝了该请求.当我直接在浏览器地址栏中输入"&sensor = false"时,它会正常加载.
我在WordPress trac系统中看到了这种类型的错误:http://core.trac.wordpress.org/ticket/9243但它被视为无效,并且响应请求的管理员以某种方式显示" 038"方法很好.从谷歌的角度来看,这绝对不是好事.
我当然可以获得将HTML作为脚本标记回显的函数,但是如果可能的话我宁愿使用wp_enqueue_script系统.
有人知道这个解决方案吗?
干杯,
RAFF