简体   繁体   English

使用jQuery替换WordPress插件中用于日期选择器的本地化文件?

[英]Override localization file in WordPress plugin for datepicker with jquery?

I am using a WordPress plugin called HBook which is a searchable availability calendar for hotels. 我正在使用一个名为HBook的WordPress插件,这是可搜索的酒店空房日历。 It uses a jquery datepicker. 它使用一个jQuery datepicker。 The developer's localization file for the datepicker is making the week start on Monday. 开发人员针对日期选择器的本地化文件使每周的星期一开始。 My client is in the US and needs the week to start on Sunday. 我的客户在美国,需要一周从周日开始。 Is there a jquery snippet or something else I could add to my theme to override the "firstDay" in the localization file? 是否有一个jQuery代码片段或其他可以添加到主题中的内容,以覆盖本地化文件中的“ firstDay”? I've tried messing around with it but I am not so great with jquery. 我试过弄乱它,但我对jquery不太满意。

I asked the plugin developer if there was a way to do this, but he said there was not. 我问插件开发人员是否有办法做到这一点,但他说没有。 He said I would just have to change the plugin file. 他说我只需要更改插件文件即可。 I'd rather not do this since I will lose my changes with future releases. 我不想这样做,因为在将来的发行版中我将丢失所做的更改。 He did say he would consider adding this feature to the plugin settings page in a future release, but he had no guess on when this would be. 他确实说过,他会考虑在将来的版本中将此功能添加到插件设置页面中,但是他不确定何时发布。

Here is the plugin's localization file . 这是插件的本地化文件

If this is just not possible I would appreciate someone telling me that so I can move on! 如果这不可能,我将不胜感激有人告诉我,以便我继续前进! thanks! 谢谢!

As explained in the documentation , you can initialize the datepicker with the firstDay option specified: 文档中所述,您可以使用指定的firstDay选项初始化datepicker:

jQuery( ".selector" ).datepicker({
   firstDay: 0
});

If you want to change it after initialization, you can use 如果要在初始化后进行更改,可以使用

jQuery( ".selector" ).datepicker( "option", "firstDay", 0 );

Here is the code for your custom.js file: 这是您的custom.js文件的代码:

jQuery(document).ready(function() {
    jQuery('.hb-input-datepicker').on("focus", function() {
        jQuery(this).datepicker( "option", "firstDay", 0 );
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM