WP_REST_Controller::sanitize_slug() WordPress Method

The WP_REST_Controller::sanitize_slug() method is used to sanitize a string for use as a slug. This is useful when you need to ensure that a string is safe to use as a slug, for example when creating a new post or taxonomy term.

WP_REST_Controller::sanitize_slug( string $slug ) #

Sanitizes the slug value.


Description

Top ↑

See also


Top ↑

Parameters

$slug

(string)(Required)Slug value passed in request.


Top ↑

Return

(string) Sanitized value for the slug.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-controller.php

	public function sanitize_slug( $slug ) {
		return sanitize_title( $slug );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.