// pagination vars $record_start = 1; $record_count = 10; // no. of records per page $record_begin = 1; // start at record no. $record_start = isset($_GET['start']) ? (int) $_GET['start'] : $record_start; $record_start = $record_start > 0 ? $record_start : $record_begin; // store user info global $current_user; get_currentuserinfo(); $current_person = is_user_logged_in() ? $current_user->user_firstname . ' ' . $current_user->user_lastname : ''; $current_nickname = is_user_logged_in() ? $current_user->nickname . ' ' . $current_user->user_lastname : ''; // cache all events per page $cacher = new Cacher(); $get_posts = $cacher->get_cache('tribe_get_events_roster_' . $record_start . '_' . $record_count); if ($get_posts == false) { $get_posts = tribe_get_events(array('posts_per_page' => $record_count, 'eventDisplay' => 'future', 'offset' => $record_start - 1, 'tax_query' => array(array('taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => 'race')))); $cacher->set_cache($get_posts, 'tribe_get_events_roster'); } // TODO: just use this thing $total_posts = $cacher->get_cache('tribe_get_events_roster_total'); if ($total_posts == false) { $total_posts = tribe_get_events(array('posts_per_page' => -1, 'eventDisplay' => 'future')); $cacher->set_cache($total_posts, 'tribe_get_events_roster_total'); } // total records on current page $page_total = $record_count + ($record_start - 1) > count($total_posts) ? count($total_posts) : $record_count + ($record_start - 1); ?> <header class="rosta">
function count_btc_registrants($form_id, $event_id) { if (!is_numeric($form_id) || !is_numeric($event_id)) { return null; } $form_id = (int) $form_id; $event_id = (int) $event_id; // cache registrants per form/event $cacher = new Cacher(); $registrants = $cacher->get_cache('btc_registrant_count_' . $form_id . '_' . $event_id); if ($registrants == false) { global $wpdb; // I don't like this: $sql = 'select count(distinct lead_id) as btcers from ' . $wpdb->prefix . 'rg_lead_detail where field_number=' . EVENT_FIELD_ID . ' and form_id = ' . $form_id . ' and value = \'' . $event_id . '\''; $registrants = $wpdb->get_results($sql, OBJECT); // cache results $cacher->set_cache($registrants, 'btc_registrant_count_' . $form_id . '_' . $event_id); } if ($registrants && is_array($registrants)) { return $registrants[0]->btcers; } return null; }