-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathmultisite-global-media.php
114 lines (97 loc) · 2.81 KB
/
multisite-global-media.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* Plugin Name: Multisite Global Media
* Description: Multisite Global Media is a WordPress plugin which shares media across the Multisite network.
* Network: true
* Plugin URI: https://github.com/bueltge/multisite-global-media
* Version: 0.2.0
* Author: Dominik Schilling, Frank Bültge, Guido Scialfa
* License: GPLv2+
* License URI: ./LICENSE
* Text Domain: multisite-global-media
* Domain Path: /languages
*
* Php Version 7
*
* @package WordPress
* @license https://opensource.org/licenses/GPL-2.0
* @version 2022-03-21
*/
# -*- coding: utf-8 -*-
declare(strict_types=1);
namespace MultisiteGlobalMedia;
// phpcs:disable
$bootstrap = \Closure::bind(
static function () {
/**
* @param string $message
* @param string $noticeType
* @param array $allowedMarkup
*/
function adminNotice($message, $noticeType, array $allowedMarkup = [])
{
\assert(\is_string($message) && \is_string($noticeType));
add_action(
'admin_notices',
function () use ($message, $noticeType, $allowedMarkup) {
?>
<div class="notice notice-<?= esc_attr($noticeType) ?>">
<p><?= wp_kses($message, $allowedMarkup) ?></p>
</div>
<?php
}
);
}
/**
* @return bool
*/
function autoload()
{
if (\class_exists(PluginProperties::class)) {
return true;
}
$autoloader = plugin_dir_path(__FILE__) . '/vendor/autoload.php';
if (!\file_exists($autoloader)) {
return false;
}
/** @noinspection PhpIncludeInspection */
require_once $autoloader;
return true;
}
/**
* Compare PHP Version with our minimum.
*
* @return bool
*/
function isPhpVersionCompatible()
{
return PHP_VERSION_ID >= 70000;
}
if (!isPhpVersionCompatible()) {
adminNotice(
sprintf(
// Translators: %s is the PHP version of the current installation, where is the plugin is active.
__(
'Multisite Global Media require php version 7.0 at least. Your\'s is %s',
'multisite-global-media'
),
PHP_VERSION
),
'error'
);
return;
}
if (!autoload()) {
adminNotice(
__(
'No suitable autoloader found. Multisite Global Media cannot be loaded correctly.',
'multisite-global-media'
),
'error'
);
return;
}
$plugin = new Plugin(__FILE__);
$plugin->onLoad();
}, null);
$bootstrap();