Reputation: 5690
I would like to add a jQuery full calendar to my wordpress plugin. By default wordpress contains these widgets for jQuery : http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_Scripts_Included_and_Registered_by_WordPress but my desired widget : http://fullcalendar.io/ is not part of the default jQuery installation.
Can somebody please detail how as part of my plugin I can add support for the jQuery full calendar? This question is related to another question I asked here : "undefined is not a function" when I add a WordPress plugin
The background to the problem is that under the twentyfourteen theme my code in the plugin works fine. Under a different theme - OptimizePress - the code does not work and I think it is because the jQuery is being loaded by OptimizePress and therefore is not including my jQuery support for the calendar.
Please help!
Upvotes: 0
Views: 1573
Reputation: 3762
Add this to your child theme's functions.php file.
function fullcalendar_jquery_enqueue() {
wp_register_script('fullcalendar', "http//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.3/fullcalendar.min.js", false, null, true);
wp_enqueue_script('fullcalendar');
}
add_action("wp_enqueue_scripts", "fullcalendar_jquery_enqueue", 11);
function load_styles() {
wp_register_style('fullcalendarcss', 'http://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.3/fullcalendar.min.css');
wp_register_style('fullcalendarprintcss', 'http://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.3/fullcalendar.print.css');
wp_enqueue_style( 'fullcalendarcss');
wp_enqueue_style( 'fullcalendarprintcss');
}
add_action('wp_print_styles', 'load_styles');
Upvotes: 1