function dbem_replace_placeholders($format, $event, $target = "html") { $event_string = $format; preg_match_all("/#@?_?[A-Za-z0-9]+/", $format, $placeholders); foreach ($placeholders[0] as $result) { // echo "RESULT: $result <br>"; // matches alla fields placeholder //TODO CUSTOM FIX FOR Brian // EVENTUALLY REMOVE if (preg_match('/#_JCCSTARTTIME/', $result)) { $time = substr($event['event_start_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } // END of REMOVE if (preg_match('/#_24HSTARTTIME/', $result)) { $time = substr($event['event_start_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_24HENDTIME/', $result)) { $time = substr($event['event_end_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_12HSTARTTIME/', $result)) { $AMorPM = "AM"; $hour = substr($event['event_start_time'], 0, 2); $minute = substr($event['event_start_time'], 3, 2); if ($hour > 12) { $hour = $hour - 12; $AMorPM = "PM"; } $time = "{$hour}:{$minute} {$AMorPM}"; $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_12HENDTIME/', $result)) { $AMorPM = "AM"; $hour = substr($event['event_end_time'], 0, 2); $minute = substr($event['event_end_time'], 3, 2); if ($hour > 12) { $hour = $hour - 12; $AMorPM = "PM"; } $time = "{$hour}:{$minute} {$AMorPM}"; $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_MAP/', $result)) { $location = dbem_get_location($event['location_id']); $map_div = dbem_single_location_map($location); $event_string = str_replace($result, $map_div, $event_string); } if (preg_match('/#_ADDBOOKINGFORM/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $rsvp_add_module .= dbem_add_booking_form(); } else { $rsvp_add_module .= ""; } $event_string = str_replace($result, $rsvp_add_module, $event_string); } if (preg_match('/#_REMOVEBOOKINGFORM/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $rsvp_delete_module .= dbem_delete_booking_form(); } else { $rsvp_delete_module .= ""; } $event_string = str_replace($result, $rsvp_delete_module, $event_string); } if (preg_match('/#_AVAILABLESEATS/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $availble_seats .= dbem_get_available_seats($event['event_id']); } else { $availble_seats .= ""; } $event_string = str_replace($result, $availble_seats, $event_string); } if (preg_match('/#_LINKEDNAME/', $result)) { $events_page_id = get_option('dbem_events_page'); $event_page_link = get_permalink($events_page_id); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, "<a href='" . get_permalink($events_page_id) . $joiner . "event_id=" . $event['event_id'] . "' title='" . $event['event_name'] . "'>" . $event['event_name'] . "</a>", $event_string); } if (preg_match('/#_EVENTPAGEURL/', $result)) { $events_page_id = get_option('dbem_events_page'); $event_page_link = get_permalink($events_page_id); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, get_permalink($events_page_id) . $joiner . "event_id=" . $event['event_id'], $event_string); } if (preg_match('/#_(NAME|NOTES|SEATS)/', $result)) { $field = "event_" . ltrim(strtolower($result), "#_"); $field_value = $event[$field]; if ($field == "event_notes") { if ($target == "html") { $field_value = apply_filters('dbem_notes', $field_value); } else { if ($target == "map") { $field_value = apply_filters('dbem_notes_map', $field_value); } else { $field_value = apply_filters('dbem_notes_rss', $field_value); } } } else { if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_(ADDRESS|TOWN|PROVINCE)/', $result)) { $field = "location_" . ltrim(strtolower($result), "#_"); $field_value = $event[$field]; if ($field == "event_notes") { if ($target == "html") { $field_value = apply_filters('dbem_notes', $field_value); } else { if ($target == "map") { $field_value = apply_filters('dbem_notes_map', $field_value); } else { $field_value = apply_filters('dbem_notes_rss', $field_value); } } } else { if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_(LOCATION)$/', $result)) { $field = "location_name"; $field_value = $event[$field]; if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_CONTACTNAME$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $name = dbem_get_user_name($user_id); $event_string = str_replace($result, $name, $event_string); } if (preg_match('/#_CONTACTEMAIL$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $email = dbem_get_user_email($user_id); $event_string = str_replace($result, dbem_ascii_encode($email), $event_string); } if (preg_match('/#_CONTACTPHONE$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $phone = dbem_get_user_phone($user_id); $event_string = str_replace($result, dbem_ascii_encode($phone), $event_string); } if (preg_match('/#_(IMAGE)/', $result)) { if ($event['location_image_url'] != '') { $location_image = "<img src='" . $event['location_image_url'] . "' alt='" . $event['location_name'] . "'/>"; } else { $location_image = ""; } $event_string = str_replace($result, $location_image, $event_string); } if (preg_match('/#_(LOCATIONPAGEURL)/', $result)) { $events_page_link = dbem_get_events_page(true, false); if (stristr($events_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $venue_page_link = $events_page_link . $joiner . "location_id=" . $event['location_id']; $event_string = str_replace($result, $venue_page_link, $event_string); } // matches all PHP time placeholders for endtime if (preg_match('/^#@[dDjlNSwzWFmMntLoYy]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#@"), $event['event_end_date']), $event_string); } // matches all PHP date placeholders if (preg_match('/^#[dDjlNSwzWFmMntLoYy]$/', $result)) { // echo "-inizio-"; $event_string = str_replace($result, mysql2date(ltrim($result, "#"), $event['event_start_date']), $event_string); // echo $event_string; } // matches all PHP time placeholders if (preg_match('/^#@[aABgGhHisueIOPTZcrU]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#@"), "0000-00-00 " . $event['event_end_time']), $event_string); // echo $event_string; } if (preg_match('/^#[aABgGhHisueIOPTZcrU]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#"), "0000-00-00 " . $event['event_start_time']), $event_string); // echo $event_string; } /* Marcus/ROR Begin Edit*/ //Add a placeholder for categories if (preg_match('/#_CATEGORY$/', $result)) { $category = dbem_get_event_category($event['event_id']); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, "<a href='" . get_permalink($events_page_id) . $joiner . "category=" . $category['category_id'] . "' title='" . $category['category_name'] . "'>" . $category['category_name'] . "</a>", $event_string); } /* Marcus/ROR End Edit */ } /* Marcus Begin Edit */ preg_match_all("/#@?_\\{[A-Za-z0-9 -\\/,\\.\\\\]+\\}/", $format, $placeholders); foreach ($placeholders[0] as $result) { if (substr($result, 0, 3) == "#@_") { $date = 'event_end_date'; $offset = 4; } else { $date = 'event_start_date'; $offset = 3; } $event_string = str_replace($result, mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $event[$date]), $event_string); } /* Marcus End Edit */ return $event_string; }
function dbem_get_event($event_id) { global $wpdb; $events_table = $wpdb->prefix . EVENTS_TBNAME; $sql = "SELECT event_id, \n\t\t\t \tevent_name, \n\t\t \t \tDATE_FORMAT(event_start_date, '%Y-%m-%e') AS 'event_date', \n\t\t\t\t\tDATE_FORMAT(event_start_date, '%e') AS 'event_day', \n\t\t\t\t\tDATE_FORMAT(event_start_date, '%m') AS 'event_month',\n\t\t\t\t\tDATE_FORMAT(event_start_date, '%Y') AS 'event_year',\n\t\t\t \tDATE_FORMAT(event_start_time, '%k') AS 'event_hh',\n\t\t\t \tDATE_FORMAT(event_start_time, '%i') AS 'event_mm',\n\t\t\tDATE_FORMAT(event_start_time, '%h:%i%p') AS 'event_start_12h_time', \n\t\t\tDATE_FORMAT(event_start_time, '%H:%i') AS 'event_start_24h_time', \n\t\t\t DATE_FORMAT(event_end_time, '%Y-%m-%e') AS 'event_end_date', \n\t\t\t\t\tDATE_FORMAT(event_end_time, '%e') AS 'event_end_day', \n\t\t\t\t\tDATE_FORMAT(event_end_time, '%m') AS 'event_end_month', \n\t\t \t\tDATE_FORMAT(event_end_time, '%Y') AS 'event_end_year',\n\t\t \t\tDATE_FORMAT(event_end_time, '%k') AS 'event_end_hh',\n\t\t \t\tDATE_FORMAT(event_end_time, '%i') AS 'event_end_mm',\n\t\t\t\tDATE_FORMAT(event_end_time, '%h:%i%p') AS 'event_end_12h_time', \n\t\t\t\tDATE_FORMAT(event_end_time, '%H:%i') AS 'event_end_24h_time', \n\t\t event_start_date,\n\t\t\t\t\tevent_end_date,\n\t\t\t\t\tevent_start_time,\n\t\t\t \tevent_end_time,\n\t\t\t\t\tevent_notes,\n\t\t\t\t\tevent_rsvp,\n\t\t\t\t\tevent_seats,\n\t\t\t\t\trecurrence_id, \n\t\t\t\t\tlocation_id,\n\t\t\t\t\tevent_contactperson_id\n\t\t\t\tFROM {$events_table} \n\t\t\t WHERE event_id = {$event_id}"; //$wpdb->show_errors(true); $event = $wpdb->get_row($sql, ARRAY_A); //$wpdb->print_error(); $location = dbem_get_location($event['location_id']); $event['location_name'] = $location['location_name']; $event['location_address'] = $location['location_address']; $event['location_town'] = $location['location_town']; $event['location_latitude'] = $location['location_latitude']; $event['location_longitude'] = $location['location_longitude']; $event['location_image_url'] = $location['location_image_url']; return $event; }
function dbem_insert_location($location) { global $wpdb; $table_name = $wpdb->prefix . LOCATIONS_TBNAME; // if GMap is off the hidden fields are empty, so I add a custom value to make the query work if (empty($location['location_longitude'])) { $location['location_longitude'] = 0; } if (empty($location['location_latitude'])) { $location['location_latitude'] = 0; } $sql = "INSERT INTO " . $table_name . " (location_name, location_address, location_town, location_latitude, location_longitude, location_description)\n\t\tVALUES ('" . $location['location_name'] . "','" . $location['location_address'] . "','" . $location['location_town'] . "'," . $location['location_latitude'] . "," . $location['location_longitude'] . ",'" . $location['location_description'] . "')"; $wpdb->query($sql); $new_location = dbem_get_location(mysql_insert_id()); return $new_location; }
function dbem_get_recurrence($recurrence_id) { global $wpdb; $recurrence_table = $wpdb->prefix . RECURRENCE_TBNAME; $sql = "SELECT *,\n\t\t\t\t\t\t\t\tDATE_FORMAT(recurrence_start_time, '%k') AS 'recurrence_hh',\n\t\t\t\t\t\t \tDATE_FORMAT(recurrence_start_time, '%i') AS 'recurrence_mm',\n\t\t\t\t\t\t\t\tDATE_FORMAT(recurrence_start_time, '%h:%i%p') AS 'recurrence_start_12h_time', \n\t\t\t\t\t\t\t\tDATE_FORMAT(recurrence_start_time, '%H:%i') AS 'recurrence_start_24h_time', \n\t\t\t\t\t\t DATE_FORMAT(recurrence_end_time, '%Y-%m-%e') AS 'end_date', \n\t\t\t\t\t\t\t\tDATE_FORMAT(recurrence_end_time, '%k') AS 'recurrence_end_hh',\n\t\t\t\t\t \t\tDATE_FORMAT(recurrence_end_time, '%i') AS 'recurrence_end_mm',\n\t\t\t\t\t \t\t\tDATE_FORMAT(recurrence_end_time, '%h:%i%p') AS 'recurrence_end_12h_time', \n\t\t\t\t\t\t\t\tDATE_FORMAT(recurrence_end_time, '%H:%i') AS 'recurrence_end_24h_time'\n\t FROM {$recurrence_table} WHERE recurrence_id = {$recurrence_id};"; $recurrence = $wpdb->get_row($sql, ARRAY_A); $location = dbem_get_location($recurrence['location_id']); $recurrence['location_name'] = $location['location_name']; $recurrence['location_address'] = $location['location_address']; $recurrence['location_town'] = $location['location_town']; $recurrence['recurrence_description'] = dbem_build_recurrence_description($recurrence); return $recurrence; }
<?php $location = dbem_get_location($_REQUEST['location_id']); ?> <table id="events-table"> <col id="col120" /> <col id="col190" /> <thead> <tr> <th colspan="3"><?php echo $location['location_name']; ?> </th> </tr> </thead> <tbody> <tr> <th class="text-left">Date</th> <th class="text-left">Time</th> <th class="text-left">Name</th> </tr> <?php echo dbem_events_in_location_list($location); ?> </tbody> </table> <pre> <?php echo dbem_single_location_map($location);
function dbem_replace_placeholders($format, $event, $target = "html") { $event_string = $format; preg_match_all("/#@?_?[A-Za-z0-9]+/", $format, $placeholders); foreach ($placeholders[0] as $result) { // echo "RESULT: $result <br>"; // matches alla fields placeholder //TODO CUSTOM FIX FOR Brian // EVENTUALLY REMOVE if (preg_match('/#_JCCSTARTTIME/', $result)) { $time = substr($event['event_start_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } // END of REMOVE if (preg_match('/#_24HSTARTTIME/', $result)) { $time = substr($event['event_start_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_24HENDTIME/', $result)) { $time = substr($event['event_end_time'], 0, 5); $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_12HSTARTTIME/', $result)) { $AMorPM = "AM"; $hour = substr($event['event_start_time'], 0, 2); $minute = substr($event['event_start_time'], 3, 2); if ($hour > 12) { $hour = $hour - 12; $AMorPM = "PM"; } $time = "{$hour}:{$minute} {$AMorPM}"; $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_12HENDTIME/', $result)) { $AMorPM = "AM"; $hour = substr($event['event_end_time'], 0, 2); $minute = substr($event['event_end_time'], 3, 2); if ($hour > 12) { $hour = $hour - 12; $AMorPM = "PM"; } $time = "{$hour}:{$minute} {$AMorPM}"; $event_string = str_replace($result, $time, $event_string); } if (preg_match('/#_MAP/', $result)) { $location = dbem_get_location($event['location_id']); $map_div = dbem_single_location_map($location); $event_string = str_replace($result, $map_div, $event_string); } if (preg_match('/#_ADDBOOKINGFORM/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $rsvp_add_module .= dbem_add_booking_form(); } else { $rsvp_add_module .= ""; } $event_string = str_replace($result, $rsvp_add_module, $event_string); } if (preg_match('/#_REMOVEBOOKINGFORM/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $rsvp_delete_module .= dbem_delete_booking_form(); } else { $rsvp_delete_module .= ""; } $event_string = str_replace($result, $rsvp_delete_module, $event_string); } if (preg_match('/#_AVAILABLESEATS/', $result)) { $rsvp_is_active = get_option('dbem_gmap_is_active'); if ($event['event_rsvp']) { $availble_seats .= dbem_get_available_seats($event['event_id']); } else { $availble_seats .= ""; } $event_string = str_replace($result, $availble_seats, $event_string); } if (preg_match('/#_LINKEDNAME/', $result)) { $events_page_id = get_option('dbem_events_page'); $event_page_link = get_permalink($events_page_id); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, "<a href='" . get_permalink($events_page_id) . $joiner . "event_id=" . $event['event_id'] . "' title='" . $event['event_name'] . "'>" . $event['event_name'] . "</a>", $event_string); } if (preg_match('/#_EVENTPAGEURL(\\[(.+\\)]))?/', $result)) { $events_page_id = get_option('dbem_events_page'); if (stristr($event_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $event_string = str_replace($result, get_permalink($events_page_id) . $joiner . "event_id=" . $event['event_id'], $event_string); } if (preg_match('/#_(NAME|NOTES|SEATS|EXCERPT)/', $result)) { $field = "event_" . ltrim(strtolower($result), "#_"); $field_value = $event[$field]; if ($field == "event_notes" || $field == "event_excerpt") { /* Marcus Begin Edit */ if ($target == "html") { //If excerpt, we use more link text if ($field == "event_excerpt") { $matches = explode('<!--more-->', $event['event_notes']); $field_value = $matches[0]; $field_value = apply_filters('dbem_notes_excerpt', $field_value); } else { $field_value = apply_filters('dbem_notes', $field_value); } //$field_value = apply_filters('the_content', $field_value); - chucks a wobbly if we do this. } else { if ($target == "map") { $field_value = apply_filters('dbem_notes_map', $field_value); } else { if ($field == "event_excerpt") { $matches = explode('<!--more-->', $event['event_notes']); $field_value = htmlentities($matches[0]); $field_value = apply_filters('dbem_notes_rss', $field_value); } else { $field_value = apply_filters('dbem_notes_rss', $field_value); } $field_value = apply_filters('the_content_rss', $field_value); } } /* Marcus End Edit */ } else { if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_(ADDRESS|TOWN|PROVINCE)/', $result)) { $field = "location_" . ltrim(strtolower($result), "#_"); $field_value = $event[$field]; if ($field == "event_notes") { if ($target == "html") { $field_value = apply_filters('dbem_notes', $field_value); } else { if ($target == "map") { $field_value = apply_filters('dbem_notes_map', $field_value); } else { $field_value = apply_filters('dbem_notes_rss', $field_value); } } } else { if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_(LOCATION)$/', $result)) { $field = "location_name"; $field_value = $event[$field]; if ($target == "html") { $field_value = apply_filters('dbem_general', $field_value); } else { $field_value = apply_filters('dbem_general_rss', $field_value); } $event_string = str_replace($result, $field_value, $event_string); } if (preg_match('/#_CONTACTNAME$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $name = dbem_get_user_name($user_id); $event_string = str_replace($result, $name, $event_string); } if (preg_match('/#_CONTACTEMAIL$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $email = dbem_get_user_email($user_id); $event_string = str_replace($result, dbem_ascii_encode($email), $event_string); } if (preg_match('/#_CONTACTPHONE$/', $result)) { $event['event_contactperson_id'] ? $user_id = $event['event_contactperson_id'] : ($user_id = get_option('dbem_default_contact_person')); $phone = dbem_get_user_phone($user_id); $event_string = str_replace($result, dbem_ascii_encode($phone), $event_string); } if (preg_match('/#_(IMAGE)/', $result)) { if ($event['location_image_url'] != '') { $location_image = "<img src='" . $event['location_image_url'] . "' alt='" . $event['location_name'] . "'/>"; } else { $location_image = ""; } $event_string = str_replace($result, $location_image, $event_string); } if (preg_match('/#_(LOCATIONPAGEURL)/', $result)) { $events_page_link = dbem_get_events_page(true, false); if (stristr($events_page_link, "?")) { $joiner = "&"; } else { $joiner = "?"; } $venue_page_link = $events_page_link . $joiner . "location_id=" . $event['location_id']; $event_string = str_replace($result, $venue_page_link, $event_string); } // matches all PHP time placeholders for endtime if (preg_match('/^#@[dDjlNSwzWFmMntLoYy]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#@"), $event['event_end_date']), $event_string); } // matches all PHP date placeholders if (preg_match('/^#[dDjlNSwzWFmMntLoYy]$/', $result)) { // echo "-inizio-"; $event_string = str_replace($result, mysql2date(ltrim($result, "#"), $event['event_start_date']), $event_string); // echo $event_string; } // matches all PHP time placeholders if (preg_match('/^#@[aABgGhHisueIOPTZcrU]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#@"), "2000-10-10 " . $event['event_end_time']), $event_string); // echo $event_string; } if (preg_match('/^#[aABgGhHisueIOPTZcrU]$/', $result)) { $event_string = str_replace($result, mysql2date(ltrim($result, "#"), "2000-10-10 " . $event['event_start_time']), $event_string); //echo $event['event_start_time']; //echo mysql2date('h:i A', '2010-10-10 23:35:00')."<br/>"; // echo $event_string; } /* Marcus Begin Edit*/ //Add a placeholder for categories if (preg_match('/^#_CATEGORY$/', $result)) { $category = dbem_get_event_category($event['event_id']); $event_string = str_replace($result, $category['category_name'], $event_string); } /* Marcus End Edit */ } /* Marcus Begin Edit */ preg_match_all("/#@?_\\{[A-Za-z0-9 -\\/,\\.\\\\]+\\}/", $format, $results); foreach ($results[0] as $result) { if (substr($result, 0, 3) == "#@_") { $date = 'event_end_date'; $offset = 4; } else { $date = 'event_start_date'; $offset = 3; } if ($date == 'event_end_date' && $event[$date] == $event['event_start_date']) { $event_string = str_replace($result, '', $event_string); } else { $event_string = str_replace($result, mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $event[$date]), $event_string); } } /* Marcus End Edit */ /* Marcus Begin Edit */ //This is for the custom attributes preg_match_all("/#_ATT\\{.+?\\}(\\{.+?\\})?/", $format, $results); foreach ($results[0] as $resultKey => $result) { //Strip string of placeholder and just leave the reference $attRef = substr(substr($result, 0, strpos($result, '}')), 6); $attString = $event['event_attributes'][$attRef]; if (trim($attString) == '' && $results[1][$resultKey] != '') { //Check to see if we have a second set of braces; $attString = substr($results[1][$resultKey], 1, strlen(trim($results[1][$resultKey])) - 2); } $event_string = str_replace($result, $attString, $event_string); } /* Marcus End Edit */ return $event_string; }