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: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: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: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: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: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: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:b4368fa538fac4ee1441
Created January 25, 2015 08:19
sublime_docblockr_package_custom-1
diff --git a/php.sublime-completions b/php.sublime-completions
index 5a8432b..e6990e0 100644
--- a/php.sublime-completions
+++ b/php.sublime-completions
@@ -2,21 +2,24 @@
"scope": "source.php comment.block.documentation",
"completions":
[
+ { "trigger" : "Drupal", "contents": "Drupal"},
{ "trigger" : "@api", "contents": ""},
@sidharrell
sidharrell / gist:ac831708ae44838d5fe5
Created January 25, 2015 08:23
sublime_user_settings
{
"bold_folder_labels": true,
"caret_style": "wide",
"default_line_ending": "unix",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"find_selected_text": true,
"font_options":
[
"subpixel_antialias"
@sidharrell
sidharrell / gist:5fe35bf67e10bb118ce8
Created February 5, 2015 17:47
wp-debug to file
/**
* This will log all errors notices and warnings to a file called debug.log in
* wp-content only when WP_DEBUG is true. if Apache does not have write permission,
* you may need to create the file first and set the appropriate permissions (i.e. use 666).
*/
define( 'WP_DEBUG', true ); // Or false
if ( WP_DEBUG ) {
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@sidharrell
sidharrell / gist:8da2c256c5ab6921ddf7
Created February 6, 2015 19:21
more entropy in reg ids
//Build the registration id
function espresso_build_registration_id_custom($event_id){
remove_filter('filter_hook_espresso_registration_id', 'espresso_build_registration_id', 10, 1);
return uniqid($event_id . '-', true);
}
//Registration id filter
add_filter('filter_hook_espresso_registration_id', 'espresso_build_registration_id_custom', 8, 1);