-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin-core.php
More file actions
137 lines (117 loc) · 3.54 KB
/
plugin-core.php
File metadata and controls
137 lines (117 loc) · 3.54 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
134
135
136
137
<?php
/**
* Plugin Name: Plugin Core
* Plugin URI: https://plugin-core.com
* Description: A powerful WordPress plugin built with modern best practices
* Version: 1.0.0
* Requires at least: 5.0
* Tested up to: 6.4
* Requires PHP: 7.4
* Author: Your Name
* Author URI: https://your-website.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: plugin-core
* Domain Path: /languages
* Network: false
*
* @package Plugin_Core
* @since 1.0.0
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
// Define plugin constants
define('PLUGIN_CORE_VERSION', '1.0.0');
define('PLUGIN_CORE_NAME', 'Plugin Core');
define('PLUGIN_CORE_SLUG', 'plugin-core');
define('PLUGIN_CORE_TEXT_DOMAIN', 'plugin-core');
define('PLUGIN_CORE_PREFIX', 'plugin_core');
define('PLUGIN_CORE_PATH', plugin_dir_path(__FILE__));
define('PLUGIN_CORE_URL', plugin_dir_url(__FILE__));
define('PLUGIN_CORE_BASENAME', plugin_basename(__FILE__));
// Load configuration
if (file_exists(PLUGIN_CORE_PATH . 'config.php')) {
require_once PLUGIN_CORE_PATH . 'config.php';
}
// Load environment configuration
if (file_exists(PLUGIN_CORE_PATH . 'environment.php')) {
require_once PLUGIN_CORE_PATH . 'environment.php';
}
// Load Composer autoloader
if (file_exists(PLUGIN_CORE_PATH . 'vendor/autoload.php')) {
require_once PLUGIN_CORE_PATH . 'vendor/autoload.php';
}
/**
* Plugin activation hook
*/
function activate_plugin_core() {
// Check PHP version
if (version_compare(PHP_VERSION, '7.4', '<')) {
deactivate_plugins(plugin_basename(__FILE__));
wp_die('This plugin requires PHP 7.4 or higher.');
}
// Check WordPress version
if (version_compare(get_bloginfo('version'), '5.0', '<')) {
deactivate_plugins(plugin_basename(__FILE__));
wp_die('This plugin requires WordPress 5.0 or higher.');
}
// Include activator class
require_once PLUGIN_CORE_PATH . 'includes/class-activator.php';
// Run activation
Plugin_Core_Activator::activate();
// Flush rewrite rules
flush_rewrite_rules();
}
register_activation_hook(__FILE__, 'activate_plugin_core');
/**
* Plugin deactivation hook
*/
function deactivate_plugin_core() {
// Include deactivator class
require_once PLUGIN_CORE_PATH . 'includes/class-deactivator.php';
// Run deactivation
Plugin_Core_Deactivator::deactivate();
// Flush rewrite rules
flush_rewrite_rules();
}
register_deactivation_hook(__FILE__, 'deactivate_plugin_core');
/**
* Plugin uninstall hook
*/
function uninstall_plugin_core() {
// Include uninstall file
require_once PLUGIN_CORE_PATH . 'uninstall.php';
}
register_uninstall_hook(__FILE__, 'uninstall_plugin_core');
/**
* Load plugin providers
*/
function load_plugin_core_providers() {
// Load providers configuration
if (file_exists(PLUGIN_CORE_PATH . 'providers/config.php')) {
require_once PLUGIN_CORE_PATH . 'providers/config.php';
}
// Load providers manager
if (file_exists(PLUGIN_CORE_PATH . 'providers/index.php')) {
require_once PLUGIN_CORE_PATH . 'providers/index.php';
}
}
add_action('plugins_loaded', 'load_plugin_core_providers', 20);
/**
* Initialize the plugin
*/
function run_plugin_core() {
// Include the main plugin class
require_once PLUGIN_CORE_PATH . 'includes/class-include.php';
// Create and run the plugin
$plugin = new Plugin_Core();
$plugin->run();
}
// Run the plugin
run_plugin_core();
/**
* Plugin loaded action
*/
do_action('plugin_core_loaded');