Skip to content

Conversation

@r-a-y
Copy link

@r-a-y r-a-y commented Aug 22, 2016

MEXP's JS has hardcoded references to its own views and controllers. This makes things impossible for more than one plugin to override these internals.

For example, MEXP's built-in YouTube service manually overrides MEXP's own media.view.MEXP and media.view.Toolbar.MEXP, so no other plugin can touch these without conflicts occurring:
https://github.com/Automattic/media-explorer/blob/master/js/mexp.js#L85
https://github.com/Automattic/media-explorer/blob/master/services/youtube/js.js#L11

https://github.com/Automattic/media-explorer/blob/master/js/mexp.js#L36
https://github.com/Automattic/media-explorer/blob/master/services/youtube/js.js#L219

This commit allows each service to set their own views and controllers and refactors MEXP to allow these views and controllers to be initialized.

Specifically, adds a JS utility function - stringToFunction() - so we can instantiate custom views (could do better here).

Plugins can override the default views and controllers by registering them on the "mexp_js_{$service_id}" hook. See how we're using this hook with our Google Drive MEXP plugin.

I didn't change MEXP's YouTube JS to do this yet. If this commit looks good in your eyes, then I'll add a commit for YouTube.

MEXP's JS has hardcoded references to its own views and controllers.
This makes things impossible for more than one plugin to override these
internals.

For example, MEXP's built-in YouTube service manually overrides
MEXP's own media.view.MEXP and media.view.Toolbar.MEXP, so no other plugin
can touch these without conflicts occurring.

This commit allows each service to set their own views and controllers and
refactors MEXP to allow these views and controllers to be initialized.

Specifically, adds a JS utility function - stringToFunction() - so we can
instantiate custom views (could do better here).  Plugins can override the
default views and controllers on the "mexp_js_{$service_id}" hook.
@GaryJones GaryJones changed the base branch from main to develop November 5, 2025 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant