Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



sanitize_title ›

Seit1.0.0
Veraltetn/v
sanitize_title ( $title, $fallback_title = '', $context = 'save' )
Parameter: (3)
  • (string) $title The string to be sanitized.
    Erforderlich: Ja
  • (string) $fallback_title Optional. A title to use if $title is empty.
    Erforderlich: Nein
    Standard: (leer)
  • (string) $context Optional. The operation for which the string is sanitized
    Erforderlich: Nein
    Standard: 'save'
Gibt zurück:
  • (string) The sanitized string.
Definiert in:
Codex:

Sanitizes a title, or returns a fallback title.

Specifically, HTML and PHP tags are stripped. Further actions can be added via the plugin API. If $title is empty and $fallback_title is set, the latter will be used.



Quellcode

function sanitize_title( $title, $fallback_title = '', $context = 'save' ) {
	$raw_title = $title;

	if ( 'save' == $context ) {
		$title = remove_accents( $title );
	}

	/**
	 * Filters a sanitized title string.
	 *
	 * @since 1.2.0
	 *
	 * @param string $title     Sanitized title.
	 * @param string $raw_title The title prior to sanitization.
	 * @param string $context   The context for which the title is being sanitized.
	 */
	$title = apply_filters( 'sanitize_title', $title, $raw_title, $context );

	if ( '' === $title || false === $title ) {
		$title = $fallback_title;
	}

	return $title;
}