-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheveeno.php
105 lines (89 loc) · 3.34 KB
/
eveeno.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
<?php
/*
Plugin Name: Eveeno
Plugin URI: https://github.com/cassandre/eveeno-wp
Version: 2.1
Description: WordPress plugin for embedding eveeno registration forms and upcoming events lists
Author: Barbara Bothe
Author URI: https://barbara-bothe.de
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
namespace Eveeno;
include "includes/Shortcode.php";
// Load the plugin's text domain for localization.
add_action('init', fn() => load_plugin_textdomain('eveeno', false, dirname(plugin_basename(__FILE__)) . '/languages'));
register_activation_hook(__FILE__, __NAMESPACE__ . '\activation');
register_deactivation_hook(__FILE__, __NAMESPACE__ . '\deactivation');
add_action('plugins_loaded', __NAMESPACE__ . '\loaded');
const EVEENO_PHP_VERSION = '8.0';
const EVEENO_WP_VERSION = '6.2';
const EVEENO_PLUGIN_VERSION = '2.1';
function systemRequirements(): string {
global $wp_version;
// Strip off any -alpha, -RC, -beta, -src suffixes.
[$wpVersion] = explode('-', $wp_version);
$phpVersion = phpversion();
$error = '';
if (!is_php_version_compatible(EVEENO_PHP_VERSION)) {
$error = sprintf(
/* translators: 1: Server PHP version number, 2: Required PHP version number. */
__('The server is running PHP version %1$s. The Plugin requires at least PHP version %2$s.', 'eveeno'),
$phpVersion,
EVEENO_PHP_VERSION
);
} elseif (!is_wp_version_compatible(EVEENO_WP_VERSION)) {
$error = sprintf(
/* translators: 1: Server WordPress version number, 2: Required WordPress version number. */
__('The server is running WordPress version %1$s. The Plugin requires at least WordPress version %2$s.', 'eveeno'),
$wpVersion,
EVEENO_PHP_VERSION
);
}
return $error;
}
/*
* Wird durchgeführt, wenn das Plugin aktiviert wird.
* @return void
*/
function activation() {
if ($error = systemRequirements()) {
deactivate_plugins(plugin_basename(__FILE__));
wp_die(
sprintf(
/* translators: 1: The plugin name, 2: The error string. */
esc_html__('Plugins: %1$s: %2$s', 'eveeno'),
esc_html(plugin_basename(__FILE__)),
esc_html($error)
)
);
}
}
/*
* Wird durchgeführt, wenn das Plugin deaktiviert wird
* @return void
*/
function deactivation() { }
function loaded() {
if ($error = systemRequirements()) {
add_action('admin_init', function () use ($error) {
if (current_user_can('activate_plugins')) {
$pluginData = get_plugin_data(__FILE__);
$pluginName = $pluginData['Name'];
$tag = is_plugin_active_for_network('eveeno') ? 'network_admin_notices' : 'admin_notices';
add_action($tag, function () use ($pluginName, $error) {
printf(
'<div class="notice notice-error"><p>' .
/* translators: 1: The plugin name, 2: The error string. */
esc_html__('Plugins: %1$s: %2$s', 'eveeno') .
'</p></div>',
esc_html($pluginName),
esc_html($error)
);
});
}
});
return;
}
new Shortcode();
}