NO BUG: Media browse panel does not enqueue admin scripts in the expected way

I use a plugin called Converter for Media which adds asset statistics and optimise actions in the WordPress media library. This functionality is broken when using the browse media panel in Bricks when for example adding images to a carousel. I reached out to the plugin developers and this is their response:

"Our plugin loads its styles and scripts in the WordPress dashboard through the standard admin_enqueue_scripts action (admin_enqueue_scripts – Hook | Developer.WordPress.org). Bricks, however, uses a separate editor panel where that action isn’t fired.
From our tests, Bricks pulls assets there via wp_enqueue_scripts (wp_enqueue_scripts – Hook | Developer.WordPress.org), which is intended for the front end. As a result, the files from our plugin never reach the Bricks editor, causing the issue you’re seeing.

We’d be happy to add a workaround, but introducing an exception just for Bricks could affect the stability of a solution that’s already running on more than 500,000 sites. We haven’t received other reports like this so far, so for now we’re keeping the code as universal as possible. Of course, we’ll monitor the situation and, if Bricks’ popularity grows or we get additional feedback, we’ll revisit the matter.

At this stage, the best approach is to reach out to the Bricks team. If they add support for the admin_enqueue_scripts action in their panel, the problem will be resolved at its source."

Hi @jamie,

Bricks Builder runs in the frontend, not the WordPress admin, which is why it uses wp_enqueue_scripts instead of admin_enqueue_scripts. This isn’t a bug in Bricks. It’s a compatibility issue with the plugin, as their own devs explained. If their scripts depend on admin-only hooks, they won’t load in Bricks’ editor unless the plugin explicitly accounts for that.

1 Like

Fair enough. Understandably, the developer doesn’t want to (or can’t) use wp_enqueue_scripts for admin related functionality.

I just checked one of our Elementor websites to see how the media popup is handled in that case. Interestingly, none of the statistics or optimisation drop-downs are shown at all when inside the builder and browsing media. This solution would also be fine.