wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



_truncate_post_slug › WordPress Function

Da3.6.0
Deprecaton/a
_truncate_post_slug ( $slug, $length = 200 )
Accedi:
  • private
Parametri: (2)
  • (string) $slug The slug to truncate.
    Richiesto:
  • (int) $length Optional. Max length of the slug. Default 200 (characters).
    Richiesto: No
    Default: 200
Vedi:
Ritorna:
  • (string) The truncated slug.
Definito a:
Codex:

Truncates a post slug.



Sorgenti

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, true );
		}
	}

	return rtrim( $slug, '-' );
}