custom_truncate

By: Massimiliano Mollo | Asked: 05/07/2022
ForumsCategory: General questionscustom_truncate
Massimiliano Mollo asked 3 years ago
hi, i find this custom_truncate,for cut text on right side,but not understand how cut in right side,beacause also custom_truncate cut always on left side  

Add custom truncate#

To add a custom truncate option to the [frm-field-value] shortcode, follow the example below. Usage example: [frm-field-value field_id=x custom_truncate=1]
add_filter( 'do_shortcode_tag', 'truncate_frm_field_value', 10, 3 );
function truncate_frm_field_value( $output, $tag, $attr ) {
	if ( 'frm-field-value' === $tag && isset( $attr['custom_truncate'] ) && is_numeric( $attr['custom_truncate'] ) ) {
		$output = FrmAppHelper::truncate( $output, $attr['custom_truncate'] );
	}
	return $output;
}
1 Answers
Victor Font answered 3 years ago
truncate always reduces the length of a string from the right. This is how PHP works. If you want to get a portion of a string or remove characters from the left side, use substr. https://www.php.net/manual/en/function.substr.php
Massimiliano Mollo replied 3 years ago

Tks, but i dont know where to put substr string

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right