INVP::sluggify( string $name )

Turns the name of something into a slug that WordPress will accept when creating objects like terms. WordPress slugs are described as containing only letters, numbers, and hyphens.

On This Page


Parameters Parameters

$name

(string) (Required) The string to turn into a slug.


Top ↑

Return Return

(string) An alteration of $name that WordPress will accept as a term slug


Top ↑

Source Source

File: includes/class-invp.php

	public static function sluggify( $name ) {
		if ( null === $name ) {
			return '';
		}
		$name = trim( preg_replace( '/[^a-zA-Z0-9\\- ]/', '', $name ) );
		$name = str_replace( '/', '-', str_replace( ' ', '-', $name ) );
		return strtolower( str_replace( '--', '-', str_replace( '---', '-', $name ) ) );
	}