WP_REST_Plugins_Controller::sanitize_plugin_param() WordPress Method

The WP_REST_Plugins_Controller::sanitize_plugin_param() method is used to sanitize a plugin parameter before it is used to load a plugin. This is done to ensure that the parameter is a valid plugin name and to avoid potential security vulnerabilities.

WP_REST_Plugins_Controller::sanitize_plugin_param( string $file ) #

Sanitizes the “plugin” parameter to be a proper plugin file with “.php” appended.


Parameters

$file

(string)(Required)The plugin file parameter.


Top ↑

Return

(string)


Top ↑

Source

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

	public function sanitize_plugin_param( $file ) {
		return plugin_basename( sanitize_text_field( $file . '.php' ) );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.5.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.