wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



validate_file_to_edit › WordPress Function

Depuis1.5.0
Dépréciéen/a
validate_file_to_edit ( $file, $allowed_files = array() )
Paramètres: (2)
  • (string) $file File the user is attempting to edit.
    Requis: Oui
  • (string[]) $allowed_files Optional. Array of allowed files to edit. `$file` must match an entry exactly.
    Requis: Non
    Défaut: array()
Retourne:
  • (string|void) Returns the file name on success, dies on failure.
Défini(e) dans:
Codex:

Makes sure that the file that was requested to be edited is allowed to be edited.

Function will die if you are not allowed to edit the file.


Source

function validate_file_to_edit( $file, $allowed_files = array() ) {
	$code = validate_file( $file, $allowed_files );

	if ( ! $code ) {
		return $file;
	}

	switch ( $code ) {
		case 1:
			wp_die( __( 'Sorry, that file cannot be edited.' ) );

			// case 2 :
			// wp_die( __('Sorry, cannot call files with their real path.' ));

		case 3:
			wp_die( __( 'Sorry, that file cannot be edited.' ) );
	}
}