Register assets context #6795
Replies: 7 comments
-
Issue-Label Bot is automatically applying the label Links: app homepage, dashboard and code for this bot. |
Beta Was this translation helpful? Give feedback.
-
@JoryHogeveen Can you clarify what hooks / context would be used in an example? |
Beta Was this translation helpful? Give feedback.
-
Sure! There are now two filters: We could add a second context parameter. Example of usage: add_filter( 'pods_after_enqueue_scripts', function( $suffix, $context ) {
if ( 'admin' === $context ) {
// Scripts for admin pages only.
}
if ( 'modal' === $context ) {
// Scripts for Pods modal only.
}
// etc.
}, 10, 2 ); I already used the filter in PodsI18n: https://github.com/pods-framework/pods/blob/main/classes/PodsI18n.php#L39 |
Beta Was this translation helpful? Give feedback.
-
To avoid reinventing wheels, may I suggest taking a look at what our Inpsyde buddies have thought of this problem at https://github.com/inpsyde/wp-context/ |
Beta Was this translation helpful? Give feedback.
-
Hi @lkraav |
Beta Was this translation helpful? Give feedback.
-
Possibly, I'm in the beggining phases with it myself, through another Inpsyde package I'm using. But this maybe begs the questions, how many context should be defined, and if we think we need more, is there a problem with modelling our problem? |
Beta Was this translation helpful? Give feedback.
-
For Pods we have the Modal: Pods modal popup These are both quite important contexts in this case but are not part of WP core. |
Beta Was this translation helpful? Give feedback.
-
Pods hooks into all register script hooks of WordPress. 2.7.23 will add two filters (before and after) for other parts of Pods to register script.
We should add some form of context to these filters. Some ideas:
admin
General admin pagesfront
Frontend pageslogin
Login pagebuilder
Page Builder pages (usually frontend)modal
Modal view (pods_is_modal_window()
), this is similar to admin contextBeta Was this translation helpful? Give feedback.
All reactions