How do I display the handle for all front-end enqueued scripts in plugin options page?

I use the following function in my plugin to display all the scripts handles in my plugin options page but it display only the handles of admin scripts:

function my_detected_scripts() {
  global $wp_scripts;
  foreach( $wp_scripts-queue as $handle ) :
    echo $handle . ' br / ';
  endforeach;
}

Then:

echo my_detected_scripts()

How can get the handles of all front-end enqueued scripts only?

Thanks in advance!

Topic scripts wp-enqueue-script Wordpress

Category Web


I think it's not possible to get the front-end scripts in a script called in the back-end, because the front-end scripts are all registered in scripts called only on the front-end. I think the only way would be to save a transient option including the front-end scripts on front-end page loading and get the transient option via ajax in the back-end. Maybe it will be not the best way, but I don't see other solutions. Then of course you can add all the conditions with nonces ... to save the transient only in specific conditions ...

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.