WP_REST_Plugins_Controller::validate_plugin_param() WordPress Method

The WP_REST_Plugins_Controller::validate_plugin_param() function is used to validate a plugin parameter. This function is used to ensure that the plugin parameter is a valid plugin. This function will return an error if the plugin parameter is not a valid plugin.

WP_REST_Plugins_Controller::validate_plugin_param( string $file ) #

Checks that the “plugin” parameter is a valid path.


Parameters

$file

(string)(Required)The plugin file parameter.


Top ↑

Return

(bool)


Top ↑

Source

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

	public function validate_plugin_param( $file ) {
		if ( ! is_string( $file ) || ! preg_match( '/' . self::PATTERN . '/u', $file ) ) {
			return false;
		}

		$validated = validate_file( plugin_basename( $file ) );

		return 0 === $validated;
	}


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.