WC_Gateway_Paypal_Request::limit_length
Limit length of an arg.
Method of the class: WC_Gateway_Paypal_Request{}
No Hooks.
Returns
String.
Usage
// protected - for code of main (parent) or child class $result = $this->limit_length( $string, $limit );
- $string(string) (required)
- Argument to limit.
- $limit(int)
- Limit size in characters.
Default:127
WC_Gateway_Paypal_Request::limit_length() WC Gateway Paypal Request::limit length code WC 10.5.0
protected function limit_length( $string, $limit = 127 ) {
$str_limit = $limit - 3;
if ( function_exists( 'mb_strimwidth' ) ) {
if ( mb_strlen( $string ) > $limit ) {
$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
}
} elseif ( strlen( $string ) > $limit ) {
$string = substr( $string, 0, $str_limit ) . '...';
}
return $string;
}