/** * Replaces the event page with the FullCalendar if requested in settings * @param unknown_type $page_content * @return Ambigous <mixed, string> */ function wpfc_em_content($content = '', $page_content = '') { global $wpdb, $post; if (em_is_events_page()) { $calendar_content = WP_FullCalendar::calendar(); //Now, we either replace CONTENTS or just replace the whole page if (preg_match('/CONTENTS/', $page_content)) { $content = str_replace('CONTENTS', $calendar_content, $page_content); } else { $content = $calendar_content; } } return $content; }
/** * Returns the calendar HTML setup and primes the js to load at wp_footer * @param array $args * @return string */ public static function calendar($args = array()) { 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(); ?> <div class="wpfc-calendar-wrapper"><form class="wpfc-calendar"></form><div class="wpfc-loading"></div></div> <div class="wpfc-calendar-search" style="display:none;"> <?php $post_type = !empty(self::$args['type']) ? self::$args['type'] : 'post'; //figure out what taxonomies to show $wpfc_post_taxonomies = get_option('wpfc_post_taxonomies'); $search_taxonomies = !empty($wpfc_post_taxonomies[$post_type]) ? array_keys($wpfc_post_taxonomies[$post_type]) : array(); if (!empty($args['taxonomies'])) { //we accept taxonomies in arguments $search_taxonomies = explode(',', $args['taxonomies']); array_walk($search_taxonomies, 'trim'); unset(self::$args['taxonomies']); } //go through each post type taxonomy and display if told to foreach (get_object_taxonomies($post_type) as $taxonomy_name) { $taxonomy = get_taxonomy($taxonomy_name); if (count(get_terms($taxonomy_name, array('hide_empty' => 1))) > 0 && in_array($taxonomy_name, $search_taxonomies)) { $default_value = !empty(self::$args[$taxonomy_name]) ? self::$args[$taxonomy_name] : 0; $taxonomy_args = array('echo' => true, 'hide_empty' => 1, 'name' => $taxonomy_name, 'hierarchical' => true, 'class' => 'wpfc-taxonomy ' . $taxonomy_name, 'taxonomy' => $taxonomy_name, 'selected' => $default_value, 'show_option_all' => $taxonomy->labels->all_items); wp_dropdown_categories(apply_filters('wpmfc_calendar_taxonomy_args', $taxonomy_args, $taxonomy)); } } do_action('wpfc_calendar_search', self::$args); ?> </div> <script type="text/javascript"> WPFC.data = { action : 'WP_FullCalendar'<?php //these arguments were assigned earlier on when displaying the calendar, and remain constant between ajax calls if (!empty(self::$args)) { echo ", "; } $strings = array(); foreach (self::$args as $key => $arg) { $arg = is_numeric($arg) ? (int) $arg : "'{$arg}'"; $strings[] = "'{$key}'" . " : " . $arg; } echo implode(", ", $strings); ?> }; WPFC.month = <?php echo self::$args['month']; ?> ; WPFC.year = <?php echo self::$args['year']; ?> ; </script> <?php do_action('wpfc_calendar_displayed', $args); return ob_get_clean(); }
/** * Returns the calendar HTML setup and primes the js to load at wp_footer * @param array $args * @return string */ function calendar($args = array()) { 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(); ?> <div id="wpfc-calendar-wrapper"><form id="wpfc-calendar"></form><div class="wpfc-loading"></div></div> <div id="wpfc-calendar-search" style="display:none;"> <?php $post_type = !empty(self::$args['type']) ? self::$args['type'] : 'post'; //figure out what taxonomies to show $wpfc_post_taxonomies = get_option('wpfc_post_taxonomies'); $search_taxonomies = !empty($wpfc_post_taxonomies[$post_type]) ? array_keys($wpfc_post_taxonomies[$post_type]) : array(); if (!empty($args['taxonomies'])) { //we accept taxonomies in arguments $search_taxonomies = explode(',', $args['taxonomies']); array_walk($search_taxonomies, 'trim'); unset(self::$args['taxonomies']); } //go through each post type taxonomy and display if told to foreach (get_object_taxonomies($post_type) as $taxonomy_name) { $taxonomy = get_taxonomy($taxonomy_name); if (count(get_terms($taxonomy_name, array('hide_empty' => 1))) > 0 && in_array($taxonomy_name, $search_taxonomies)) { $default_value = !empty(self::$args[$taxonomy_name]) ? self::$args[$taxonomy_name] : 0; $taxonomy_args = array('echo' => true, 'hide_empty' => 1, 'name' => $taxonomy_name, 'hierarchical' => true, 'class' => 'wpfc-taxonomy', 'taxonomy' => $taxonomy_name, 'selected' => $default_value, 'show_option_all' => $taxonomy->labels->all_items); wp_dropdown_categories(apply_filters('wpmfc_calendar_taxonomy_args', $taxonomy_args, $taxonomy)); } } do_action('wpfc_calendar_search', self::$args); ?> </div> <?php return ob_get_clean(); }
<?php // Template Name: Calendar get_header(); the_post(); ?> <section id="locke-cal" class="container"> <?php echo WP_FullCalendar::calendar(array()); ?> </section> <?php get_footer();
</select> </div> </li> </ul> </form>--> </div> </div> </div><!-- main right box--> <div class="right-main-box pull-right"> <div id="calender"> <?php //echo do_shortcode('[events_calendar long_events=1 full=1]'); ?> <?php echo WP_FullCalendar::calendar('long_events=1'); ?> </div> <h2 class="pg-title">Upcoming events</h2> <div id="events"> <?php $args = 'post_type=event&post_status=publish&posts_per_page=5&paged=' . $paged; $pquery = new WP_Query($args); $page = $paged; if ($paged == 0) { $page = 1; } if ($pquery->have_posts()) { ?> <ul class="all-posts">