WP_Filesystem_Base::exists() WordPress Method
The WP_Filesystem_Base::exists() method is used to check whether a given file or directory exists. This is a static method, and it takes two parameters: the path to check, and an optional boolean flag specifying whether to check if the given path is a directory. This method is useful for making sure that a given file or directory exists before attempting to perform any operations on it. For example, you might use this method to check if a given image file exists before attempting to process and resize it. Note that this method only checks whether the given path exists; it does not check whether the path is readable, writable, or executable. Therefore, you should not use this method as a substitute for the WP_Filesystem_Base::is_readable(), WP_Filesystem_Base::is_writable(), or WP_Filesystem_Base::is_executable() methods.
WP_Filesystem_Base::exists( string $file ) #
Checks if a file or directory exists.
Parameters
- $file
(string)(Required)Path to file or directory.
Return
(bool) Whether $file exists or not.
Source
File: wp-admin/includes/class-wp-filesystem-base.php
public function exists( $file ) { return false; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |