Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Created October 25, 2013 18:07
Show Gist options
  • Select an option

  • Save sidharrell/7159162 to your computer and use it in GitHub Desktop.

Select an option

Save sidharrell/7159162 to your computer and use it in GitHub Desktop.
modifications to show_cat_event_date_max shortcode functions
/*
This is an update to the function in uploads/espresso/custom_shortcodes.php
*/
function show_cat_event_date_max($atts) {
extract(shortcode_atts(array('max_days' => 'No Date Supplied',
'event_category_id' => __('No Category ID Supplied','event_espresso'),
'show_deleted' => false), $atts));
$max_days = "{$max_days}";
$event_category_id = "{$event_category_id}";
$show_deleted = $show_deleted == "true" ? true : false;
ob_start();
display_event_espresso_cat_date_max($max_days, $event_category_id, $show_deleted);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
add_shortcode('EVENT_CAT_DATE_MAX_DAYS', 'show_cat_event_date_max');
/*
This is an update to the function in uploads/espresso/templates/event_list_table.php
*/
function display_event_espresso_cat_date_max($max_days="null", $event_category_id="null", $show_deleted=false){
global $wpdb;
//$org_options = get_option('events_organization_settings');
//$event_page_id =$org_options['event_page_id'];
if ($max_days != "null" && $event_category_id != "null" ){
if ($_REQUEST['show_date_max'] == '1'){
foreach ($_REQUEST as $k=>$v) $$k=$v;
}
//testing if we got the cat and day filters (it works)
//echo $event_category_id;
//echo $max_days;
$max_days = $max_days;
$sql = "SELECT e.*, c.category_name, c.category_desc, c.display_desc, ese.start_time FROM ". EVENTS_DETAIL_TABLE . " e
JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id
JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id
JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id
WHERE ADDDATE('".date ( 'Y-m-d' )."', INTERVAL ".$max_days." DAY) >= e.start_date AND e.start_date >= '".date ( 'Y-m-d' )."'
AND e.is_active = 'Y'";
if (!$show_deleted) $sql .= " AND e.event_status != 'D'";
$sql .= " AND c.category_identifier = '" . $event_category_id . "'
ORDER BY date(e.start_date), ese.start_time";
event_espresso_get_event_list_table($sql);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment