wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



_truncate_post_slug › WordPress Function

Od3.6.0
Przestarzałyn/a
_truncate_post_slug ( $slug, $length = 200 )
Dostęp:
  • private
Parametry: (2)
  • (string) $slug The slug to truncate.
    Wymagane: Tak
  • (int) $length Optional. Max length of the slug. Default 200 (characters).
    Wymagane: Nie
    Domyślny: 200
Zobacz:
Powrót:
  • (string) The truncated slug.
Zdefiniowane na:
Codex:

Truncates a post slug.



Źródło

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