/**
  * Output the metabox
  */
 public static function output($post)
 {
     $calendar = new SP_Calendar($post);
     $data = $calendar->data();
     $usecolumns = $calendar->columns;
     self::table($data, $usecolumns);
 }
function sp_get_calendar($post = 0)
{
    $calendar = new SP_Calendar($post);
    return $calendar->data();
}
Ejemplo n.º 3
0
if ($status != 'default') {
    $calendar->status = $status;
}
if ($date != 'default') {
    $calendar->date = $date;
}
if ($date_from != 'default') {
    $calendar->from = $date_from;
}
if ($date_to != 'default') {
    $calendar->to = $date_to;
}
if ($order != 'default') {
    $calendar->order = $order;
}
$data = $calendar->data();
$usecolumns = $calendar->columns;
$title_format = get_option('prosports_event_list_title_format', 'title');
$time_format = get_option('prosports_event_list_time_format', 'combined');
if (isset($columns)) {
    if (is_array($columns)) {
        $usecolumns = $columns;
    } else {
        $usecolumns = explode(',', $columns);
    }
}
if ($id) {
    echo '<h4 class="sp-table-caption">' . get_the_title($id) . '</h4>';
}
?>
<div class="sp-template sp-template-event-list">
 /**
  * Define our custom columns shown in admin.
  * @param  string $column
  */
 public function custom_columns($column, $post_id)
 {
     switch ($column) {
         case 'sp_league':
             echo get_the_terms($post_id, 'sp_league') ? the_terms($post_id, 'sp_league') : __('All', 'prosports');
             break;
         case 'sp_season':
             echo get_the_terms($post_id, 'sp_season') ? the_terms($post_id, 'sp_season') : __('All', 'prosports');
             break;
         case 'sp_venue':
             echo get_the_terms($post_id, 'sp_venue') ? the_terms($post_id, 'sp_venue') : __('All', 'prosports');
             break;
         case 'sp_team':
             $teams = (array) get_post_meta($post_id, 'sp_team', false);
             $teams = array_filter($teams);
             if (empty($teams)) {
                 echo __('All', 'prosports');
             } else {
                 $current_team = get_post_meta($post_id, 'sp_current_team', true);
                 foreach ($teams as $team_id) {
                     if (!$team_id) {
                         continue;
                     }
                     $team = get_post($team_id);
                     if ($team) {
                         echo $team->post_title;
                         if ($team_id == $current_team) {
                             echo '<span class="dashicons dashicons-yes" title="' . __('Current Team', 'prosports') . '"></span>';
                         }
                         echo '<br>';
                     }
                 }
             }
             break;
         case 'sp_events':
             $calendar = new SP_Calendar($post_id);
             echo sizeof($calendar->data());
             break;
         case 'sp_layout':
             echo sp_array_value(SP()->formats->calendar, get_post_meta($post_id, 'sp_format', true), '&mdash;');
             break;
     }
 }
Ejemplo n.º 5
0
extract($defaults, EXTR_SKIP);
if (isset($id)) {
    $calendar = new SP_Calendar($id);
    if ($status != 'default') {
        $calendar->status = $status;
    }
    if ($date != 'default') {
        $calendar->date = $date;
    }
    if ($date_from != 'default') {
        $calendar->from = $date_from;
    }
    if ($date_to != 'default') {
        $calendar->to = $date_to;
    }
    $events = $calendar->data();
    $event_ids = array();
    foreach ($events as $event) {
        $event_ids[] = $event->ID;
    }
    if (empty($event_ids)) {
        $in = 'AND 1 = 0';
    } else {
        $in = 'AND ID IN (' . implode(', ', $event_ids) . ')';
    }
} else {
    $in = '';
}
// week_begins = 0 stands for Sunday
$week_begins = intval(get_option('start_of_week'));
// Get year and month from query vars