require.js to load javascript

Though WordPress already has a basic .js API (with register and enqueue script), I don’t see why you cannot use it in conjunction with require.js, at least at the modular level. From what I can tell (never used it) it only needs to be loaded, so you can, wp_enqueue_script( $handle, ‘…folder../require.js’, $deps, $ver, $in_footer ); … Read more

How to add a “data-” attribute to the image tag of native gallery output

Depending on how your Galleria plugin is interacting with the attachment image filters, you should be able to inject your data attribute using the wp_get_attachment_image_attributes filter. Obviously, the attribute would be added for anything using wp_get_attachment_image(), but it will do what you’re asking. /** * Filter attributes for the current gallery image tag. * * … Read more

wp_customize_support_script – do I need it?

Yes, it is needed. For reference, the function’s description is: Prints a script to check whether or not the Customizer is supported, and apply either the no-customize-support or customize-support class to the body. The class names that the function toggles on the body element control whether or not the Customize link in the admin bar … Read more

WP REST – video and audio players

Ran into this same issue and I found the answer after many hours and almost giving up. It’s in a bit of code that written to make the Customizer work with playlists. Checkout this comment from /wp-includes/widgets/class-wp-widget-text.php: /** * Enqueue preview scripts. * * These scripts normally are enqueued just-in-time when a playlist shortcode is … Read more