FullCalendar with slow JSON loading

I use FullCalendar to load events from custom message types in WP via the JSON channel. It works, but it takes some time to load. Please check here: http://cea3.iscte.pt/en/agenda-3/ (June or August). Do any of you have a clue on what could be causing?

This is the complete code for the JSON channel:

<?php

// - standalone json feed -

header('Content-Type:application/json');

// - grab wp load, wherever it hiding -
if(file_exists('../../../../wp-load.php')) :
    include '../../../../wp-load.php';
else:
    include '../../../../../wp-load.php';
endif;

global $wpdb;

// - grab date barrier -
$oneyear = strtotime('-1 year') + ( get_option( 'gmt_offset' ) * 3600 );

// - query -
global $wpdb;
$querystr = "
    SELECT *
    FROM $wpdb->posts wposts, $wpdb->postmeta metastart, $wpdb->postmeta metaend
    WHERE (wposts.ID = metastart.post_id AND wposts.ID = metaend.post_id)
    AND (metaend.meta_key = 'tf_events_enddate' AND metaend.meta_value > $oneyear )
    AND metastart.meta_key = 'tf_events_enddate'
    AND wposts.post_type = 'tf_events'
    AND wposts.post_status = 'publish'
    ORDER BY metastart.meta_value ASC LIMIT 500
 ";

$events = $wpdb->get_results($querystr, OBJECT);
$jsonevents = array();

// - loop -
if ($events):
global $post;
foreach ($events as $post):
setup_postdata($post);

// - custom variables -
$custom = get_post_custom(get_the_ID());
$sd = $custom["tf_events_startdate"][0];
$ed = $custom["tf_events_enddate"][0];

// - grab gmt for start -
$gmts = date('Y-m-d H:i:s', $sd);
$gmts = get_gmt_from_date($gmts); // this function requires Y-m-d H:i:s
$gmts = strtotime($gmts);

// - grab gmt for end -
$gmte = date('Y-m-d H:i:s', $ed);
$gmte = get_gmt_from_date($gmte); // this function requires Y-m-d H:i:s
$gmte = strtotime($gmte);

// - set to ISO 8601 date format -
$stime = date('c', $gmts);
$etime = date('c', $gmte);

$thetitle = $post->post_title;
$short_title = substr($thetitle,0,50);

$eventpostid = $post->ID;
$eventslug = wp_get_post_terms( $eventpostid, 'tf_eventcategory' );
$eventvenueslug = $eventslug[0]->slug;

$tf_events_link = get_post_meta($post->ID, 'tf_events_link', true);
$tf_events_permalink = get_permalink($post->ID);
if ($tf_events_link) { $url_event = $tf_events_link ; }
else { $url_event = $tf_events_permalink; };

// - json items -
$jsonevents[]= array(
    'title' => $short_title . '...',
    'allDay' => false, // <- true by default with FullCalendar
    'start' => $stime,
    'end' => $etime,
    'url' => $url_event,
    'className' => $eventvenueslug
    );

endforeach;
else :
endif;

// - fire away -
echo json_encode($jsonevents);

?> 

Thank.

+3
source share
1 answer

It seems like loading takes a few seconds.

I use this calendar and the download takes about 2-6 seconds. The longest is 6 seconds, but I had about 3 sources and ~ 40 events.

, , , . , , SQL, , . ?

PHP . .NET SQL Server.

, .

enter image description here

-

http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/#options

, - ? -. , ms, .

- , - 1 2 . , , , .

+1

All Articles