Skip to content

Instantly share code, notes, and snippets.

View lorenzocaum's full-sized avatar

Lorenzo Orlando Caum lorenzocaum

View GitHub Profile
@joshfeck
joshfeck / events_venue.php
Last active February 26, 2018 23:58
List of upcoming events for a venue. Requires Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_list_upcoming_events_for_a_venue( $post ) {
// query the events for this venue using EE_Venue's events() method
$query_params = array(
'order_by' => 'Datetime.DTT_EVT_start',
'order' => 'ASC',
array(
'status' => 'publish',
@joshfeck
joshfeck / ee_meta_for_ee4.php
Created December 5, 2014 03:44
A little helper function for EE4 to use the old EE_META shortcode from EE3 on an event custom post. Idea from http://eventespresso.com/topic/how-to-use-ee_meta-in-event-expresso-4-for-backwards-compatibility/
function display_custom_meta_in_ee4( $atts ){
global $post;
extract( shortcode_atts( array( 'type' => '', 'name' => '' ), $atts ) );
$post_meta = get_post_meta( $post->ID, $name, TRUE );
return $post_meta;
}
add_shortcode( 'EE_META', 'display_custom_meta_in_ee4' );
@joshfeck
joshfeck / modify_permissions.php
Last active August 29, 2015 14:11
Allows any event editor set up with the EE3 Roles and Permission plugin to be able to use any questions in the system.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
//remove r&P question group filter so any event editor has all the questions:
add_action( 'init', 'ee3_modify_permissions_questions' );
function ee3_modify_permissions_questions() {
remove_filter('espresso_get_question_groups_for_event_where', 'espresso_rp_basic_get_question_groups_for_event_where', 10, 3);
}
@nerrad
nerrad / filter-events-to-posts.php
Last active August 29, 2015 14:13
Filter for injecting Event Espresso event post type events into everywhere posts are queried in WP
<?php
/**
* This is an alternative filter for adding events to posts.
*
* 1. Adds events to ANY query for posts (including core wp functions like wp_recent_posts() that suppress filters ).
* 2. Ensures we don't accidentally add posts (and events) into custom queries for other post types. (eg sliders).
*/
function add_espresso_events_to_posts( $WP_Query ) {
if ( $WP_Query instanceof WP_Query && ( $WP_Query->is_feed || $WP_Query->is_posts_page || ( $WP_Query->is_home && ! $WP_Query->is_page ) || ( isset( $WP_Query->query_vars['post_type'] ) && ( $WP_Query->query_vars['post_type'] == 'post' || is_array( $WP_Query->query_vars['post_type'] ) && in_array( 'post', $WP_Query->query_vars['post_type'] ) ) ) ) ) {
@Apina
Apina / modify_reg_id.php
Last active August 29, 2015 14:14
EE4 modify registration ID
<?php
// Please do NOT include the opening php tag, except of course if you're starting with a blank file
function change_reg_code($new_reg_code, $registration) {
//create a new reg ID e.g. business-1598
$new_reg_code = "business-" . rand(1000, 10000);
//send the new reg code back to be used.
@joshfeck
joshfeck / archive-espresso_events.php
Last active August 29, 2015 14:14
Display a calendar of events instead of the Espresso Events custom post type archive. Requires: Event Espresso 4, Espresso Calendar add-on, Genesis theme. Usage: Add this file to your Genesis child theme.
<?php
if ( class_exists( 'EED_Espresso_Calendar' ) ) :
global $is_espresso_calendar;
$is_espresso_calendar = TRUE;
if ( ! has_action( 'wp_enqueue_scripts', array( EED_Espresso_Calendar::instance(), 'calendar_scripts' ))) {
add_action( 'wp_enqueue_scripts', array( EED_Espresso_Calendar::instance(), 'calendar_scripts' ));
}
if ( EED_Espresso_Calendar::instance()->config()->tooltip->show ) {
@joshfeck
joshfeck / billing_form.php
Created February 17, 2015 18:08
Filter to change the State and Country fields to text fields on the payment billing forms. Requires Event Espresso 4.6.7.p or greater.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__state_field', 'billing_locale_text_field', 10, 1 );
add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__country_field', 'billing_locale_text_field', 10, 1 );
function billing_locale_text_field( $original_field ) {
return new EE_Text_Input( array( 'required' => true, 'html_class' => 'ee-billing-qstn'));
}
@mnelson4
mnelson4 / functions.php
Last active November 30, 2016 22:02
Filtering Ticket name and description in SPCO in EE4.6.23
function ee_revise_registration_checkout_line_item_desc( $original_description, $line_item, $options ) {
$datetime_names = array();
if( $line_item->ticket() instanceof EE_Ticket ) {
foreach( $line_item->ticket()->datetimes() as $datetime ) {
$datetime_names[] = $datetime->get_dtt_display_name(true);
}
}
return sprintf( __( ' for "%1$s", for datetime(s): %2$s', 'event_espresso' ),
$line_item->ticket_event_name(),
implode(", ", $datetime_names ) );
@joshfeck
joshfeck / details_waiting_list.md
Last active January 12, 2021 23:26
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.
@joshfeck
joshfeck / functions.php
Last active July 21, 2019 22:40
Past event archives page template for EE4. This can be adapted to most WP themes. Prints a simple unordered one page list of expired events.
<?php
// alter the query to only the primary datetimes that ended before today
// adjust query as desired
// add this to your child theme's functions.php file or into a custom plugin
function custom_posts_where_sql_for_only_expired() {
return ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end < "' . current_time( 'mysql', TRUE ) . '" ';
}