WP_Filesystem_Direct::is_writable( string $path ): bool

Checks if a file or directory is writable.

Parameters

$pathstringrequired
Path to file or directory.

Return

bool Whether $path is writable.

Source

public function is_writable( $path ) {
	return @is_writable( $path );
}

Changelog

VersionDescription
2.5.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    You have to call function \WP_Filesystem().

    if (!\WP_Filesystem()) {
    // failed to initialize file system.
    return false;
    }

    global $wp_filesystem;

    var_dump($wp_filesystem->is_writable('/path/to/file'));

    And if your file is not work in admin pages, require it with require_once(ABSPATH . 'wp-admin/includes/file.php');.

You must log in before being able to contribute a note or feedback.