-
Notifications
You must be signed in to change notification settings - Fork 21
/
google-listings-and-ads.php
113 lines (101 loc) · 2.83 KB
/
google-listings-and-ads.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
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* Plugin Name: Google for WooCommerce
* Plugin URL: https://wordpress.org/plugins/google-listings-and-ads/
* Description: Native integration with Google that allows merchants to easily display their products across Google’s network.
* Version: 2.8.7
* Author: WooCommerce
* Author URI: https://woocommerce.com/
* Text Domain: google-listings-and-ads
* Requires at least: 5.9
* Tested up to: 6.7
* Requires PHP: 7.4
* Requires PHP Architecture: 64 bits
* Requires Plugins: woocommerce
* WC requires at least: 6.9
* WC tested up to: 9.4
* Woo:
*
* @package WooCommerce\Admin
*/
use Automattic\Jetpack\Config;
use Automattic\WooCommerce\GoogleListingsAndAds\Container;
use Automattic\WooCommerce\GoogleListingsAndAds\Autoloader;
use Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements\PluginValidator;
use Automattic\WooCommerce\GoogleListingsAndAds\Internal\Requirements\VersionValidator;
use Automattic\WooCommerce\GoogleListingsAndAds\PluginFactory;
use Automattic\WooCommerce\GoogleListingsAndAds\Vendor\Psr\Container\ContainerInterface;
use Automattic\WooCommerce\Utilities\FeaturesUtil;
defined( 'ABSPATH' ) || exit;
define( 'WC_GLA_VERSION', '2.8.7' ); // WRCS: DEFINED_VERSION.
define( 'WC_GLA_MIN_PHP_VER', '7.4' );
define( 'WC_GLA_MIN_WC_VER', '6.9' );
// Load and initialize the autoloader.
require_once __DIR__ . '/src/Autoloader.php';
if ( ! Autoloader::init() ) {
return;
}
// Validate PHP Version and Architecture
if ( ! VersionValidator::instance()->validate() ) {
return;
}
// Register activation hook
register_activation_hook(
__FILE__,
function () {
PluginFactory::instance()->activate();
}
);
// HPOS compatibility declaration.
add_action(
'before_woocommerce_init',
function () {
if ( class_exists( FeaturesUtil::class ) ) {
FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__ );
FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__ );
FeaturesUtil::declare_compatibility( 'product_block_editor', __FILE__ );
}
}
);
// Hook much of our plugin after WooCommerce is loaded.
add_action(
'woocommerce_loaded',
function () {
PluginFactory::instance()->register();
},
1
);
// Register deactivation hook
register_deactivation_hook(
__FILE__,
function () {
PluginFactory::instance()->deactivate();
}
);
/**
* Get our main container object.
*
* @return ContainerInterface
*/
function woogle_get_container(): ContainerInterface {
static $container = null;
if ( null === $container ) {
$container = new Container();
}
return $container;
}
/**
* Jetpack-config will initialize the modules on "plugins_loaded" with priority 2,
* so this code needs to be run before that.
*/
add_action(
'plugins_loaded',
function () {
// Check requirements.
if ( ! PluginValidator::validate() ) {
return;
}
woogle_get_container()->get( Config::class );
},
1
);