Con jQuery possiamo includere dinamicamente i plugin nel frontend di WordPress.
La soluzione รจ la seguente:
"use strict";
(function( $ ) {
$.exec = function( path, callback ) {
var src = ( /^\//.test( path ) ) ? path : location.protocol + "//" + location.host + "/" + path;
return $.getScript( src, callback );
};
$(function() {
$.exec( "/wp-content/themes/mytheme/js/fancybox.js", function() {
$( ".fancybox" ).fancybox();
});
});
})( jQuery );