validate_username

Definition:
function validate_username( $username ) {}

Checks whether an username is valid.

Parameters

  • string $username: Username.

Return values

returns:Whether username given is valid

Defined filters

  • validate_username
    apply_filters( 'validate_username', $valid, $username )

Source code

function validate_username( $username ) {

	$sanitized = sanitize_user( $username, true );

	$valid = ( $sanitized == $username );

	return apply_filters( 'validate_username', $valid, $username );

}

3329

validate_plugin

Definition:
function validate_plugin($plugin) {}

Validate the plugin path.
Checks that the file exists and is valid file.

Parameters

  • string $plugin: Plugin Path

Return values

returns:0 on success, WP_Error on failure.

Source code

function validate_plugin($plugin) {

	if ( validate_file($plugin) )

		return new WP_Error('plugin_invalid', __('Invalid plugin path.'));

	if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) )

		return new WP_Error('plugin_not_found', __('Plugin file does not exist.'));



	$installed_plugins = get_plugins();

	if ( ! isset($installed_plugins[$plugin]) )

		return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.'));

	return 0;

}

3327

validate_file_to_edit

Definition:
function validate_file_to_edit( $file, $allowed_files = '' ) {}

Make sure that the file that was requested to edit, is allowed to be edited
Function will die if if you are not allowed to edit the file

Parameters

  • string $file: file the users is attempting to edit
  • array $allowed_files: Array of allowed files to edit, $file must match an entry exactly

Source code

function validate_file_to_edit( $file, $allowed_files = '' ) {

	$code = validate_file( $file, $allowed_files );



	if (!$code )

		return $file;



	switch ( $code ) {

		case 1 :

			wp_die( __('Sorry, can’t edit files with “..” in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.' ));



		//case 2 :

		//	wp_die( __('Sorry, can’t call files with their real path.' ));



		case 3 :

			wp_die( __('Sorry, that file cannot be edited.' ));

	}

}

3325

validate_file

Definition:
function validate_file( $file, $allowed_files = '' ) {}

File validates against allowed set of defined rules.
A return value of ‘1’ means that the $file contains either ‘..’ or ‘./’. A return value of ‘2’ means that the $file contains ‘:’ after the first character. A return value of ‘3’ means that the file is not in the allowed files list.

Parameters

  • string $file: File path.
  • array $allowed_files: List of allowed files.

Return values

returns:0 means nothing is wrong, greater than 0 means something was wrong.

Source code

function validate_file( $file, $allowed_files = '' ) {

	if ( false !== strpos( $file, '..' ) )

		return 1;



	if ( false !== strpos( $file, './' ) )

		return 1;



	if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) )

		return 3;



	if (':' == substr( $file, 1, 1 ) )

		return 2;



	return 0;

}

3323

validate_email

Definition:
function validate_email( $email, $check_domain = true) {}

Parameters

  • $email
  • $check_domain

Source code

function validate_email( $email, $check_domain = true) {

	_deprecated_function( __FUNCTION__, '3.0', 'is_email()' );

	return is_email( $email, $check_domain );

}

3321