Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function tribe_ext_gf_event_merge_tag( $text, $url_encode = false, $entry = false, $esc_html = false, $form = false, $nl2br = false, $format = 'html' ) {
- preg_match_all( "/\{tribe_event:(.*?)\}/", $text, $event_matches, PREG_SET_ORDER );
- if ( ! empty( $event_matches ) ) {
- global $post;
- $post_array = GFCommon::object_to_array( $post );
- $event_id = $post_array['ID'];
- //custom_field
- foreach ( $event_matches as $match ) {
- $full_tag = $match[0];
- $custom_field_name = $match[1];
- $custom_field_value = get_post_meta( $event_id, $custom_field_name, true );
- // Only look at the Venue and Organizer if you didnt find anything at the event PostMeta
- if ( ! $custom_field_value ) {
- // Look at the Venue Data
- if ( 0 === strpos( $custom_field_name, '_Venue' ) ) {
- $venue_id = get_post_meta( $event_id, '_EventVenueID', true );
- // Only Try if we have a Venue
- if ( $venue_id ) {
- $custom_field_value = get_post_meta( $venue_id, $custom_field_name, true );
- }
- // Look at the Organizer Data
- } elseif ( 0 === strpos( $custom_field_name, '_Organizer' ) ) {
- $organizer_id = get_post_meta( $event_id, '_EventOrganizerID', true );
- // Only Try if we have an Organizer
- if ( $organizer_id ) {
- $custom_field_value = get_post_meta( $organizer_id, $custom_field_name, true );
- }
- }
- }
- $text = str_replace( $full_tag, $url_encode ? urlencode( $custom_field_value ) : $custom_field_value, $text );
- }
- }
- return $text;
- }
Add Comment
Please, Sign In to add comment