截断一个帖子。
原型
_truncate_post_slug( string $slug, int $length = 200 )
参数
$slug
(string)
(Required)
塞子要截断。
$length
(int)
(Optional)
最大长度的slu ..默认200(字符)。
返回值
(string)
截断的slu ..
源文件
路径:wp-includes/post.php
<?php
...
function _truncate_post_slug( $slug, $length = 200 ) {
if ( strlen( $slug ) > $length ) {
$decoded_slug = urldecode( $slug );
if ( $decoded_slug === $slug )
$slug = substr( $slug, 0, $length );
else
$slug = utf8_uri_encode( $decoded_slug, $length );
}
return rtrim( $slug, '-' );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/_truncate_post_slug/