Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Blake Miller

ACF is Blank, Prevent HTML rendering in WP-Admin Posts View?

I’ve got a CPT with a handful of Advanced Custom Fields attached to it. I’m also using Admin Columns Pro in the back end to help facilitate view/editing of all the data in list views. One of the fields is a Text Area field where we put Vimeo iFrame Embed Code. (On the front end of the CPT, I am displaying the resultant Vimeo video and all works great.) The problem is that in the posts/list view, the data is not showing. I believe it’s trying to render/process the resultant iframe embed code and returning nothing. But the data is there. Even if I use the inline edit feature of ACP, the data appears. I’m not sure if this is a question for Admin Columns Pro – but it seems more “WP Admin Specific” Thoughts?

Blank Field

Resultant Data

2 years, 11 months ago
Stefan van den Dungen Gronovius
Developer

All the values that run through our column values are sanitized. We use wp_kses to sanitize the data and script and iframes are automatically removed by that function. If you want to render the actual iframes on your list page you can do that, but you’ll need to overwrite the value yourself with the following hook:

https://github.com/codepress/admin-columns-hooks/blob/master/ac-column-value.php

This hook runs after the sanitation, so if you call the value again of a column, it should render it without sanitation. I wrote the following snippet that will help you start with the hook. You might want to change the conditional to make it work for your use case.

add_filter( 'ac/column/value', function ( $value, $id, AC\Column $column ) {
	if ( $column instanceof ACA\ACF\Column && 'yourkey' === $column->get_meta_key() ) {
		$value = $column->get_value( $id );
	}

	return $value;
}, 10, 3 );
2 years, 11 months ago
Blake Miller

Thank you for your response and taking the time to help with a solution.

Ideally, I’d like to show the plain text just as it’s entered in the Custom Field, not the rendered iFrame or scripts. (In these cases, it’s an embedded video and it would not be good to pull in multiple video feeds into a list view of posts). It doesn’t even have to be the full text, even an indicator that something is there. The data is there, and it shows up when you click the inline edit, but then is removed (sanitized) when in view mode.

It is possible to show just the plain text w/o executing scripts or iframes?

My original images did not embed:

List view (blank) – https://www.screencast.com/t/rdu9Ai6UCgWk
Inline Edit View (data) – https://www.screencast.com/t/vHdRny3yUsI

Thanks!

2 years, 11 months ago

You must be logged in to reply to this topic.