Prevent direct access to WordPress plugin assets?

Question

I was wondering if there was a simple way to prevent direct access to asset files within a WordPress plugin. Primarily javascript files.

I’m developing a plugin that’s meant to be used only in the admin dashboard, and I would like the javascript files this plugin uses to not be exposed to the public. It should only be able to be run by a logged-in admin on the dashboard.

Currently, anyone can access a plugin asset file directly through the URL via
https://DOMAIN.com/wp-content/plugins/YOURPLUGIN/assets/YOURJSFILE.js

So if somewhere were to somehow get that domain they can few the JS file.

Hope that question makes sense.

Thanks!

0
Dan 5 months 2022-07-02T12:14:12-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse