示例#1
0
function dpProEventcalendar_column_for_events_list($column_id, $post_id)
{
    global $typenow, $current_user, $wpdb, $dpProEventCalendar, $table_prefix;
    if ($typenow == 'pec-events') {
        switch ($column_id) {
            case 'calendar':
                $id_calendar = get_post_meta($post_id, 'pec_id_calendar', true);
                if (isset($id_calendar)) {
                    $cal_list = explode(",", $id_calendar);
                    require_once dirname(__FILE__) . '/../classes/base.class.php';
                    $calendar = "";
                    $count = 0;
                    foreach ($cal_list as $key) {
                        $dpProEventCalendar_class = new DpProEventCalendar(true, $key);
                        if ($count > 0) {
                            $calendar .= ' - ';
                        }
                        $calendar .= '<a href="' . admin_url('admin.php?page=dpProEventCalendar-admin&edit=' . $key) . '">' . $dpProEventCalendar_class->getCalendarName() . '</a>';
                        $count++;
                    }
                    echo $calendar;
                }
                break;
            case 'start_date':
                $pec_date = get_post_meta($post_id, 'pec_date', true);
                echo '<abbr title="' . date_i18n(get_option('date_format'), strtotime($pec_date)) . ' ' . date_i18n(get_option('time_format'), strtotime($pec_date)) . '">' . date_i18n(get_option('date_format'), strtotime($pec_date)) . ' ' . date_i18n(get_option('time_format'), strtotime($pec_date)) . '</abbr><br>' . ucfirst(get_post_status($post_id));
                break;
            case 'end_date':
                $end_time_hh = get_post_meta($post_id, 'pec_end_time_hh', true);
                $end_time_mm = get_post_meta($post_id, 'pec_end_time_mm', true);
                if (empty($end_time_hh)) {
                    $end_time_hh = '00';
                }
                if (empty($end_time_mm)) {
                    $end_time_mm = '00';
                }
                $pec_end_date = get_post_meta($post_id, 'pec_end_date', true);
                $pec_date = $pec_end_date . ' ' . $end_time_hh . ':' . $end_time_mm . ':00';
                if ($pec_end_date != "" && $pec_end_date != "0000-00-00") {
                    echo '<abbr title="' . date_i18n(get_option('date_format'), strtotime($pec_date)) . ' ' . ($end_time_hh != "" ? date_i18n(get_option('time_format'), strtotime($pec_date)) : '') . '">' . date_i18n(get_option('date_format'), strtotime($pec_date)) . ' ' . ($end_time_hh != "" ? date_i18n(get_option('time_format'), strtotime($pec_date)) : '') . '</abbr>';
                }
                break;
            case 'frequency':
                $frequency = get_post_meta($post_id, 'pec_recurring_frecuency', true);
                if ($frequency != "" && $frequency > 0) {
                    switch ($frequency) {
                        case 1:
                            echo __('Daily', 'dpProEventCalendar');
                            break;
                        case 2:
                            echo __('Weekly', 'dpProEventCalendar');
                            break;
                        case 3:
                            echo __('Monthly', 'dpProEventCalendar');
                            break;
                        case 4:
                            echo __('Yearly', 'dpProEventCalendar');
                            break;
                    }
                }
                break;
            case 'bookings':
                $table_name_booking = $table_prefix . DP_PRO_EVENT_CALENDAR_TABLE_BOOKING;
                $querystr = "\n\t\t\t\t\tSELECT count(*) as counter\n\t\t\t\t\tFROM " . $table_name_booking . "\n\t\t\t\t\tWHERE id_event = " . $post_id . " AND status <> 'pending'\n\t\t\t\t\t";
                $bookings_obj = $wpdb->get_row($querystr, OBJECT);
                echo '<abbr>' . $bookings_obj->counter . '</abbr>';
                break;
        }
    }
}