-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
52 lines (39 loc) · 1.42 KB
/
bootstrap.php
File metadata and controls
52 lines (39 loc) · 1.42 KB
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
<?php
use Rockschtar\WordPress\Settings\Controller\SettingsController;
use Rockschtar\WordPress\Settings\Models\SettingsPage;
if (function_exists('plugin_dir_url')) {
if(!defined('RWPS_PLUGIN_DIR')) {
define('RWPS_PLUGIN_DIR', plugin_dir_path(__FILE__));
}
if(!defined('RWPS_PLUGIN_URL')) {
define('RWPS_PLUGIN_URL', plugin_dir_url(__FILE__));
}
}
if (function_exists('add_action')) {
static $actionsAdded = false;
if (!$actionsAdded) {
add_action('wp_loaded', static function () {
do_action('rswp_create_settings');
}, 1);
add_action('admin_action_rwps-load-script', static function () {
$allowed = ['AjaxButton.js', 'UploadMedia.js', 'UploadFile.js'];
$script = basename($_GET['script'] ?? '');
if (!in_array($script, $allowed, true)) {
wp_die('Not allowed', '', ['response' => 403]);
}
$file = __DIR__ . '/js/' . $script;
if (!file_exists($file)) {
wp_die('Not found', '', ['response' => 404]);
}
header('Content-Type: application/javascript');
readfile($file);
exit;
});
$actionsAdded = true;
}
}
if (!function_exists('rswp_register_settings_page')) {
function rswp_register_settings_page(SettingsPage $page) : void {
SettingsController::registerSettingsPage($page);
}
}