Support

Search results for ""

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

Export file -Removing HTML tags

Dear community,

I need to be removed the HTML tags when exporting a filter file to CSV.

Now when I do an export I also export the HTML tag I placed to better looking the columns.

Thnk you in advance

4 months ago
RAUL JAUREGUI

Just to be more specific, when you add a column that can be edited, that column when it is exported to CSV file, the HTML tags of the edited lines on the column are exported too. It would be better if they are not exported to the file

4 months ago
Stefan
Developer

Thanks for your feedback.
I suspect that you’re talking about the custom field column.
Since this is a column that contain any type of information, we did not implement our StripHTML strategry Export for that column. You can use the hook ac/export/value to filter the value yourself and strip it from all HTML.

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

You can have a look at the last example that strips the value for a specific custom fields column based on the selected meta key.

Or if you want to strip the HTML for all custom fields, you can do it like this:

/**
 * @param string    $value
 * @param AC\Column $column
 *
 * @return string
 */
function ac_column_export_value_strip_html( $value, AC\Column $column ) {
	if ( $column instanceof ACP\Column\CustomField ) {
		$value = strip_tags( $value );
	}

	return $value;
}

add_filter( 'ac/export/value', 'ac_column_export_value_strip_html', 10, 2 );
4 months ago
RAUL JAUREGUI

Thank you, I entered the snippet for all HTML tags, and it worked fine for the custom field columns. But the on the “content” type fields, the tags are not removed.

I don’t know what to add to the code you send me in order to remove those too.

Raul,

4 months ago
Stefan
Developer
/**
 * @param string    $value
 * @param AC\Column $column
 *
 * @return string
 */
function ac_column_export_value_strip_html( $value, AC\Column $column ) {
	if ( $column instanceof ACP\Column\Post\Content ) {
		$value = strip_tags( $value );
	}

	return $value;
}

add_filter( 'ac/export/value', 'ac_column_export_value_strip_html', 10, 2 );

Or if you want to strip all columns from their HTML (Which can probably do no harm) you can use this nice one-liner:


// Strip all HTML for Admin Columns Export
add_filter( 'ac/export/value', function( $value ){ return strip_tags( $value ); } );
4 months ago
RAUL JAUREGUI

Yes now it works fine.

Thank you,
Raul

4 months ago

You must be logged in to reply to this topic.