Call plugins_url in a hook
-
The URL to resources of the plugin (CSS / JS) gets generated in the global context of the plugin. Thus, changes to the URL that are done via filters do not get applied. An example of this is when Foobox is used with the Polylang plugin: If an individual URL for each language is configured, Foobox always references the resources using the
site_url, disregarding the domain for an additional language. This leads to the resources not being loaded due to Cross-Origin-Resource-Sharing being restricted in most browsers.The URLs of the resources should be called in a hook and not in the global context of the plugin, i.e. in the function
register_and_enqueue_css()in filefree/includes/classes/class-foo-plugin-base.php(please also see here).
The topic ‘Call plugins_url in a hook’ is closed to new replies.