Skip to content

Instantly share code, notes, and snippets.

View Pebblo's full-sized avatar
🏠
Working from home

Tony Warwick Pebblo

🏠
Working from home
  • Event Espresso
  • Liverpool, UK
View GitHub Profile
@Pebblo
Pebblo / tw_ee_remove_DetectLogin_middleware.php
Created June 19, 2020 14:29
A function to remove the DetectLogin middleware from Event Espresso, this allows all of EE's logic to run on those requests.
<?php //Please do not include the opening PHP tag if your already have one.
add_filter('FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps','tw_ee_remove_DetectLogin_middleware', 10, 1);
function tw_ee_remove_DetectLogin_middleware($stack_apps) {
unset($stack_apps['EventEspresso\core\services\request\middleware\DetectLogin']);
return $stack_apps;
}
@Pebblo
Pebblo / tw_ee_tweak_event_list_exclude_sold_out_events_where.php
Created June 19, 2020 13:01
Exclude sold_out events from EE event lists.
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_tweak_event_list_exclude_sold_out_events_where( $SQL, WP_Query $wp_query ) {
if ( isset( $wp_query->query_vars['post_type'] ) && ( $wp_query->query_vars['post_type'] == 'espresso_events' || ( is_array( $wp_query->query_vars['post_type'] ) && in_array( 'espresso_events', $wp_query->query_vars['post_type'] ) ) ) && ! $wp_query->is_singular ) {
global $wpdb;
$SQL .= "AND {$wpdb->prefix}posts.post_status != 'sold_out' ";
}
return $SQL;
}
@Pebblo
Pebblo / tw_ee_cal_rerender.php
Last active November 14, 2022 12:17
Example of how to force the EE calender for re-render when the window has loaded.
<?php //Please do not include the opening PHP tag if you alreayd have one.
function tw_ee_cal_rerender(){
wp_add_inline_script(
'espresso_calendar',
"jQuery(window).on('load', function() {
jQuery('#espresso_calendar').fullCalendar( 'render' );
});"
);
}
@Pebblo
Pebblo / tw_ee_hide_primary_email.php
Last active June 16, 2020 14:42
Example of how to hide the Personal information question group's email question using CSS if the current user is logged in.
<?php //Please do not include the opneing PHP tag if you already have one.
function tw_ee_hide_primary_email(){
if( is_user_logged_in() ) {
wp_add_inline_style(
'single_page_checkout',
'div[id*="ee-reg-form-qstn-grp-personal-information"] .ee-reg-qstn-email {
display: none;
}'
);
}
@Pebblo
Pebblo / tw_ee_is_promotion_line_item_type.php
Created June 15, 2020 22:10
Example of how to change the product type used in Infusionsoft for Promotions line items.
<?php //Please do not include the opening PHP tag if you alreayd have one.
add_filter('FHEE__EEE_Infusionsoft_Line_Item__ext_sync_to_infusionsoft__product_type', 'tw_ee_is_promotion_line_item_type', 10, 2);
function tw_ee_is_promotion_line_item_type($is_product_type, $line_item);
//If processing a line item and te Promotions add-on is active.
if ($line_item instanceof EE_Line_Item && class_exists('EE_Promotion')) {
// Check if the object related to the line item as an EE_Promotion.
$obj = $line_item->get_object();
if ($obj instanceof EE_Promotion) {
// Set line item type to be 'Special: Product' which is type 12.
@Pebblo
Pebblo / tw_ee_my_events_cancel_link.php
Created June 10, 2020 10:15
Example of how to override a JS method added by espresso_core.
@Pebblo
Pebblo / tw_ee_espresso_events_table_template_empty_row.php
Created June 3, 2020 11:34
Example of how to use jQuery to add an 'empty' row when the category you select on Table View Template does not have any events.
<?php // Please do not inlue the opening PHP tag if you alread have one.
function tw_ee_espresso_events_table_template_empty_row() {
wp_add_inline_script(
'espresso_events_table_template',
'jQuery(document).ready(function($){
$("#ee_filter_cat").change(function() {
$(".espresso-table-row.empty").remove();
if( $(".espresso-table-row:visible").length === 0 ) {
@Pebblo
Pebblo / tw_ee_add_private_events_to_cal_with_cap_check.php
Created May 27, 2020 19:04
Example of how to include Private events on the calendar if the current user has the ee_read_private_events cap
<?php //Please do not include the opening PHP tag if you already have one
add_filter( 'AFEE__EED_Espresso_Calendar__get_calendar_events__public_event_stati', 'tw_ee_add_private_events_to_cal_with_cap_check', 10, 1);
function tw_ee_add_private_events_to_cal_with_cap_check($public_event_stati) {
// Add private events if the current user can view them.
if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
$public_event_stati[] = EEM_Event::post_status_private;
}
return $public_event_stati;
@Pebblo
Pebblo / tw_ee_filter_porto_meta_layout.php
Created May 18, 2020 15:06
How to force Porto theme to load a specific layout and sidebar for EE events.
<?php // Do not include the opening PHP tag if you already have one.
// Force Porto theme to load the 'right-sidebar' layout and 'home-sidebar'.
add_filter('porto_meta_layout', 'tw_ee_filter_porto_meta_layout', 10, 1);
function tw_ee_filter_porto_meta_layout( $settings ) {
if( is_singular('espresso_events') ) {
$settings[0] = 'right-sidebar';
// Change this to the slug of the sidebar you want to load.
$settings[1] = 'home-sidebar';
}
@Pebblo
Pebblo / tw_ee_mer_change_event_list_url_from_term.php
Created May 18, 2020 11:15
Example of how to change the return to event list button displayed on the cart modal based on the terms set the event the ticket submission is for.
<?php // Do not add the opening PHP tag if you already have one.
function tw_ee_mer_change_event_list_url_from_term($default_event_list){
// Check if this is an ajax request.
if (wp_doing_ajax()){
// Check we have an event id.
if (!empty($_POST['tkt-slctr-event-id'])) {
$EVT_ID = absint($_POST['tkt-slctr-event-id']);
if (has_term( 'courses-seminars', 'espresso_event_categories', $EVT_ID ) ){
return 'https://domain.com/courses-seminars/';