|
1
|
|
|
<?php // -*- coding: utf-8 -*- |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Plugin Name: Multisite Global Media |
|
6
|
|
|
* Description: Multisite Global Media is a WordPress plugin which shares media across the Multisite network. |
|
7
|
|
|
* Network: true |
|
8
|
|
|
* Plugin URI: https://github.com/bueltge/multisite-global-media |
|
9
|
|
|
* Version: 0.1.1 |
|
10
|
|
|
* Author: Dominik Schilling, Frank Bültge, Guido Scialfa |
|
11
|
|
|
* License: GPLv2+ |
|
12
|
|
|
* License URI: ./LICENSE |
|
13
|
|
|
* Text Domain: multisite-global-media |
|
14
|
|
|
* Domain Path: /languages |
|
15
|
|
|
* |
|
16
|
|
|
* Php Version 7 |
|
17
|
|
|
* |
|
18
|
|
|
* @package WordPress |
|
19
|
|
|
* @license https://opensource.org/licenses/GPL-2.0 |
|
20
|
|
|
* @version 2020-04-22 |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace MultisiteGlobalMedia; |
|
24
|
|
|
|
|
25
|
|
|
// phpcs:disable |
|
26
|
|
|
|
|
27
|
|
|
$bootstrap = \Closure::bind( |
|
28
|
|
|
static function () { |
|
29
|
|
|
/** |
|
30
|
|
|
* @param string $message |
|
31
|
|
|
* @param string $noticeType |
|
32
|
|
|
* @param array $allowedMarkup |
|
33
|
|
|
*/ |
|
34
|
|
|
function adminNotice($message, $noticeType, array $allowedMarkup = []) |
|
35
|
|
|
{ |
|
36
|
|
|
\assert(\is_string($message) && \is_string($noticeType)); |
|
37
|
|
|
|
|
38
|
|
|
add_action( |
|
39
|
|
|
'admin_notices', |
|
40
|
|
|
function () use ($message, $noticeType, $allowedMarkup) { |
|
41
|
|
|
?> |
|
42
|
|
|
<div class="notice notice-<?= esc_attr($noticeType) ?>"> |
|
43
|
|
|
<p><?= wp_kses($message, $allowedMarkup) ?></p> |
|
44
|
|
|
</div> |
|
45
|
|
|
<?php |
|
46
|
|
|
} |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return bool |
|
52
|
|
|
*/ |
|
53
|
|
|
function autoload() |
|
54
|
|
|
{ |
|
55
|
|
|
if (\class_exists(PluginProperties::class)) { |
|
56
|
|
|
return true; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$autoloader = plugin_dir_path(__FILE__) . '/vendor/autoload.php'; |
|
60
|
|
|
|
|
61
|
|
|
if (!\file_exists($autoloader)) { |
|
62
|
|
|
return false; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** @noinspection PhpIncludeInspection */ |
|
66
|
|
|
require_once $autoloader; |
|
67
|
|
|
|
|
68
|
|
|
return true; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Compare PHP Version with our minimum. |
|
73
|
|
|
* |
|
74
|
|
|
* @return bool |
|
75
|
|
|
*/ |
|
76
|
|
|
function isPhpVersionCompatible() |
|
77
|
|
|
{ |
|
78
|
|
|
return PHP_VERSION_ID >= 70000; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
if (!isPhpVersionCompatible()) { |
|
82
|
|
|
adminNotice( |
|
83
|
|
|
sprintf( |
|
84
|
|
|
// Translators: %s is the PHP version of the current installation, where is the plugin is active. |
|
85
|
|
|
__( |
|
86
|
|
|
'Multisite Global Media require php version 7.0 at least. Your\'s is %s', |
|
87
|
|
|
'multisite-global-media' |
|
88
|
|
|
), |
|
89
|
|
|
PHP_VERSION |
|
90
|
|
|
), |
|
91
|
|
|
'error' |
|
92
|
|
|
); |
|
93
|
|
|
|
|
94
|
|
|
return; |
|
95
|
|
|
} |
|
96
|
|
|
if (!autoload()) { |
|
97
|
|
|
adminNotice( |
|
98
|
|
|
__( |
|
99
|
|
|
'No suitable autoloader found. Multisite Global Media cannot be loaded correctly.', |
|
100
|
|
|
'multisite-global-media' |
|
101
|
|
|
), |
|
102
|
|
|
'error' |
|
103
|
|
|
); |
|
104
|
|
|
|
|
105
|
|
|
return; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
$plugin = new Plugin(__FILE__); |
|
109
|
|
|
$plugin->onLoad(); |
|
110
|
|
|
}, null); |
|
111
|
|
|
$bootstrap(); |
|
112
|
|
|
|