-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanylabel.php
More file actions
133 lines (115 loc) · 3.37 KB
/
anylabel.php
File metadata and controls
133 lines (115 loc) · 3.37 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
/**
* Plugin Name: AnylabelWP
* Plugin URI: https://github.com/wpoperator/anylabelwp
* Description: White Label 3rd Party Plugins for WordPress. Perfect for agencies and WAAS providers.
* Version: 0.0.2
* Author: WPOperator
* Author URI: https://wpoperator.com
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: anylabelwp-plugin
* Domain Path: /languages
* Requires at least: 5.0
* Tested up to: 6.3
* Requires PHP: 7.4
* Network: false
* Update URI: https://github.com/wpoperator/anylabelwp
*
* @package AnylabelWP
* @author WPOperator
* @since 0.0.1
*/
// Escape if accessed directly
if (!defined('ABSPATH')) {
exit;
}
// Check minimum requirements
if (!anylabelwp_check_requirements()) {
return;
}
/**
* Check plugin requirements
*/
function anylabelwp_check_requirements() {
global $wp_version;
$min_wp = '5.0';
$min_php = '7.4';
if (version_compare(PHP_VERSION, $min_php, '<')) {
add_action('admin_notices', function() use ($min_php) {
echo '<div class="notice notice-error"><p>';
printf(
__('AnylabelWP requires PHP %s or higher. You are running PHP %s.', 'anylabelwp-plugin'),
$min_php,
PHP_VERSION
);
echo '</p></div>';
});
return false;
}
if (version_compare($wp_version, $min_wp, '<')) {
add_action('admin_notices', function() use ($min_wp) {
global $wp_version;
echo '<div class="notice notice-error"><p>';
printf(
__('AnylabelWP requires WordPress %s or higher. You are running WordPress %s.', 'anylabelwp-plugin'),
$min_wp,
$wp_version
);
echo '</p></div>';
});
return false;
}
return true;
}
// Version and filepath declarations
define('ANYLABELWP_VERSION', '0.0.2');
define('ANYLABELWP_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('ANYLABELWP_PLUGIN_URL', plugin_dir_url(__FILE__));
// Require the class autoloader
require_once ANYLABELWP_PLUGIN_DIR . 'includes/class-anylabelwp-loader.php';
// Strictly define is_plugin_active() function
if (!function_exists('is_plugin_active')) {
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
/**
* Initialize the plugin by instantiating the loader class.
*
* @return void
*/
function run_anylabelwp()
{
$plugin = new \AnylabelWP\Loader();
$plugin->run();
}
/**
* Plugin activation hook
*/
function anylabelwp_activate()
{
// Set default options
if (!get_option('anylabelwp_allowed_roles')) {
update_option('anylabelwp_allowed_roles', ['administrator']);
}
// Set activation notice
set_transient('anylabelwp_activation_notice', true, 30);
// Store activation time
if (!get_option('anylabelwp_activation_time')) {
update_option('anylabelwp_activation_time', time());
}
// Create any necessary database tables or options
flush_rewrite_rules();
}
/**
* Plugin deactivation hook
*/
function anylabelwp_deactivate()
{
// Clean up any temporary data, caches, etc.
flush_rewrite_rules();
}
// Register activation and deactivation hooks
register_activation_hook(__FILE__, 'anylabelwp_activate');
register_deactivation_hook(__FILE__, 'anylabelwp_deactivate');
// Load plugin
run_anylabelwp();