Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Workarounds to make Eventbrite API WordPress plugin work on 32bit systems
<?php
// Additions to main functions.php file - eventbrite 32bit php problems - referenced from http://wvega.com/850/getting-eventbrite-api-wordpress-plugin-to-work-on-systems-with-32-bit-builds-of-php/
function wvega_850_filter_event_permalink( $url ) { // eg. http://mysite.com/events/july-test-drive-11829569561
if ( function_exists( 'eventbrite_is_event' ) && eventbrite_is_event() ) {
$url = sprintf( '%1$s/%2$s/%3$s-%4$s/',
esc_url( home_url() ), // protocol://domain
sanitize_title( get_queried_object()->post_name ), // page-with-eventbrite-template
sanitize_title( get_post()->post_title ), // event-title
wvega_850_get_current_event_id() // event ID
);
}
return $url;
}
add_filter( 'post_link', 'wvega_850_filter_event_permalink', 11 );
function wvega_850_http_api_curl( $handle, $r, $url ) {
if ( false === strpos( $url, 'www.eventbriteapi.com' ) || false === strpos( $url, '2147483647' ) ) {
return;
}
$eventbrite_id = wvega_850_get_current_event_id();
if ( empty( $eventbrite_id ) ) {
return;
}
$new_url = str_replace( '2147483647', $eventbrite_id, $url );
curl_setopt( $handle, CURLOPT_URL, $new_url);
}
add_action( 'http_api_curl', 'wvega_850_http_api_curl', 10, 3 );
function wvega_850_get_current_event_id() {
$eventbrite_id = get_query_var( 'eventbrite_id' );
if ( $eventbrite_id ) {
return $eventbrite_id;
}
$post = get_post();
if ( isset( $post->tickets[0]->event_id ) ) {
$eventbrite_id = $post->tickets[0]->event_id;
}
return $eventbrite_id;
}
function wvega_850_eventbrite_transient_name( $transient_name, $endpoint, $params ) {
if ( $endpoint != 'event_details' ) {
return $transient_name . rand();
}
$eventbrite_id = wvega_850_get_current_event_id();
if ( empty( $eventbrite_id ) ) {
return $transient_name . rand();
}
$params['p'] = $eventbrite_id;
return 'eventbrite_' . md5( $endpoint . implode( $params ) );
}
add_filter( 'eventbrite_transient_name', 'wvega_850_eventbrite_transient_name', 10, 3 );
// end of additions for eventbrite 32bit php problems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.