-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobi-variation-stock-indicator.php
More file actions
49 lines (41 loc) · 1.34 KB
/
obi-variation-stock-indicator.php
File metadata and controls
49 lines (41 loc) · 1.34 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
<?php
/**
* Plugin Name: Obi Variation Stock Indicator
* Description: A WordPress plugin that displays the stock indicator for each variation of a product.
* Version: 1.0
* Author: Obi Juan
* Author URI: https://www.obijuan.dev
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: obi-variation-stock-indicator
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
// Define plugin constants
define('OVSI_VERSION', '1.0.0');
define('OVSI_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('OVSI_PLUGIN_URL', plugin_dir_url(__FILE__));
// Autoloader for plugin classes
spl_autoload_register(function ($class) {
// Project-specific namespace prefix
$prefix = 'OVSI\\';
$base_dir = OVSI_PLUGIN_DIR . 'includes/';
// Check if the class uses the namespace prefix
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
// Get the relative class name
$relative_class = substr($class, $len);
// Replace namespace separators with directory separators
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// If the file exists, require it
if (file_exists($file)) {
require $file;
}
});
// Initialize the plugin
add_action('plugins_loaded', function() {
OVSI\Plugin::get_instance();
});