我正在使用wp-store-locator 插件和我想将插件目录路径添加到我的JS。
html = "<li data-store-id=\'" + id + "\'><div><p>" + storeImg + "<strong>" + store + "</strong><span class=\'wpsl-street\'>" + address + "</span>" + address2 + city + " " + state + " " + zip + "</p>" + moreInfo + "<span><a href=\'plugin-urlpath/store-listings.php\' class=\'more-details\'>More details</a></span></div></li>";
return html;
我该怎么做?插件路径位于
html
.
EDITED:
这就是我所做的:
wp_enqueue_script( \'wpsl-gmap\', ( "//maps.google.com/maps/api/js?sensor=false&libraries=places&language=" . $this->settings[\'api_language\'] ), false, \'\', true );
wp_localize_script(\'wpsl-gmap\', \'wpsl-gmap\', array(\'pluginsUrl\' => plugins_url(,__FILE__)));
然后将此行添加到
wpsl-gmap.jsvar href = wpsl-gmap.pluginsUrl + \'/path/to/resource\';
html = "<li data-store-id=\'" + id + "\'><div><p>" + storeImg + "<strong>" + store + "</strong><span class=\'wpsl-street\'>" + address + "</span>" + address2 + city + " " + state + " " + zip + "</p>" + moreInfo + "<span><a href=\'" + href + "\' class=\'more-details\'>More details</a></span></div></li>";
它没有给出错误。但它也没有告诉我商店的位置。
NOTE 在进行此操作之前,它已正确显示。