function espresso_category_name_sc($atts) { global $wpdb, $org_options; extract(shortcode_atts(array('event_id' => '0'), $atts)); $event_id = "{$event_id}"; $category_name = espresso_event_category_data($event_id); return $category_name['category_name']; }
function espresso_calendar($atts) { global $wpdb, $org_options, $espresso_calendar, $load_espresso_calendar_scripts; $load_espresso_calendar_scripts = true; //This tells the plugin to load the required scripts extract(shortcode_atts(array('event_category_id' => '', 'show_expired' => 'false', 'cal_view' => 'month'), $atts)); $event_category_id = "{$event_category_id}"; $show_expired = "{$show_expired}"; $cal_view = "{$cal_view}"; //Build the SQL to run //Get the categories if ($event_category_id != "") { $sql = "SELECT e.*, c.category_name, c.category_desc, c.display_desc, ese.start_time, ese.end_time FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id "; $sql .= " JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id "; $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id= e.id "; $sql .= " WHERE e.is_active = 'Y' "; $sql .= " AND e.event_status != 'D' "; $sql .= " AND e.event_status != 'S' "; $sql .= " AND e.event_status != 'P' "; $sql .= " AND e.event_status != 'X' "; $sql .= " AND e.event_status != 'R' "; $sql .= " AND c.category_identifier = '" . $event_category_id . "' "; if ($show_expired == "false") { $sql .= " AND start_date >= '" . date('Y-m-d') . "' "; $sql .= " AND e.registration_start <= '" . date('Y-m-d') . "' "; $sql .= " AND e.registration_end >= '" . date('Y-m-d') . "' "; } } else { $sql = "SELECT e.*, ese.start_time, ese.end_time FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id= e.id "; $sql .= " WHERE is_active = 'Y' "; $sql .= " AND e.event_status != 'D' "; $sql .= " AND e.event_status != 'S' "; $sql .= " AND e.event_status != 'P' "; $sql .= " AND e.event_status != 'X' "; $sql .= " AND e.event_status != 'R' "; if ($show_expired == "false") { $sql .= " AND e.start_date >= '" . date('Y-m-d') . "' "; $sql .= " AND e.registration_start <= '" . date('Y-m-d') . "' "; $sql .= " AND e.registration_end >= '" . date('Y-m-d') . "' "; } } $sql .= " GROUP BY e.id ORDER BY date(start_date), id ASC"; //Print the results of the query //echo $sql; $events_data = $wpdb->get_results($sql); $events = array(); foreach ($events_data as $event) { //Get details about the category of the event //print_r( espresso_event_category_data($event->id) ); //Print the category id for each event. $category_data = espresso_event_category_data($event->id); switch ($espresso_calendar['espresso_page_post']) { case 'P': $registration_url = get_option('siteurl') . '/?p=' . $event->post_id; break; case 'R': default: $registration_url = get_option('siteurl') . '/?page_id=' . $org_options['event_page_id'] . '®event_action=register&event_id=' . $event->id; break; } //Checkthe status of the event. If the event is expired, the link to the registration page will be deactivated. $eventArray['url'] = ''; $status = ''; //Changed 8-30-2011 by Seth /*switch (event_espresso_get_status($event->id)){ case 'NOT_ACTIVE': $status = ' - ' . __('Expired','event_espresso'); break; case 'ACTIVE': $status = ''; break; }*/ //End Seth //Gets the URL of the event and links the event to the registration form. $eventArray['url'] = $event->externalURL != '' ? htmlspecialchars_decode($event->externalURL) : $registration_url; //Id of the event $eventArray['id'] = $event->id; //Get the title of the event $eventArray['title'] = htmlspecialchars_decode(stripslashes_deep($event->event_name . $status), ENT_QUOTES); //Gets the description of the event. This can be used for hover effects such as jQuery Tooltips or QTip $eventArray['description'] = htmlspecialchars_decode(stripslashes_deep($event->event_desc), ENT_QUOTES); //Get the start and end times for each event //important! time must be in iso8601 format 2010-05-10T08:30 !! $eventArray['start'] = date("c", strtotime($event->start_date . ' ' . event_date_display($event->start_time, get_option('time_format')))); $eventArray['end'] = date("c", strtotime($event->end_date . ' ' . event_date_display($event->end_time, get_option('time_format')))); //Custom fields: //These can be used to perform special functions in your display. //This can be used to use the category id as the event type $eventArray['eventType'] = $category_data['category_name']; //Changed 8-30-2011 by Seth //This decalares the category ID as the CSS class name /*$sql_categories = 'select * from `wp_events_category_rel` where event_id='.$event->id ; $categories_data = $wpdb->get_results($sql_categories); $cssClass = $category_data['category_identifier']; foreach($categories_data as $_category){ if(isset($categoryCss[$_category->cat_id])){ $cssClass .=' '.$categoryCss[$_category->cat_id] ; continue; } $sql_cat = 'select * from `wp_events_category_detail` where id='.$_category->cat_id; $category = $wpdb->get_results($sql_cat); foreach($category as $_cat){ $cssClass .=' '.$_cat->category_identifier ; $categoryCss[$_category->cat_id] = $_cat->category_identifier; continue; } } $eventArray['className'] = $cssClass;*/ //End Seth //End custom fields //If set to true, events will be shown as all day events $eventArray['allDay'] = FALSE; //Array of the event details $events[] = $eventArray; } //Print the results of the code above //echo json_encode($events); //Start the output of the calendar ob_start(); ?> <script type="text/javascript"> $jaer = jQuery.noConflict(); jQuery(document).ready(function($jaer) { $jaer('#espresso_calendar').fullCalendar({ /** * General Display * http://arshaw.com/fullcalendar/docs/text/ **/ //month, basicWeek, basicDay, agendaWeek, agendaDay defaultView: '<?php echo $cal_view; ?> ', //Defines the buttons and title at the top of the calendar. header: { //Settings: http://arshaw.com/fullcalendar/docs/display/header/ <?php echo stripslashes_deep($espresso_calendar['espresso_calendar_header']); ?> }, /** * Theme Settings * * Once you enable theming with true, you still need to include the CSS file for the theme you want. * For example, if you just downloaded a theme from the jQuery UI Themeroller, you need to put a <link> tag in your page's <head>. **/ //Enables/disables use of jQuery UI theming. //theme: true, //Settings: http://arshaw.com/fullcalendar/docs/display/theme/ //This option only applies to calendars that have jQuery UI theming enabled with the theme option. /*buttonIcons:{ //Settings: http://arshaw.com/fullcalendar/docs/display/buttonIcons/ prev: 'circle-triangle-w', next: 'circle-triangle-e' },*/ //The day that each week begins. //The value must be a number that represents the day of the week. //Sunday=0, Monday=1, Tuesday=2, etc. firstDay:<?php echo $espresso_calendar['espresso_calendar_firstday']; ?> , //Settings: http://arshaw.com/fullcalendar/docs/display/firstDay/ //Displays the calendar in right-to-left mode. isRTL: false, //Whether to include Saturday/Sunday columns in any of the calendar views. weekends: <?php echo $espresso_calendar['espresso_calendar_weekends']; ?> , //Determines the number of weeks displayed in a month view. Also determines each week's height. weekMode:'fixed', //Settings: http://arshaw.com/fullcalendar/docs/display/weekMode/ //Will make the entire calendar (including header) a pixel height. height:<?php echo $espresso_calendar['espresso_calendar_height']; ?> , //Settings: http://arshaw.com/fullcalendar/docs/display/height/ //Will make the calendar's content area a pixel height. //contentHeight: 600, //Settings: http://arshaw.com/fullcalendar/docs/display/contentHeight/ //Determines the width-to-height aspect ratio of the calendar. //aspectRatio: 2, //Settings: http://arshaw.com/fullcalendar/docs/display/aspectRatio/ /** * Agenda Options * http://arshaw.com/fullcalendar/docs/agenda/ * Note: These ptions that apply to the agendaWeek and agendaDay views, and have beft out intentionally. * Please refer to the URL above to add.manage your agenda views. **/ /** * Text/Time Customization Settings * http://arshaw.com/fullcalendar/docs/text/ **/ //Determines the time-text that will be displayed on each event. timeFormat:{ //Settings: http://arshaw.com/fullcalendar/docs/text/timeFormat/ // for agendaWeek and agendaDay agenda: 'h:mm{ - h:mm}', // 5:00 - 6:30 // for all other views '': '' // 7p }, //Changes the colors of the events as seen here: //http://code.google.com/p/fullcalendar/issues/detail?id=6&can=1&q=css&colspec=ID%20Type%20Status%20Milestone%20Summary%20Stars eventRender: function(event, element) { //This displays the title of the event when hovering element.attr('title', event.title); //These are examples of custom parameters that can be passed /*if (event.myType == 'meeting') { element.addClass('meeting'); //alert(event.myType ); }*/ //This example basically applies different classes to the event /*switch (event.myType){ case 'meeting' : element.find('.n, .w, .c, .e, .s').css('background-color', '#00cc33'); break; case 'project' : element.find('.n, .w, .c, .e, .s').css('background-color', 'red'); break; default : break; }*/ }, //Determines the text that will be displayed on the calendar's column headings. columnFormat:{ //Settings: http://arshaw.com/fullcalendar/docs/text/columnFormat/ <?php echo stripslashes_deep($espresso_calendar['espresso_calendar_columnFormat']); ?> /*month: 'ddd', // Mon week: 'ddd M/d', // Mon 9/7 day: 'dddd M/d' // Monday 9/7*/ }, //For date formatting options, please refer to: http://arshaw.com/fullcalendar/docs/utilities/formatDate/ titleFormat:{ //Settings: http://arshaw.com/fullcalendar/docs/text/columnFormat/ <?php echo stripslashes_deep($espresso_calendar['espresso_calendar_titleFormat']); ?> /*month: 'MMMM yyyy', // September 2009 week: "MMM d[ yyyy]{ '—'[ MMM] d yyyy}", // Sep 7 - 13 2009 day: 'dddd, MMM d, yyyy' // Tuesday, Sep 8, 2009*/ }, //Text that will be displayed on buttons of the header. buttonText: { //Settings: http://arshaw.com/fullcalendar/docs/text/buttonText/ <?php echo stripslashes_deep($espresso_calendar['espresso_calendar_buttonText']); ?> /*prev: ' ◄ ', // left triangle next: ' ► ', // right triangle prevYear: ' << ', // << nextYear: ' >> ', // >> today: 'today', month: 'month', week: 'week', day: 'day'*/ }, //Full names of months. monthNames: [<?php echo stripslashes_deep($espresso_calendar['espresso_calendar_monthNames']); ?> /*'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'*/], //Abbreviated names of months. monthNamesShort: [<?php echo stripslashes_deep($espresso_calendar['espresso_calendar_monthNamesShort']); ?> /*'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'*/], //Full names of days-of-week. dayNames: [<?php echo stripslashes_deep($espresso_calendar['espresso_calendar_dayNames']); ?> /*'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'*/], //Abbreviated names of days-of-week. dayNamesShort: [<?php echo stripslashes_deep($espresso_calendar['espresso_calendar_dayNamesShort']); ?> /*'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'*/], //Load the events into json srrsy events: <?php echo json_encode($events); ?> , loading: function(bool) { if (bool) $('#loading').show(); else $jaer('#loading').hide(); } }); // this line was overriding the cal_view defined inthe shortcode //$jaer('#espresso_calendar').fullCalendar('changeView','month'); }); </script> <div id='espresso_calendar'></div> <?php $buffer = ob_get_contents(); ob_end_clean(); return $buffer; //End calendar output }
function espresso_calendar_do_stuff($show_expired) { global $wpdb, $org_options, $espresso_calendar, $event_category_id, $events, $eventsArray; //Build the SQL to run //Get the categories if ($event_category_id != "") { $type = 'cat'; $sql = "SELECT e.*, c.category_name, c.category_desc, c.display_desc, ese.start_time, ese.end_time FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id "; $sql .= " JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id "; $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id= e.id "; if (function_exists('espresso_version')) { if (espresso_version() >= '3.2.P') { // if we're using ee 3.2+, is_active is true/false $sql .= " WHERE e.is_active != false "; } else { $sql .= " WHERE e.is_active != 'N' "; } } $sql .= " AND e.event_status != 'D' "; //Deleted $sql .= " AND e.event_status != 'S' "; //Secondary/Waitlist $sql .= " AND e.event_status != 'P' "; //Pending $sql .= " AND e.event_status != 'X' "; $sql .= " AND e.event_status != 'R' "; //Draft $sql .= " AND c.category_identifier = '" . $event_category_id . "' "; if ($show_expired == "false") { $sql .= " AND start_date >= '" . date('Y-m-d') . "' "; $sql .= " AND e.registration_start <= '" . date('Y-m-d') . "' "; $sql .= " AND e.registration_end >= '" . date('Y-m-d') . "' "; } } else { //Get all events $type = 'all'; $sql = "SELECT e.*, ese.start_time, ese.end_time FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= " LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id= e.id "; if (function_exists('espresso_version')) { if (espresso_version() >= '3.2.P') { // if we're using ee 3.2+, is_active is true/false $sql .= " WHERE e.is_active != false "; } else { $sql .= " WHERE e.is_active != 'N' "; } } $sql .= " AND e.event_status != 'D' "; //Deleted $sql .= " AND e.event_status != 'S' "; //Secondary/Waitlist $sql .= " AND e.event_status != 'P' "; //Pending $sql .= " AND e.event_status != 'X' "; $sql .= " AND e.event_status != 'R' "; //Draft if ($show_expired == "false") { $sql .= " AND e.start_date >= '" . date('Y-m-d') . "' "; $sql .= " AND e.registration_start <= '" . date('Y-m-d') . "' "; $sql .= " AND e.registration_end >= '" . date('Y-m-d') . "' "; } } $sql .= " GROUP BY e.id ORDER BY date(start_date), id ASC"; //Debug //echo '<p>$sql - '.$sql.'</p>'; $events = array(); $events_data = $wpdb->get_results($sql); foreach ($events_data as $event) { //Debug: //Print the category id for each event. //print_r( espresso_event_category_data($event->id) ); //Get details about the category of the event $category_data = espresso_event_category_data($event->id); $category_data['category_meta'] = unserialize($category_data['category_meta']); //Debug: //echo "<pre>".print_r($category_data,true)."</pre>"; //Assign colors to events by category if (isset($category_data['category_meta']) && $category_data['category_meta']['use_pickers'] == 'Y') { $eventArray['color'] = $category_data['category_meta']['event_background']; $eventArray['textColor'] = $category_data['category_meta']['event_text_color']; } $event_meta = unserialize($event->event_meta); //Debug: //var_dump($event); //If the version of Event Espresso is 3.2 or older, we need to use the new permalink structure. If not, then we need to default to the structure. if (function_exists('espresso_version')) { if (espresso_version() >= '3.2.P') { switch ($espresso_calendar['espresso_page_post']) { case 'P': $registration_url = get_permalink($event->post_id); break; case 'R': default: //$registration_url = get_home_url(). '/?page_id=' . $org_options['event_page_id'] . '®event_action=register&event_id=' . $event->id; $registration_url = espresso_reg_url($event->id, $event->slug); break; } } else { switch ($espresso_calendar['espresso_page_post']) { case 'P': $registration_url = get_home_url() . '/?p=' . $event->post_id; break; case 'R': default: $registration_url = get_home_url() . '/?page_id=' . $org_options['event_page_id'] . '®event_action=register&event_id=' . $event->id; break; } } } //Checkthe status of the event. If the event is expired, the link to the registration page will be deactivated. $eventArray['url'] = ''; $status = ''; //Changed 8-30-2011 by Seth /* switch (event_espresso_get_status($event->id)){ case 'NOT_ACTIVE': $status = ' - ' . __('Expired','event_espresso'); break; case 'ACTIVE': $status = ''; break; } */ //End Seth // Build calendar array from $event data //Gets the URL of the event and links the event to the registration form. $eventArray['url'] = $event->externalURL != '' ? htmlspecialchars_decode($event->externalURL) : $registration_url; //Id of the event $eventArray['id'] = $event->id; //Get the title of the event $ee_event_title = htmlspecialchars_decode(stripslashes_deep($event->event_name . $status), ENT_QUOTES); $eventArray['title'] = $ee_event_title; //Gets the description of the event. This can be used for hover effects such as jQuery Tooltips or QTip $eventArray['description'] = espresso_format_content($event->event_desc); //Supports 3.2 short descriptions if (isset($org_options['template_settings']['display_short_description_in_event_list']) && $org_options['template_settings']['display_short_description_in_event_list'] == true) { $eventArray['description'] = array_shift(explode('<!--more-->', $eventArray['description'])); } //Supports 3.1 short descriptions if (isset($org_options['display_short_description_in_event_list']) && $org_options['display_short_description_in_event_list'] == 'Y') { $eventArray['description'] = array_shift(explode('<!--more-->', $eventArray['description'])); } //Get the start and end times for each event //important! time must be in iso8601 format 2010-05-10T08:30!! $eventArray['start'] = date("c", strtotime($event->start_date . ' ' . event_date_display($event->start_time, get_option('time_format')))); $eventArray['end'] = date("c", strtotime($event->end_date . ' ' . event_date_display($event->end_time, get_option('time_format')))); $eventArray['day'] = date("j", strtotime($event->end_date)); $eventArray['month'] = date("n", strtotime($event->end_date)); if ($eventArray['end'] < date('Y-m-d')) { $eventArray['expired'] = 'expired'; } else { $eventArray['expired'] = ''; } $eventArray['today'] = date('Y-m-d'); $eventArray['this_month'] = date('m'); $eventArray['startTime'] = event_date_display($event->start_time, $espresso_calendar['time_format']); $eventArray['endTime'] = event_date_display($event->end_time, $espresso_calendar['time_format']); // Add thumb to eventArray $eventArray['event_img_thumb'] = ''; if ($espresso_calendar['enable_calendar_thumbs'] == true) { if (isset($event_meta['event_thumbnail_url'])) { $calendar_thumb = $event_meta['event_thumbnail_url']; //Debug: //echo '<a href="' . $registration_url . '"><img class="event-id-'. $event->id . '" src="'. $calendar_thumb . '" alt="" title="' . $ee_event_title . '" / ></a>'; $eventArray['event_img_thumb'] = $calendar_thumb; } } //Custom fields: //These can be used to perform special functions in your display. //This decalares the category ID as the CSS class name $eventArray['className'] = ''; $eventArray['eventType'] = ''; if (isset($espresso_calendar['enable_cat_classes']) && $espresso_calendar['enable_cat_classes'] == true) { //Debug //var_dump($category_data); //This is the class $eventArray['className'] = $category_data['category_identifier']; //This can be used to use the category id as the event type $eventArray['eventType'] = $category_data['category_name']; } //end if user enabled cat for classes //End custom fields //If set to true, events will be shown as all day events $eventArray['allDay'] = FALSE; //Array of the event details $events[] = $eventArray; //Reset category colors $eventArray['color'] = ''; $eventArray['textColor'] = ''; } //Debug: //Print the results of the code above //echo json_encode($events); //echo '<style type="text/css">'.$category_styles.'</style>'; }