
- WP-AppKit themes are based on Javascript.
- All app themes have a functions.js file which is the entry point for your theme’s Javascript (e.g. event bindings, DOM manipulation, dialog with app core …).
- The path to functions.js is: wp-content/themes-wp-appkit/[your-theme]/js/functions.js.
- Inserting Javascript directly in templates (e.g. single.html) should be done with caution. Simple code is fine (like string concatenations, conditional statements, component content retrieval…), all within UnderscoreJS template engine tags <% … %>, but DOM manipulation has to be avoided.
define(['jquery','core/theme-app'],function($,App){
//Launch app content refresh when clicking your refresh button :
$('#my-refresh-button').click(function(e){
e.preventDefault();
App.refresh(function(){
$('#my-feedback').html('Content updated successfully :)').show();
});
});
});
You may also include Javascript libraries using RequireJS dependency management (the first “define” line of the above example). More on that here.
Happy coding!