Skip to content

Instantly share code, notes, and snippets.

@joshfeck
joshfeck / 0_reuse_code.js
Created January 27, 2014 21:02
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
<?php
//* Do NOT include the opening php tag
//* Load Lato and Merriweather Google fonts
add_action( 'wp_enqueue_scripts', 'bg_load_google_fonts' );
function bg_load_google_fonts() {
wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,700|Merriweather:300,700', array(), CHILD_THEME_VERSION );
}
// Add this section to the end of gateways/invoice/init.php
// This is for the thank you page
if (!empty($_REQUEST['type']) && $_REQUEST['type'] == 'invoice') {
event_espresso_require_gateway("invoice/invoice_ipn.php");
add_filter('filter_hook_espresso_transactions_get_attendee_id', 'espresso_transactions_invoice_get_attendee_id');
add_filter('filter_hook_espresso_thank_you_get_payment_data', 'espresso_process_invoice');
}
@joshfeck
joshfeck / espresso_create_wp_user.php
Last active August 29, 2015 14:08 — forked from Pebblo/espresso_create_wp_user.php
Adds a new user account and sends a new user email after registering for an event. Requires EE3 and its WP user integration add-on.
<?php
add_action('action_hook_espresso_save_attendee_data','espresso_create_wp_user', 10, 1);
function espresso_create_wp_user($attendee_data) {
if( email_exists( $attendee_data['email'] ) == NULL ) {
global $org_options;
// Generate the password and create the user
$password = wp_generate_password( 12, false );
$user_id = wp_create_user( $attendee_data['email'], $password, $attendee_data['email'] );
<?php
/*
Plugin Name: Custom Post Type Plugin
Description: Properties Custom Post Type.
*/
/*
* Creating a function to create our CPT
*/
@joshfeck
joshfeck / next-previous.php
Last active October 18, 2016 15:25 — forked from lorenzocaum/new_gist_file.md
Add a previous event and next event link to the end of the single event pages in Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
//* Add a previous event and next event link to single event pages in Event Espresso 4
function ee_previous_event_next_event_navigation(){
?>
<div class="ee-after-event-navigation ee-clearfix">
<div class="ee-after-event-navigation-previous" style="float:left"><?php previous_post_link('&laquo; %link', 'Previous Event: %title'); ?></div>
<div class="ee-after-event-navigation-next" style="float:right"><?php next_post_link('%link &raquo; ', 'Next Event: %title'); ?></div>
</div>
@joshfeck
joshfeck / add_location_to_calendar_event.php
Created January 19, 2017 22:00
Adds the event location to the EE4 calendar event. Requires EE4.
function jv_ee_add_location_to_calendar_event( $text, $datetime, $event ) {
if ( $event instanceof EE_Event ) {
$venue = $event->get_first_related( 'Venue' );
if ( $venue instanceof EE_Venue ) {
$venue_name = $venue->name();
$text .= '<span>Location: ' . $venue_name . '</span>';
}
}
return $text;
}
@joshfeck
joshfeck / example.php
Last active February 2, 2017 01:35 — forked from Pebblo/example.php
How to filter the 'Event Cart' text to use something else in its place, in this example just 'Cart'
<?php //Please do not include the opening PHP tag if you already have one.
function tw_ee_return_cart() {
return 'Cart';
}
add_filter( 'FHEE__EED_Multi_Event_Registration__set_definitions__event_cart_name', 'tw_ee_return_cart' );
// also filter the empty cart message:
function my_ee_cart_is_empty() {
@joshfeck
joshfeck / functions.php
Last active October 16, 2017 03:29 — forked from Pebblo/functions.php
Add a ninja form to a Sold out Event Espresso 4 event. This is useful if you want to capture names and contact info from people that want to be signed up for a waiting list.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// Display a contact form when the event is sold out
// to be used as a waiting list
function ee_espresso_clean_event_status( $event ) {
$status = $event instanceof EE_Event ? $event->get_active_status() : 'inactive';
return $status;
}
@joshfeck
joshfeck / csv_transaction.php
Last active February 8, 2018 22:09 — forked from Pebblo/csv_transaction.php
add a column to the Event Espresso 4 Registrations CSV report that displays the total tax amount for the transaction
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'espresso_add_total_taxes_column', 10, 2);
function espresso_add_total_taxes_column( $reg_csv_array, $reg_row ) {
$registration = EEM_Registration::instance()->get_one_by_ID( $reg_row['Registration.REG_ID'] );
$sub_line_item_details = array();
if( $registration instanceof EE_Registration && $registration->is_primary_registrant() ) {
$sub_line_items = EEM_Line_Item::instance()->get_all(
array(