Plugin Author
Aesqe
(@aesqe)
@old_blueyes:
when calling the shortcode directly from the template, the CSS and JavaScript files are NOT enqueued automatically – you’ll have to do that manually.
The reason for this is, the CSS <link> tags must be in the <head> of the document, and since you’re calling the shortcode from within your template, the head part is already generated.
The only way would be to use JavaScript to inject the CSS <link> in the document after it has loaded – but I really don’t think that’s an generally acceptable solution.
Aesque,
since it’s becoming an emerging request, I suggest to implement a tutorial or integrate a solution directly in the plugin. The possibility to embed the gallery EASILY in a template file would be a killer feature, as this would give a great control to theme developers.
Best regards
Plugin Author
Aesqe
(@aesqe)
@thedarkmist:
I’ll write up a tutorial to explain best practices when using the shortcode within template files.
And this could be a way to do it from the plugin point of view:
add a new attribute to the shortcode, ‘force_enqueue’ (true or false)
if set to true, enqueue javascript files in footer and, depending on a second new attribute – ‘force_enqueue_css’ (‘inject’ or ‘inline’), inject css links into header using javascript (I really dislike this part), or get css file contents and prepend them inline to HTML (in HTML5, if used with the ‘scope’ attribute, <style> tags are allowed inside <body>)
I’ll think some more about it, but, without output buffering, I don’t think there’s another way to do it…
I’ll definitely write up a tutorial as soon as I can 🙂