Tuesday, June 7, 2022
HomeWordPress Developmentjavascript - Plugin URL in JS

javascript – Plugin URL in JS


In my plugin I want to incorporate a localization JSON useful resource for an exterior library I will be utilizing. The localization for the actual library will get invoked like this:

$('#table-id').DataTable( {
    language: {
        url: 'http://area.tld/wp-content/plugins/my-plugin-name/property/js/i18n/fr_FR.json'
    }
} );

How do I get in JS this http://area.tld/wp-content/plugins/my-plugin-name/ although, in order that I haven’t got to hardcode it?

In PHP it is simple as I’ve even assigned it to a continuing. However in JS?

Edit: After all I can echo the URL throughout the JS script, however is that this really the correct solution to do it?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments