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:203414222d119d77b971
Created December 8, 2014 23:52
Insert category relations in EE4
global $wpdb;
$cat_id = 7;
$event_ids = array( 1, 2, 3, 4, 5);
foreach ($event_ids as $event_id) {
$wpdb->insert(
'wp_term_relationships',
array(
'object_id' => $event_id,
'term_taxonomy_id' => $cat_id,
'term_order' => 0
@sidharrell
sidharrell / gist:1e7a3390f74d2cbb0065
Created December 3, 2014 20:19
add venue id import to csv import, EE3
// find the first chunk, which should be lines 241-262 of includes/event-management/csv_import.php
// and add the second chunk after. You'll need to add the column to the events.csv file.
//Add category data
$category_names = explode("|", $strings[25]);
foreach ($category_names as $category_name) {
$category_name = trim($category_name);
$category_sql = "SELECT cd.id FROM " . EVENTS_CATEGORY_TABLE . " cd WHERE category_name='%s'";
$cat_id = $wpdb->get_var($wpdb->prepare($category_sql, $category_name));
@sidharrell
sidharrell / gist:c248f6905d3d139967c3
Created November 6, 2014 19:42
Volume Discount for EE3 with No Info Required on Additional Attendees
add_action('action_hook_espresso_save_attendee_data', 'apply_volume_discount_hook_function');
function apply_volume_discount_hook_function ( $attendee_data ) {
if ( !empty($attendee_data['event_meta']['VD_threshold']) &&
!empty($attendee_data['event_meta']['VD_discount']) &&
(int)$attendee_data['quantity'] >= (int)$attendee_data['event_meta']['VD_threshold'] ) {
global $wpdb;
$data = array(
'final_price' => max(array( 0, (float)$attendee_data['final_price'] - (float)$attendee_data['event_meta']['VD_discount'] ))
);
@sidharrell
sidharrell / gist:71f01924d56d460c11a4
Created October 15, 2014 18:02
replace comma tags in answers in visible (but not hidden) text
add_filter ( 'the_content', 'who_cares_about_an_oxford_comma', 11 );
function who_cares_about_an_oxford_comma ( $content ) {
$base = '#(<span.*)\{comma}(.*</span>)#';
$replace = '$1,$2';
$new_content = "";
while (($new_content = preg_replace( $base, $replace, $content )) != $content) {
$content = $new_content;
}
return $new_content;
@sidharrell
sidharrell / gist:f2007e6bf5dd7f7e67c8
Created July 31, 2014 00:30
Make custom event table template only display one category
// In plugins/espresso-custom-templates/templates/events-table/index.php on line 20, change it to:
<pre><p class="category-filter" style="display:none"><label><?php echo __('Filter by category ', 'event_espresso'); ?></label></pre>
// and at line 91 insert the code:
if ( !empty( $event->category_id ) ) {
$array_cat=explode(",",$event->category_id);
if (array_search(1,$array_cat)===FALSE) continue;
$cat=array_map(function($val) { return "cat-" . trim($val); }, $array_cat);
$cat_class = implode(" ", $cat);
} else {
continue;
@sidharrell
sidharrell / gist:0cb3086e1b71c71b9c51
Created July 14, 2014 20:33
EE4 js to make payment option auto-clicked if only one payment option available
jQuery(document).ready(function() {
jQuery('#spco-go-to-step-payment_options-btn').click(function() {
if (jQuery('.reg-page-payment-option-dv').length == 1) {
setTimeout(function(){jQuery('.reg-page-payment-option-dv').click();}, 2000);
}
});
});
@sidharrell
sidharrell / gist:f4aa5491ec2cd0db09c1
Created June 30, 2014 23:33
replacement for EE3 includes/event-management/csv_import.php in 3.1.36
<?php
function csv_import() { ?>
<h3>Event Import</h3>
<ul>
<li>
<p><?php _e('This page is for importing your events from a comma separated file (CSV) directly into the the events database. The limitation of this upload is that it does not support the extra questions, only the core event configuration.', 'event_espresso'); ?> </p>
<ul>
<li><?php _e('Please use Y where you want to say Yes and N where you want No.', 'event_espresso'); ?></li>
<li><?php _e('Dates should be formatted YYYY-MM-DD (2009-07-04).', 'event_espresso'); ?></li>
@sidharrell
sidharrell / gist:6ede29557dd068eefeb2
Last active November 30, 2016 22:01
EE4 override espresso_list_of_event_dates
function espresso_list_of_event_dates( $EVT_ID = FALSE, $dt_frmt = '', $tm_frmt = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE ) {
$dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : get_option('date_format');
$tm_frmt = ! empty( $tm_frmt ) ? $tm_frmt : get_option('time_format');
$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID ,$show_expired );
//d( $datetimes );
if ( is_array( $datetimes ) && ! empty( $datetimes )) {
global $post;
$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul">' : '';
foreach ( $datetimes as $datetime ) {
if ( $datetime instanceof EE_Datetime ) {
@sidharrell
sidharrell / 0_reuse_code.js
Created June 12, 2014 01:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sidharrell
sidharrell / gist:9de33f19f6f98794fe29
Created June 9, 2014 18:48
fix for espresso-custom-templates/templates/events-table/index.php
// replaces lines 87-93
if ($event_status == 'NOT_ACTIVE') {
$live_button = __('Closed', 'event_espresso');
$cart_link = '';
}
if ( !empty( $event->category_id ) ) {
$array_cat=explode(",",$event->category_id);
$cat=array_map(function($val) { return "cat-" . trim($val); }, $array_cat);
$cat_class = implode(" ", $cat);