Skip to content

Instantly share code, notes, and snippets.

View sidharrell's full-sized avatar

Sidney Harrell sidharrell

  • Vivian-Harrell Web Development Studios, LLC
  • Harpers Ferry, WV, United States
View GitHub Profile
@sidharrell
sidharrell / gist:8738915
Last active August 29, 2015 13:55
patch for non-standard date formats with php >= 5.3
function espresso_ical_prepare_by_meta($meta, $title = '', $image = '', $link_only = FALSE) {
global $org_options, $wpdb;
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
if ( !empty($org_options['display_ical_download']) && $org_options['display_ical_download'] == 'N' || !isset($org_options['display_ical_download']) ){
return;
}
$start_date_object = DateTime::createFromFormat(get_option('date_format').' G:i', $meta['start_date'] . ' ' . $meta['start_time']);
$start_date = !empty($start_date_object) ? $start_date_object->getTimestamp() : '';
$end_date_object = DateTime::createFromFormat(get_option('date_format').' G:i', $meta['end_date'] . ' ' . $meta['end_time']);
$end_date = !empty($end_date_object) ? $end_date_object->getTimestamp() : '';
@sidharrell
sidharrell / gist:8811078
Created February 4, 2014 19:54
Add a price selector for the add new attendee in the admin
// unfortunately, the function does not currently have a pluggable function wrapper,
// so the best course of action right now is to add the pluggable function wrapper in core,
// then add the overriding function into a custom function holding location.
// so in includes/admin-reports/add_new_attendees.php add this as line 2:
if (!function_exists('add_new_attendee')) {
// then add the closing brace at the end of the file:
}
// that way, whenever the client updates and loses the custom functionality, all you need to do is
// add the pluggable function wrapper back in. And in a future update, we will probably add the
// pluggable function wrapper in.
@sidharrell
sidharrell / template.php
Last active August 29, 2015 13:56
Event Espresso invoice template including surcharge/VAT support. This file should go in your /wp-content/uploads/espresso/gateways/invoice directory.
<?php
/*Custom Log Function Include*/
// require('log.php');
/*End Custom Log Function Include*/
if (isset($_SESSION['espresso_session']['id'])) {
unset($_SESSION['espresso_session']['id']);
}
define('FPDF_FONTPATH', EVENT_ESPRESSO_PLUGINFULLPATH . 'class/fpdf/font/');
require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'class/fpdf/fpdf.php';
@sidharrell
sidharrell / gist:8925324
Created February 10, 2014 22:13
function to return display of all event times
function espresso_display_all_event_times($event_id) {
global $wpdb;
$sql = "SELECT ese.start_time, ese.end_time ";
$sql .= "FROM " . EVENTS_START_END_TABLE . " ese WHERE ese.event_id = %d";
$times = $wpdb->get_results($wpdb->prepare($sql, $event_id));
if(empty($times)) return NULL;
$time_format = get_option('time_format');
$output = "<p>";
foreach ($times as $time) {
$output .= "<span>" . event_date_display($time->start_time, $time_format) . " - " . event_date_display($time->end_time, $time_format) . "</span>";
@sidharrell
sidharrell / gist:8994796
Created February 14, 2014 02:30
add email newsletter filter (is being added in 3.1.38)
//this goes in includes/admin-files/event_newsletter.php at line 49 (approx)
<li>
<select name="filter">
<option value="all"><?php _e("All attendees of this event", "event_espresso"); ?></opton>
<option value="completed"><?php _e("Completed payment status attendees", "event_espresso"); ?></opton>
<option value="incomplete"><?php _e("Incomplete payment status attendees", "event_espresso"); ?></opton>
<option value="pending"><?php _e("Pending payment status attendees", "event_espresso"); ?></opton>
</select>
</li>
@sidharrell
sidharrell / gist:9012261
Created February 15, 2014 00:09
improved attendee report with totals
function espresso_chart_display($event_id, $type){
global $wpdb, $org_options;
$retVAl = array();
switch ($type){
case 'total_reg':
//Total Registrations/Transactions
$title = __('Total Registrations/Transactions', 'event_espresso');
$sql = "SELECT SUM(a.total_cost) amount, SUM(a.quantity) quantity, DATE_FORMAT(a.date,'%b %d') date FROM ".EVENTS_ATTENDEE_TABLE." a WHERE event_id =".$event_id." GROUP BY DATE_FORMAT(a.date,'%m-%d-%Y')";
$sql2 = "SELECT SUM(a.total_cost) amount, SUM(a.quantity) quantity, 'total' as date FROM ".EVENTS_ATTENDEE_TABLE." a WHERE event_id =".$event_id;
break;
@sidharrell
sidharrell / gist:9129062
Created February 21, 2014 05:02
select box card type
// insert at line 70 of gateways/aim/aim_vars.php
// copy aim folder from plugins/event-espresso/gateways to uploads/espresso/gateways first
<p>
<label for="card-type">Card Card Type</label>
<select id="ppp_card-type" name="creditcardtype" class="wide required">
<option value="Visa">Visa</option><option value="MasterCard">MasterCard</option><option value="Discover">Discover</option>
</select>
</p>
@sidharrell
sidharrell / gist:9194830
Last active August 29, 2015 13:56
override ESPRESSO_REG_FORM shortcode function as patch to no price, time selector on CPT single event template
function espresso_reg_form_sc($atts) {
wp_enqueue_script('validation'); //This tells the plugin to load the required scripts
extract(shortcode_atts(array('event_id' => '0'), $atts));
$event_id = "{$event_id}";
ob_start();
register_attendees(NULL, $event_id, false);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
@sidharrell
sidharrell / gist:9280456
Created February 28, 2014 21:38
add featured image support to event posts
// in includes/event-management/insert_event.php, put this in after
// $post_id = wp_insert_post($my_post);
// which is line 508 in 3.1.36.4.P
$event_thumbnail_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM $wpdb->posts WHERE guid = '%s'", $event_thumbnail_url));
if (!empty($event_thumbnail_id)) {
$wpdb->update( $wpdb->posts, array('post_parent' => $post_id), array('id' => $event_thumbnail_id));
add_post_meta($post_id, '_thumbnail_id', $event_thumbnail_id);
}
// and in includes/event-management/update_event.php, put this in after
@sidharrell
sidharrell / gist:8f1ce590f7717fd6e905
Created May 26, 2014 18:37
EE4 Modified template content-espresso_events-datetimes.php
<?php
//echo '<br/><h6 style="color:#2EA2CC;">'. __FILE__ . ' &nbsp; <span style="font-weight:normal;color:#E76700"> Line #: ' . __LINE__ . '</span></h6>';
if ( is_single() || is_archive() && espresso_display_datetimes_in_event_list() ) :
global $post;
do_action( 'AHEE_event_details_before_event_date', $post );
?>
<div class="event-datetimes">
<h3 class="event-datetimes-h3 ee-event-h3">
<span class="dashicons dashicons-calendar"></span><?php _e( 'Upcoming Date(s) and Time(s)', 'event_espresso' ); ?>