【问题标题】:Wordpress adding jQuery full Calendar support to wordpressWordpress 将 jQuery 完整的日历支持添加到 wordpress
【发布时间】:2014-12-04 18:39:12
【问题描述】:

我想在我的 wordpress 插件中添加一个 jQuery 完整日历。默认情况下,wordpress 包含这些用于 jQuery 的小部件:http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_Scripts_Included_and_Registered_by_WordPress,但我想要的小部件:http://fullcalendar.io/ 不是默认 jQuery 安装的一部分。

有人可以详细说明如何作为我的插件的一部分添加对 jQuery 完整日历的支持吗?这个问题与我在这里提出的另一个问题有关:"undefined is not a function" when I add a WordPress plugin

问题的背景是在 241 主题下,我在插件中的代码可以正常工作。在不同的主题下 - OptimizePress - 代码不起作用,我认为这是因为 OptimizePress 正在加载 jQuery,因此不包括我对日历的 jQuery 支持。

请帮忙!

【问题讨论】:

    标签: javascript jquery wordpress fullcalendar


    【解决方案1】:

    将此添加到您的子主题的 functions.php 文件中。

    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');
    

    【讨论】:

    • 我已经这样做了 - 但它仍然存在与我在中所示相同的错误:stackoverflow.com/questions/27180306/…
    • 我明白了,与 OptimizePress 主题存在某种冲突。您可以启用您要使用的主题并将我链接到您的网站吗?我也许可以在那里弄清楚。我最近一直在处理类似的问题。
    • 是的,我当然可以——但我宁愿私下链接到你——不知道如何在 stackoverflow 上开始“对话”,而不是继续评论这个帖子直到它提供一个?!
    • 给我发一封电子邮件,它在我的个人资料中stackoverflow.com/users/574823/hawkeye126
    • 想我明白了!不过现在遇到了下一个问题。如果需要,我会尝试解决并发送电子邮件!
    猜你喜欢
    • 1970-01-01
    • 2021-02-06
    • 2012-08-31
    • 2020-02-10
    • 2013-06-22
    • 2012-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多