-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathremotefs.php
56 lines (47 loc) · 1.49 KB
/
remotefs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/*
Plugin Name: RemoteFS
Plugin URI: http://github.com/Se7enSky/wp-remotefs
Description: Detach attachments to remote filesystem. Stupid simple and minimalistic solution for Heroku, 12factor and CDN support. And also almost transparent for WP, plugins and for user.
Version: 1.5.4
Author: Ivan Kravchenko @ Se7enSky
Author URI: http://www.se7ensky.com/
License: MIT
*/
abstract class RemoteFS {
protected static $registered = array();
static public function register($className, $detectFn) {
self::$registered[$className] = $detectFn;
}
static public function make($config) {
foreach (self::$registered as $className => $detectFn) {
if ($detectFn($config)) {
return new $className($config);
}
}
return null;
}
abstract public function __construct($config);
abstract public function get($path, $localPath); // -> bool fetch result
abstract public function put($path, $localPath); // -> string URL
abstract public function delete($path); // -> bool deletion result
abstract public function exists($path); // -> bool existence result
abstract public function errors(); // return errors
}
require_once "ftp.php";
require_once "helpers.php";
$RFS_NOTICES = array();
$rfsConfig = rfs_configuration();
$RFS = null;
if ($rfsConfig) {
$RFS = RemoteFS::make($rfsConfig['private']);
if ($RFS) {
require_once "wp-hooks.php";
require_once "compat.php";
} else {
$RFS_NOTICES[] = 'not-implemented-private';
}
} else {
$RFS_NOTICES[] = 'not-configured';
}
require_once "admin-page.php";