PluginProbe
Code Snippets / 3.9.6
Code Snippets v3.9.6
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / php / flat-files / classes / class-file-system-adapter.php

class-file-system-adapter.php in Code Snippets 3.9.6, at php/flat-files/classes/class-file-system-adapter.php

48 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Code_Snippets;
3
4 class WordPress_File_System_Adapter implements File_System_Interface {
5 private $fs;
6
7 public function __construct() {
8 if ( ! function_exists( 'WP_Filesystem' ) ) {
9 require_once ABSPATH . 'wp-admin/includes/file.php';
10 }
11 WP_Filesystem();
12 global $wp_filesystem;
13 $this->fs = $wp_filesystem;
14 }
15
16 public function put_contents( string $path, string $contents, $chmod ) {
17 return $this->fs->put_contents( $path, $contents, $chmod );
18 }
19
20 public function exists( string $path ): bool {
21 return $this->fs->exists( $path );
22 }
23
24 public function delete( $file, $recursive = false, $type = false ): bool {
25 return $this->fs->delete( $file, $recursive, $type );
26 }
27
28 public function is_dir( string $path ): bool {
29 return $this->fs->is_dir( $path );
30 }
31
32 public function mkdir( string $path, $chmod ) {
33 return $this->fs->mkdir( $path, $chmod );
34 }
35
36 public function rmdir( string $path, bool $recursive = false ): bool {
37 return $this->fs->rmdir( $path, $recursive );
38 }
39
40 public function chmod( string $path, $chmod ): bool {
41 return $this->fs->chmod( $path, $chmod );
42 }
43
44 public function is_writable( string $path ): bool {
45 return $this->fs->is_writable( $path );
46 }
47 }
48