Update to allow setting start date
-
Hi Marcus,
Thanks for the great plugin.
I wanted to be able to set the start date to show a calendar a few months in advance…
It looks like there was some code in your wrapper to do this but that was for v1 (month and year parameters are no longer supported in v2): http://fullcalendar.io/wiki/Upgrading-to-v2/Anyway I’ve hacked the code to add this functionality by using a shortcode… It’s a pretty simple change – the diffs are below:
inline.js:
--- wp-fullcalendar_orig-v1.2\includes\js\inline.js +++ wp-fullcalendar\includes\js\inline.js @@ -9,9 +9,8 @@ left: WPFC.header.left, center: WPFC.header.center, right: WPFC.header.right - }, - month: WPFC.month, - year: WPFC.year, + }, + defaultDate: WPFC.defaultDate, theme: WPFC.wpfc_theme, firstDay: WPFC.firstDay, editable: false,wp-fullcalendar.php:
--- wp-fullcalendar_orig-v1.2\wp-fullcalendar.php +++ wp-fullcalendar\wp-fullcalendar.php @@ -248,9 +248,14 @@ * @return string */ public static function calendar( $args = array() ){ + //Read in shortcode attributes and set defaults + //Full Calender accepts ISO8601 dates + //http://fullcalendar.io/docs/current_date/defaultDate/ + $attributes = shortcode_atts( array( + 'defaultdate' => date('c', current_time('timestamp')), + ), $args ); + if (is_array($args) ) self::$args = array_merge(self::$args, $args); - self::$args['month'] = (!empty($args['month'])) ? $args['month']-1:date('m', current_time('timestamp'))-1; - self::$args['year'] = (!empty($args['year'])) ? $args['year']:date('Y', current_time('timestamp')); self::$args = apply_filters('wpfc_fullcalendar_args', self::$args); add_action('wp_footer', array('WP_FullCalendar','footer_js')); ob_start(); @@ -291,8 +296,7 @@ } echo implode(", ", $strings); ?> }; - WPFC.month = <?php echo self::$args['month']; ?>; - WPFC.year = <?php echo self::$args['year']; ?>; + WPFC.defaultDate = "<?php echo $attributes['defaultdate']; ?>"; </script> <?php do_action('wpfc_calendar_displayed', $args);
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Update to allow setting start date’ is closed to new replies.