Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Last active October 2, 2017 10:31
Show Gist options
  • Save andrasguseo/08b9f3cff12facd93469c4dab212252d to your computer and use it in GitHub Desktop.
Save andrasguseo/08b9f3cff12facd93469c4dab212252d to your computer and use it in GitHub Desktop.
Changes the date format in the header of the calendar datepicker
<?php
/**
* Plugin name: Datepicker Date Format for The Events Calendar
* Description: Changes the date format of the calendar datepicker header (for The Events Calendar). Please read the instructions in the file and change the settings in the code as per your requirements.
* Download and copy the file to your wp-content/plugins folder and activate it.
*
* Required plugins: The Events Calendar
* Version: 2017-10-01
* Author: Barry Hughes
*/
add_action( 'wp_footer', 'datepicker_date_format', 1000 );
function datepicker_date_format() {
echo <<<HTML
<script type="text/javascript">
if (
'function' === typeof jQuery
&& 'function' === typeof jQuery.fn.bootstrapDatepicker
) {
// 1) In this example we're adjusting the jp (Japanese) property,
// to modify the English equivalent we'd access en instead.
//
// 2) The format in this example will result in the year then the
// full month, but all formats as described below are accepted:
// https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#format
jQuery.fn.bootstrapDatepicker.dates.en['titleFormat'] = 'yyyy. MM';
}
</script>
HTML;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment