SHARE
TWEET

Untitled

a guest Sep 17th, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * This will enable the cost field for Eventbrite imported events in the admin
  5.  * Add this code to your active theme's functions.php file
  6.  * Important Note: No cost will be displayed for Eventbrite events if none is manually set.
  7.  */
  8.  
  9. if ( class_exists( 'Tribe__Events__Tickets__Eventbrite__Main' ) ) {
  10.  
  11.     add_filter( 'tribe_events_admin_show_cost_field', '__return_true' );
  12.  
  13.     add_filter( 'tribe_get_cost', 'temp_tribe_get_cost_eventbrite', 30, 3 );
  14.  
  15.     function temp_tribe_get_cost_eventbrite ( $cost, $post_id, $with_currency_symbol ) {
  16.  
  17.         $post = get_post( $post_id );
  18.  
  19.         if ( ! is_object( $post ) || ! $post instanceof WP_Post ) {
  20.             return $cost;
  21.         }
  22.  
  23.         $eventbrite_id = tribe_eb_get_id( $post->ID );
  24.  
  25.         // If this even is not associated with Eventbrite let's do nothing more
  26.         if ( empty( $eventbrite_id ) ) {
  27.             return $cost;
  28.         }
  29.  
  30.         // Force to get EventCost
  31.         $cost = get_post_meta( $post->ID, '_EventCost', true );
  32.  
  33.         $cost_utils = tribe( 'tec.cost-utils' );
  34.         $cost = $cost_utils->get_formatted_event_cost( $post_id, $with_currency_symbol );
  35.  
  36.         // Only return cost
  37.         if ( !empty( $cost ) ) {
  38.             return $cost;
  39.         }
  40.  
  41.         return false;
  42.  
  43.     };
  44.  
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top