WooCommerce.php
1.44 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
<?php
namespace ACA\WC;
use AC;
use AC\Registerable;
use ACA\WC\QuickAdd;
use ACP;
final class WooCommerce implements Registerable {
private $location;
public function __construct( AC\Asset\Location\Absolute $location ) {
$this->location = $location;
}
public function register() {
if ( ! class_exists( 'WooCommerce', false ) ) {
return;
}
ACP\QuickAdd\Model\Factory::add_factory( new QuickAdd\Factory() );
$services = [
new TableScreen( $this->location, $this->use_product_variations() ),
new Subscriptions(),
new Rounding(),
new Admin( $this->location ),
new Service\Columns(),
new Service\Editing(),
new Service\QuickAdd(),
new Service\Table(),
new Service\ColumnGroups(),
new Service\ListScreenGroups(),
new Service\ListScreens( $this->use_product_variations() ),
new ACP\Service\Templates( $this->location->get_path() . '/' ),
new ACP\Service\IntegrationStatus( 'ac-addon-woocommerce' ),
];
if ( $this->use_product_variations() ) {
$services[] = new PostType\ProductVariation( $this->location );
}
array_map(
static function ( Registerable $service ) {
$service->register();
},
$services
);
}
private function use_product_variations(): bool {
return apply_filters( 'acp/wc/show_product_variations', true ) && $this->is_wc_version_gte( '3.3' );
}
private function is_wc_version_gte( string $version ): bool {
return version_compare( WC()->version, $version, '>=' );
}
}