-
Notifications
You must be signed in to change notification settings - Fork 9
/
pinterest-for-woocommerce.php
155 lines (142 loc) · 4.68 KB
/
pinterest-for-woocommerce.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/**
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://woocommerce.com
* @since 1.0.0
* @package woocommerce/pinterest-for-woocommerce
*
* @wordpress-plugin
* Plugin Name: Pinterest for WooCommerce
* Plugin URI: https://woocommerce.com/products/pinterest-for-woocommerce/
* Description: Grow your business on Pinterest! Use this official plugin to allow shoppers to Pin products while browsing your store, track conversions, and advertise on Pinterest.
* Version: 1.4.6
* Author: WooCommerce
* Author URI: https://woocommerce.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: pinterest-for-woocommerce
* Domain Path: /i18n/languages
* Requires Plugins: woocommerce
*
* Requires at least: 5.6
* Tested up to: 6.6
* Requires PHP: 7.4
*
* WC requires at least: 6.3
* WC tested up to: 9.2
*/
/**
* Developer note: updating minimum PHP, WordPress and WooCommerce versions.
*
* When updating any version metadata above please ensure other files are updated
* as needed, for example:
* - `class-pinterest-for-woocommerce.php`
* - `phpcs.xml`
*/
use Automattic\WooCommerce\Utilities\FeaturesUtil;
// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'PINTEREST_FOR_WOOCOMMERCE_PLUGIN_FILE', __FILE__ );
define( 'PINTEREST_FOR_WOOCOMMERCE_VERSION', '1.4.6' ); // WRCS: DEFINED_VERSION.
// HPOS compatibility declaration.
add_action(
'before_woocommerce_init',
function () {
if ( class_exists( FeaturesUtil::class ) ) {
FeaturesUtil::declare_compatibility( 'custom_order_tables', plugin_basename( __FILE__ ) );
FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', plugin_basename( __FILE__ ) );
}
}
);
/**
* Autoload packages.
*
* The package autoloader includes version information which prevents classes in this feature plugin
* conflicting with WooCommerce core.
*
* We want to fail gracefully if `composer install` has not been executed yet, so we are checking for the autoloader.
* If the autoloader is not present, let's log the failure and display a nice admin notice.
*/
$autoloader = __DIR__ . '/vendor/autoload_packages.php';
if ( is_readable( $autoloader ) ) {
require $autoloader;
} else {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( // phpcs:ignore
sprintf(
/* translators: 1: composer command. 2: plugin directory */
esc_html__( 'Your installation of the Pinterest for WooCommerce plugin is incomplete. Please run %1$s within the %2$s directory.', 'pinterest-for-woocommerce' ),
'`composer install`',
'`' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '`'
)
);
}
/**
* Outputs an admin notice if composer install has not been ran.
*/
add_action(
'admin_notices',
function () {
?>
<div class="notice notice-error">
<p>
<?php
printf(
/* translators: 1: composer command. 2: plugin directory */
esc_html__( 'Your installation of the Pinterest for WooCommerce plugin is incomplete. Please run %1$s within the %2$s directory.', 'pinterest-for-woocommerce' ),
'<code>composer install</code>',
'<code>' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '</code>'
);
?>
</p>
</div>
<?php
}
);
return;
}
require_once 'class-pinterest-for-woocommerce.php';
/**
* Main instance of Pinterest_For_Woocommerce.
*
* Returns the main instance of Pinterest_For_Woocommerce to prevent the need to use globals.
*
* @since 1.0.0
* @return Pinterest_For_Woocommerce
*/
function Pinterest_For_Woocommerce() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
return Pinterest_For_Woocommerce::instance();
}
// Initiate the plugin.
Pinterest_For_Woocommerce();
// Register activation hook.
register_activation_hook(
__FILE__,
function () {
( new Automattic\WooCommerce\Pinterest\PluginActivate() )->activate();
}
);
// Register deactivation hook.
register_deactivation_hook(
PINTEREST_FOR_WOOCOMMERCE_PLUGIN_FILE,
function () {
Automattic\WooCommerce\Pinterest\ProductSync::cancel_jobs();
Automattic\WooCommerce\Pinterest\Heartbeat::cancel_jobs();
}
);
// Register deactivation hook for WooCommerce.
if ( defined( 'WC_PLUGIN_FILE' ) ) {
register_deactivation_hook(
WC_PLUGIN_FILE,
function () {
Automattic\WooCommerce\Pinterest\ProductSync::cancel_jobs();
Automattic\WooCommerce\Pinterest\Heartbeat::cancel_jobs();
}
);
}