self::ats_DateTimeFormat( $titleArray[ $i ], '', 'True', 'False' ), 'active-style' => 'off', 'subtitle' => $subtitleArray[ $i ], 'purchase-type' => 'external-link', 'event_tickets_package_feature' => '', 'woocommerce-product' => '', 'quantity' => 'default', 'price' => '', 'eventbrite-link' => '', 'meetup-link' => '', 'external-link' => $buttonlinkArray[ $i ] . '', 'contact-form-link' => '', 'button-title' => $buttontextArray[ $i ], 'button-target' => 'agileEmbed', ); } return ( $outer ); } static function ats_DateFormat( $datetime ) { return wp_date( 'Y-m-d', strtotime( $datetime ) ); } static function ats_TimeFormat( $datetime, $showtime ) { $time = ''; if ( $showtime == 'True' ) { $time = wp_date( 'g:i a', strtotime( $datetime ) ); } return $time; } static function ats_DateTimeFormat( $startdatetime, $enddatetime, $showtime, $showenddate ) { $formatted = wp_date( 'D, M j, Y', strtotime( $startdatetime ) ); if ( $showtime == 'True' ) { $formatted .= wp_date( ' g:i a', strtotime( $startdatetime ) ); } if ( $showenddate == 'True' ) { $formatted .= ' - ' . wp_date( 'D, M j, Y', strtotime( $enddatetime ) ); if ( $showtime == 'True' ) { $formatted .= wp_date( ' g:i a', strtotime( $enddatetime ) ); } } return $formatted; } static function ats_ExpireDateTimeFormat( $enddatetime ) { return get_gmt_from_date( $enddatetime, 'Y-m-d H:i' ); } static function ats_FormatEventSlug( $title, $eventid ) { return sanitize_title( $title ) . '-' . $eventid; } static function ats_SerializeEventVenueValue( $venueid ) { $venueArray = array(); $venueArray[ intval( $venueid ) ] = $venueid; return $venueArray; } static function ats_SerializeEventVenue( $venue ) { $venueArray = array(); $venueArray[ intval( $venue['VenueID'] ) ] = $venue['Name'] ?? ''; return $venueArray; } static function ats_SerializeTicketsArea( $buttonlink, $buttontext, $title, $subtitle, $style = 0 ) { return array( 0, array( 'title' => $title, 'active-style' => 'off', 'subtitle' => $subtitle, 'purchase-type' => 'external-link', 'event_tickets_package_feature' => '', 'woocommerce-product' => '', 'quantity' => 'default', 'price' => '', 'eventbrite-link' => '', 'meetup-link' => '', 'external-link' => $buttonlink . 'affid=ticketsnashville&', 'contact-form-link' => '', 'button-title' => $buttontext, 'button-target' => '_self', ), ); } static function ats_SearializeSectionsArea() { return array( array( 'title' => 'Tickets', 'type' => 'tickets', 'event_extra_tabs_content' => '', 'speaker-style' => 'default', 'speaker-column' => 'default', 'speaker-column-space' => 'default', 'speaker-photo' => 'default', 'speaker-profession' => 'default', 'speaker-summary' => 'default', 'speaker-social' => 'default', ), array( 'title' => 'Map', 'type' => 'map', 'event_extra_tabs_content' => '', 'speaker-style' => 'default', 'speaker-column' => 'default', 'speaker-column-space' => 'default', 'speaker-photo' => 'default', 'speaker-profession' => 'default', 'speaker-summary' => 'default', 'speaker-social' => 'default', ), ); } static function ats_SpecifyCategory( $category, $orgid ) { $catString = ''; if ( $category != 'orgbased' ) { $catString = $category; } else { switch ( $orgid ) { case 11878: case 12670: $catString = 'Cinema'; break; case 11879: $catString = 'Music'; break; case 11981: case 12666: $catString = 'Performing Arts'; break; case 14252: $catString = 'Dance'; break; case 14253: $catString = 'Family'; break; default: $catString = 'Other'; break; } } return $catString; } static function ats_TagReturns( $customPropName, $customPropValue ) { $customPropNameArray = explode( ',', $customPropName ); $customPropValueArray = explode( ',', $customPropValue ); $arrayCount = count( $customPropNameArray ); $outer = ''; for ( $i = 0; $i < $arrayCount; $i++ ) { if ( isset( $customPropNameArray[ $i ], $customPropValueArray[ $i ] ) ) { if ( strtolower( trim( $customPropNameArray[ $i ] ) ) == 'tag' ) { $outer .= $customPropValueArray[ $i ] . ','; } } } $outer = rtrim( $outer, ',' ); return $outer; } static function ats_TagReturnsFromJson( $custom_prop_json ) { $outer = ''; foreach ( $custom_prop_json as $property ) { if ( isset( $property['Name'] ) && strtolower( trim( $property['Name'] ) ) == 'tag' ) { if ( isset( $property['Value'] ) ) { $outer .= trim( $property['Value'] ) . ','; } } } // Remove the trailing comma return rtrim( $outer, ',' ); } static function agile_eventChamp_post_creator( $event, $commentStat, $postStat, $isNewEvent, $postID, $comingSoonEventData = null ) { // Coming soon events never have CurrentShowings $currentShowings = isset( $event['CurrentShowings'] ) && is_array( $event['CurrentShowings'] ) ? $event['CurrentShowings'] : array(); $firstShowing = ! empty( $currentShowings ) ? $currentShowings[0] : array(); $lastShowing = ! empty( $currentShowings ) ? $currentShowings[ count( $currentShowings ) - 1 ] : array(); $firstVenue = isset( $firstShowing['Venue'] ) ? $firstShowing['Venue'] : null; $venueLocation = ''; if ( $firstVenue ) { $Address1 = $firstVenue['Address1'] ?? ''; $Address2 = $firstVenue['Address2'] ?? ''; $City = $firstVenue['City'] ?? ''; $State = $firstVenue['State'] ?? ''; $Zip = $firstVenue['Zip'] ?? ''; if ( $Address1 != '' ) { $venueLocation .= $Address1 . ', '; } if ( $Address2 != '' ) { $venueLocation .= $Address2 . ', '; } if ( $City != '' ) { $venueLocation .= $City . ', '; } if ( $State != '' ) { $venueLocation .= $State . ', '; } if ( $Zip != '' ) { $venueLocation .= $Zip; } } // Handle empty CurrentShowings (coming soon events never have CurrentShowings) $event_start_date = ! empty( $firstShowing['StartDate'] ) ? self::ats_DateFormat( $firstShowing['StartDate'] ) : ''; $event_start_time = ! empty( $firstShowing['StartDate'] ) ? self::ats_TimeFormat( $firstShowing['StartDate'], true ) : ''; $event_end_date = ! empty( $lastShowing['EndDate'] ) ? self::ats_DateFormat( $lastShowing['EndDate'] ) : ''; $event_end_time = ! empty( $lastShowing['EndDate'] ) ? self::ats_TimeFormat( $lastShowing['EndDate'], true ) : ''; $event_expire_date = ! empty( $lastShowing['EndDate'] ) ? self::ats_ExpireDateTimeFormat( $lastShowing['EndDate'] ) : ''; $event_venue = self::ats_SerializeEventVenue( $firstVenue ); $event_extra_tabs = self::ats_SearializeSectionsArea(); $StringPurchaseLinks = ''; $StringSalesMessage = ''; $StringStartDate = ''; $StringShortDescriptive = ''; $showingIDs = array(); foreach ( $currentShowings as $show ) { $StringPurchaseLinks .= ( $show['LegacyPurchaseLink'] . ',' ); $StringSalesMessage .= ( $show['SalesMessage'] . ',' ); $StringStartDate .= ( $show['StartDate'] . ',' ); $StringShortDescriptive .= ( $show['ShortDescriptive'] . ',' ); array_push( $showingIDs, $show['ID'] ); } // Only trim if strings are not empty (coming soon events never have showings) if ( ! empty( $StringPurchaseLinks ) ) { $StringPurchaseLinks = substr( $StringPurchaseLinks, 0, -1 ); } if ( ! empty( $StringSalesMessage ) ) { $StringSalesMessage = substr( $StringSalesMessage, 0, -1 ); } if ( ! empty( $StringStartDate ) ) { $StringStartDate = substr( $StringStartDate, 0, -1 ); } if ( ! empty( $StringShortDescriptive ) ) { $StringShortDescriptive = substr( $StringShortDescriptive, 0, -1 ); } $event_tickets = self::ats_SerializeShowTicketsArea( $StringPurchaseLinks, $StringSalesMessage, $StringStartDate, $StringShortDescriptive ); $thumbnailID = ''; if ( ! empty( $event['EventImage'] ) ) { $mediaLibImg = agile_tix_post_creator::add_image_to_media_library_from_uri( $event['EventImage'] ); if ( $mediaLibImg && array_key_exists( 'url', $mediaLibImg ) && array_key_exists( 'attachment_id', $mediaLibImg ) ) { $thumbnailID = $mediaLibImg['attachment_id']; } } $post_data = array( 'ID' => $postID, 'post_title' => $event['Name'], 'post_content' => agile_tix_post_creator::agile_create_universal_content_body( $event ) . '