Home › Forums › Calendar Products › Community Events › Using HTML-code in explaining text for Additional Fields
- This topic has 8 replies, 2 voices, and was last updated 8 years, 8 months ago by
Oliver.
-
AuthorPosts
-
July 23, 2017 at 1:36 pm #1325140
Oliver
ParticipantHi,
for the additional fields a text can be typed in to explain it.
Inside this text I want to add HTML-code (e.g. to insert a link to another page).Unfortunately every HTML code I inserted is automatically deleted (maybe for security – injection – reasons).
Is it possible to use HTML code there, too? (by a tweak?)Best regards,
OliverJuly 25, 2017 at 3:51 pm #1326082Barry
MemberHi Oliver,
Thanks for contacting us.
add_filter( 'tribe-events-save-options', function( $options ) { if ( ! isset( $_POST['custom-field'] ) ) { return $options; } foreach ( $_POST['custom-field-options'] as $key => $values ) { $key = absint( substr( $key, 1 ) ); if ( ! $key ) { continue; } if ( ! isset( $options['custom-fields'][ $key ] ) ) { continue; } $options['custom-fields'][ $key ]['values'] = wp_kses_data( $values ); } return $options; } );The code I outlined above, which could be added to a custom plugin or potentially even to your theme’s functions.php file ought to help.
It does strip away a layer of protection, but should be pretty safe.
Might that work for you?
July 26, 2017 at 1:16 pm #1326571Oliver
ParticipantHi Barry!
thanks for the super fast reply!
The code works to input HTML in the custom field, but unfortunately the HTML is not executed in the frontend – see screenshot.
Best regards,
OliverJuly 26, 2017 at 1:39 pm #1326597Barry
MemberAhh, right you are – sorry for missing that. There are a few steps needed to workaround this side of the problem.
First, copy events-calendar-pro/src/admin-views/event-meta.php to a custom location. Then, tell Events Calendar PRO to actually use your new replacement – which can be done using code like this:
add_filter( 'tribe_events_event_meta_template', function() { return '/path/to/your/custom-override/event-meta.php'; } );Within that template, look out for code like this (this example can be found on line 36 of the current template):
<?php echo esc_html( stripslashes( $option ) ) ?>
Remove the esc_html( … ) wrapper so that you have:
<?php echo stripslashes( $option ) ?>
And that should, hopefully, get you on track. It may be a comparable change is needed for frontend output, too – and similar principles would need to be followed if so.
August 3, 2017 at 12:26 pm #1330327Oliver
ParticipantThanks Barry, that looks good! 🙂
Best regards,
OliverAugust 3, 2017 at 12:27 pm #1330328Oliver
Participant…
August 3, 2017 at 8:19 pm #1330515Barry
MemberGreat!
August 25, 2017 at 9:35 am #1340352Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Using HTML-code in explaining text for Additional Fields’ is closed to new replies.
