Last active
January 4, 2023 22:57
-
-
Save slimndap/6d9fe9db9d83d8ef994e1c6bd6fc8fe0 to your computer and use it in GitHub Desktop.
A Jeero extension plugin that prevents Jeero from importing events from the Stager ticketing system to The Events Calendar, if an event has a publication date in the future. The plugin is written by ChatGPT!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Jeero Event Date Check | |
Description: Prevents Jeero from importing events with a future publication date. | |
Version: 1.0 | |
Author: Your Name | |
*/ | |
function jeero_stop_future_events( $result, $data, $raw, $theater, $subscription ) { | |
// Check if $result is already a WP_Error object | |
if ( is_wp_error( $result ) ) { | |
// If $result is a WP_Error, return it without checking the event publication date | |
return $result; | |
} | |
// Get the event publication date from the $raw array and convert it to a timestamp | |
$event_date = strtotime( $raw['publicationDate'] ); | |
// Get the current time in the site's timezone | |
$current_time = current_time( 'timestamp' ); | |
// Check if the event date is in the future | |
if ( $event_date > $current_time ) { | |
// Return a new WP_Error object to stop the event from being imported | |
return new WP_Error( 'event_in_future', 'Event publication date is in the future' ); | |
} | |
// If the event date is not in the future, return the original result | |
return $result; | |
} | |
add_filter( 'jeero/inbox/process/item/import/calendar=The_Events_Calendar', 'jeero_stop_future_events', 9, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment