get_queried_object_id(); $wpfc_scripts_limit = get_option('wpfc_scripts_limit'); if( empty($wpfc_scripts_limit) || in_array($obj_id, explode(',',$wpfc_scripts_limit)) ){ //Scripts wp_enqueue_script('wp-fullcalendar', plugins_url('includes/js/main.js',__FILE__), array('jquery', 'jquery-ui-core','jquery-ui-widget','jquery-ui-position', 'jquery-ui-selectmenu'), WPFC_VERSION); //jQuery will load as dependency WP_FullCalendar::localize_script(); //Styles wp_enqueue_style('wp-fullcalendar', plugins_url('includes/css/main.css',__FILE__), array(), WPFC_VERSION); //Load custom style or jQuery UI Theme $wpfc_theme = get_option('wpfc_theme_css'); if( preg_match('/\.css$/', $wpfc_theme) ){ //user-defined style within the themes/themename/plugins/wp-fullcalendar/ folder //if you're using jQuery UI Theme-Roller, you need to include the jquery-ui-css framework file too, you could do this using the @import CSS rule or include it all in your CSS file if( file_exists(get_stylesheet_directory()."/plugins/wp-fullcalendar/".$wpfc_theme) ){ $wpfc_theme_css = get_stylesheet_directory_uri()."/plugins/wp-fullcalendar/".$wpfc_theme; wp_deregister_style('jquery-ui'); wp_enqueue_style('jquery-ui', $wpfc_theme_css, array('wp-fullcalendar'), WPFC_VERSION); } }elseif( !empty($wpfc_theme) ){ //We'll find the current jQuery UI version and attempt to load the right version of jQuery UI, otherwise we'll load the default. This allows backwards compatability from 3.6 onwards. global $wp_scripts; $jquery_ui_version = preg_replace('/\.[0-9]+$/', '', $wp_scripts->registered['jquery-ui-core']->ver); if( $jquery_ui_version != WPFC_UI_VERSION ){ $jquery_ui_css_versions = glob( $plugin_path = plugin_dir_path(__FILE__)."/includes/css/jquery-ui-".$jquery_ui_version.'*', GLOB_ONLYDIR); if( !empty($jquery_ui_css_versions) ){ //use backwards compatible theme $jquery_ui_css_folder = str_replace(plugin_dir_path(__FILE__),'', array_pop($jquery_ui_css_versions)); $jquery_ui_css_uri = plugins_url(trailingslashit($jquery_ui_css_folder).$wpfc_theme."/jquery-ui$min.css",__FILE__); $wpfc_theme_css = plugins_url(trailingslashit($jquery_ui_css_folder).$wpfc_theme.'/theme.css',__FILE__); } } if( empty($wpfc_theme_css) ){ //use default theme $jquery_ui_css_uri = plugins_url('/includes/css/jquery-ui/'.$wpfc_theme."/jquery-ui$min.css",__FILE__); $wpfc_theme_css = plugins_url('/includes/css/jquery-ui/'.$wpfc_theme.'/theme.css',__FILE__); } if( !empty($wpfc_theme_css) ){ wp_deregister_style('jquery-ui'); wp_enqueue_style('jquery-ui', $jquery_ui_css_uri, array('wp-fullcalendar'), WPFC_VERSION); wp_enqueue_style('jquery-ui-theme', $wpfc_theme_css, array('wp-fullcalendar'), WPFC_VERSION); } } } } public static function localize_script(){ $js_vars = array(); $schema = is_ssl() ? 'https':'http'; $js_vars['ajaxurl'] = admin_url('admin-ajax.php', $schema); $js_vars['firstDay'] = get_option('start_of_week'); $js_vars['wpfc_theme'] = get_option('wpfc_theme_css') ? true:false; $js_vars['wpfc_limit'] = get_option('wpfc_limit',3); $js_vars['wpfc_limit_txt'] = get_option('wpfc_limit_txt','more ...'); //FC options $js_vars['timeFormat'] = get_option('wpfc_timeFormat', 'h(:mm)t'); $js_vars['defaultView'] = get_option('wpfc_defaultView', 'month'); $js_vars['weekends'] = get_option('wpfc_weekends',true) ? 'true':'false'; $js_vars['header'] = new stdClass(); $js_vars['header']->left = 'prev,next today'; $js_vars['header']->center = 'title'; $js_vars['header']->right = implode(',', get_option('wpfc_available_views', array('month','basicWeek','basicDay'))); $js_vars['header'] = apply_filters('wpfc_calendar_header_vars', $js_vars['header']); //qtip options $js_vars['wpfc_qtips'] = get_option('wpfc_qtips',true) == true; if( $js_vars['wpfc_qtips'] ){ $js_vars['wpfc_qtips_classes'] = 'ui-tooltip-'. get_option('wpfc_qtips_style','light'); $js_vars['wpfc_qtips_my'] = get_option('wpfc_qtips_my','top center'); $js_vars['wpfc_qtips_at'] = get_option('wpfc_qtips_at','bottom center'); if( get_option('wpfc_qtips_rounded', false) ){ $js_vars['wpfc_qtips_classes'] .= " ui-tooltip-rounded"; } if( get_option('wpfc_qtips_shadow', true) ){ $js_vars['wpfc_qtips_classes'] .= " ui-tooltip-shadow"; } } //calendar translations wp_localize_script('wp-fullcalendar', 'WPFC', apply_filters('wpfc_js_vars', $js_vars)); } /** * Catches ajax requests by fullcalendar */ public static function ajax(){ global $post; //sort out args unset($_REQUEST['month']); //no need for these two unset($_REQUEST['year']); //maybe excessive, but easy sanitization of start/end query params $_REQUEST['start'] = $_POST['start'] = date('Y-m-d', strtotime($_REQUEST['start'])); $_REQUEST['end'] = $_POST['end'] = date('Y-m-d', strtotime($_REQUEST['end'])); $args = array ('scope'=>array($_REQUEST['start'], $_REQUEST['end']), 'owner'=>false, 'status'=>1, 'order'=>'ASC', 'orderby'=>'post_date','full'=>1); //get post type and taxonomies, determine if we're filtering by taxonomy $post_types = get_post_types(array('public'=>true),'names'); $post_type = !empty($_REQUEST['type']) && in_array($_REQUEST['type'], $post_types) ? $_REQUEST['type']:get_option('wpfc_default_type'); $args['post_type'] = $post_type; $args['post_status'] = 'publish'; //only show published status $args['posts_per_page'] = -1; if( $args['post_type'] == 'attachment' ) $args['post_status'] = 'inherit'; $args['tax_query'] = array(); foreach( get_object_taxonomies($post_type) as $taxonomy_name ){ if( !empty($_REQUEST[$taxonomy_name]) ){ $args['tax_query'][] = array( 'taxonomy' => $taxonomy_name, 'field' => 'id', 'terms' => $_REQUEST[$taxonomy_name] ); } } //initiate vars $args = apply_filters('wpfc_fullcalendar_args', $args); $limit = get_option('wpfc_limit',3); $items = array(); $item_dates_more = array(); $item_date_counts = array(); //Create our own loop here and tamper with the where sql for date ranges, as per http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters function wpfc_temp_filter_where( $where = '' ) { global $wpdb; $where .= $wpdb->prepare(" AND post_date >= %s AND post_date < %s", $_REQUEST['start'], $_REQUEST['end']); return $where; } add_filter( 'posts_where', 'wpfc_temp_filter_where' ); do_action('wpfc_before_wp_query'); $the_query = new WP_Query( $args ); remove_filter( 'posts_where', 'wpfc_temp_filter_where' ); //loop through each post and slot them into the array of posts to return to browser while ( $the_query->have_posts() ) { $the_query->the_post(); $color = "#a8d144"; $post_date = substr($post->post_date, 0, 10); $post_timestamp = strtotime($post->post_date); if( empty($item_date_counts[$post_date]) || $item_date_counts[$post_date] < $limit ){ $title = $post->post_title; $item = array ("title" => $title, "color" => $color, "start" => date('Y-m-d\TH:i:s', $post_timestamp), "end" => date('Y-m-d\TH:i:s', $post_timestamp), "url" => get_permalink($post->ID), 'post_id' => $post->ID ); $items[] = apply_filters('wpfc_ajax_post', $item, $post); $item_date_counts[$post_date] = (!empty($item_date_counts[$post_date]) ) ? $item_date_counts[$post_date]+1:1; }elseif( empty($item_dates_more[$post_date]) ){ $item_dates_more[$post_date] = 1; $day_ending = $post_date."T23:59:59"; //TODO archives not necesarrily working $more_array = array ("title" => get_option('wpfc_limit_txt','more ...'), "color" => get_option('wpfc_limit_color','#fbbe30'), "start" => $day_ending, 'post_id' => 0, 'className' => 'wpfc-more'); global $wp_rewrite; $archive_url = get_post_type_archive_link($post_type); if( !empty($archive_url) || $post_type == 'post' ){ //posts do have archives $archive_url = trailingslashit($archive_url); $archive_url .= $wp_rewrite->using_permalinks() ? date('Y/m/', $post_timestamp):'?m='.date('Ym', $post_timestamp); $more_array['url'] = $archive_url; } $items[] = apply_filters('wpfc_ajax_more', $more_array, $post_date); } } echo json_encode(apply_filters('wpfc_ajax', $items)); die(); //normally we'd wp_reset_postdata(); } /** * Called during AJAX request for qtip content for a calendar item */ public static function qtip_content(){ $content = ''; if( !empty($_REQUEST['post_id']) ){ $post = get_post($_REQUEST['post_id']); if( $post->post_type == 'attachment' ){ $content = wp_get_attachment_image($post->ID, 'thumbnail'); }else{ $content = ( !empty($post) ) ? $post->post_content : ''; if( get_option('wpfc_qtips_image',1) ){ $post_image = get_the_post_thumbnail($post->ID, array(get_option('wpfc_qtip_image_w',75),get_option('wpfc_qtip_image_h',75))); if( !empty($post_image) ){ $content = '
'.$post_image.'
'.$content; } } } } echo apply_filters('wpfc_qtip_content', $content); die(); } /** * 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(); ?>
'.__('Settings', 'wp-fullcalendar').''; return array_merge($new_links,$links); } //translations load_plugin_textdomain('wp-fullcalendar', false, dirname( plugin_basename( __FILE__ ) ).'/includes/langs');