Last active
December 7, 2023 13:17
-
-
Save ihslimn/979736d8142f59634e3eec0b2695e4e8 to your computer and use it in GitHub Desktop.
JetBooking Set calendar language to site locale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'wp_head', function () { ?> | |
| <script> | |
| jQuery( document ).on( 'jet-booking/init', () => { | |
| window.JetPlugins.hooks.addFilter( "jet-booking.input.config", "jetBooking", modifyBookingConfig ); | |
| window.JetPlugins.hooks.addFilter( "jet-booking.calendar.config", "jetBooking", modifyBookingConfig ); | |
| function modifyBookingConfig( config ) { | |
| const lang = document.documentElement?.lang; | |
| if ( ! lang ) { | |
| return config; | |
| } | |
| config.language = lang.includes('zh-') ? 'cn' : ( lang.split('-')[0] || lang ).toLowerCase(); | |
| return config; | |
| } | |
| } ); | |
| </script> | |
| <?php } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment