-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpixmagix.php
119 lines (102 loc) · 3.15 KB
/
pixmagix.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
115
116
117
118
119
<?php
/**
* Plugin Name: PixMagix
* Plugin URI: https://pixmagixplugin.com/
* Description: Advanced image editor plugin for media images. Add filters, adjust brightness and contrast, crop and resize images, add text, and much more. Overall, PixMagix is a powerful tool for anyone looking to take their website's visual content to the next level.
* Version: 1.7.2
* Requires at least: 6.0.0
* Requires PHP: 7.0.0
* Author: Andras Tovishati
* Author URI: https://andrasweb.com/
* License: GPLv2
* Text Domain: pixmagix
*/
namespace AndrasWeb\PixMagix;
// Exit, if accessed directly.
if (!defined('ABSPATH')){
exit;
}
// Define constants.
define('PIXMAGIX_DIR', plugin_dir_path(__FILE__));
define('PIXMAGIX_URL', plugin_dir_url(__FILE__));
define('PIXMAGIX_VERSION', '1.7.2');
define('PIXMAGIX_REQUIRED_PHP_VERSION', '7.0.0');
define('PIXMAGIX_REQUIRED_WP_VERSION', '6.0.0');
// Load textdomain.
if (!function_exists(__NAMESPACE__ . '\\load_textdomain')){
function load_textdomain(){
load_plugin_textdomain('pixmagix', false, basename(dirname(__FILE__)) . '/languages');
}
add_action('plugins_loaded', __NAMESPACE__ . '\\load_textdomain');
}
// Load the plugin.
if (!version_compare(PHP_VERSION, PIXMAGIX_REQUIRED_PHP_VERSION, '>=')){
add_action('admin_notices', __NAMESPACE__ . '\\fail_php_version');
} elseif (!version_compare(get_bloginfo('version'), PIXMAGIX_REQUIRED_WP_VERSION, '>=')){
add_action('admin_notices', __NAMESPACE__ . '\\fail_wp_version');
} else {
if (!class_exists(__NAMESPACE__ . '\\Plugin')){
require_once PIXMAGIX_DIR . 'includes/init.php';
Plugin::run();
do_action('pixmagix_loaded');
}
}
/**
* Add admin notice if php version is lower than required.
* @since 1.0.0
*/
if (!function_exists(__NAMESPACE__ . '\\fail_php_version')){
function fail_php_version(){
$message = sprintf(
esc_html__(
'PixMagix requires PHP version %s+, plugin is currently NOT RUNNING.',
'pixmagix'
),
PIXMAGIX_REQUIRED_PHP_VERSION
);
$html_message = sprintf(
'<div class="error">%s</div>',
wpautop($message)
);
echo wp_kses_post($html_message);
}
}
/**
* Add admin notice if WordPress version is lower than required.
* @since 1.0.0
*/
if (!function_exists(__NAMESPACE__ . '\\fail_wp_version')){
function fail_wp_version(){
$message = sprintf(
esc_html__(
'PixMagix requires WordPress version %s+, plugin is currently NOT RUNNING.',
'pixmagix'
),
PIXMAGIX_REQUIRED_WP_VERSION
);
$html_message = sprintf(
'<div class="error">%s</div>',
wpautop($message)
);
echo wp_kses_post($html_message);
}
}
/**
* Register activation hook.
* @since 1.1.0
*/
if (!function_exists(__NAMESPACE__ . '\\plugin_activate')){
function plugin_activate(){
require_once PIXMAGIX_DIR . 'includes/utils-users.php';
$roles = array(
'administrator' => true,
'editor' => false,
'author' => false
);
foreach ($roles as $role => $allow_others){
Users\Utils\add_capabilities($role, $allow_others, $allow_others);
}
}
register_activation_hook(__FILE__, __NAMESPACE__ . '\\plugin_activate');
}
?>