-
Notifications
You must be signed in to change notification settings - Fork 6
/
product-specifications.php
101 lines (86 loc) · 2.78 KB
/
product-specifications.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
<?php
/**
* Plugin Name: Product Specifications for WooCommerce
* Plugin URI: https://github.com/dornaweb/product-specifications/
* Description: This plugin adds a product specifications table to your woocommerce products.
* Version: 0.8.7
* Author: Amin Abdolrezapoor
* Author URI: https://amin.nz
* License: GPL-2.0+
* Requires Plugins: woocommerce
* Requires PHP: 7.4
* Requires at least: 5.9
* WC tested up to: 9.3.3
* WC requires at least: 8.0.0
*/
declare(strict_types=1);
namespace Amiut\ProductSpecs;
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
use Inpsyde\Modularity\Package;
use Inpsyde\Modularity\Properties\PluginProperties;
use Throwable;
defined('ABSPATH') || exit;
if (!defined('DWSPECS_PLUGIN_FILE')) {
define('DWSPECS_PLUGIN_FILE', __FILE__);
}
function handleFailure(Throwable $throwable): void
{
add_action(
'all_admin_notices',
static function () use ($throwable) {
$class = 'notice notice-error';
printf(
'<div class="%s"><p>%s</p></div>',
esc_attr($class),
wp_kses_post(
sprintf(
'<strong>Error:</strong> %s <br><pre>%s</pre>',
$throwable->getMessage(),
$throwable->getTraceAsString()
)
)
);
}
);
}
function setupAutoLoader(): void
{
if (class_exists(Content\Module::class)) {
return;
}
if (is_readable(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
}
}
function bootstrap(): void
{
try {
setupAutoLoader();
$plugin = Package::new(
PluginProperties::new(__FILE__)
);
App::instance();
$plugin
->addModule(new Assets\Module())
->addModule(new Template\Module())
->addModule(new Repository\Module())
->addModule(new Content\Module())
->addModule(new Admin\Module())
->addModule(new AttributesListUi\Module())
->addModule(new AttributeGroupsListUi\Module())
->addModule(new ImportExport\Module())
->addModule(new Settings\Module())
->addModule(new Integration\Module())
->addModule(new Attribute\Module())
->addModule(new Shortcode\Module())
->addModule(new Metabox\Module())
->addModule(new EntityUpdater\Module())
->addModule(new EntityUpdaterUi\Module())
->addModule(new ProductSpecifications\Module())
->addModule(new SpecificationsTable\Module())
->boot();
} catch (Throwable $throwable) {
handleFailure($throwable);
}
}
add_action('plugins_loaded', __NAMESPACE__ . '\\bootstrap');