PluginProbe ʕ •ᴥ•ʔ
Meta for WooCommerce / 3.3.0
Meta for WooCommerce v3.3.0
3.7.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.11.1 1.11.2 1.11.3 1.11.4 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.4.0 2.4.1 2.5.0 2.5.1 2.6.0 2.6.1 2.6.10 2.6.11 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.18 2.6.19 2.6.2 2.6.20 2.6.21 2.6.22 2.6.23 2.6.24 2.6.25 2.6.26 2.6.27 2.6.28 2.6.29 2.6.3 2.6.30 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.24 3.0.25 3.0.26 3.0.27 3.0.28 3.0.29 3.0.3 3.0.30 3.0.31 3.0.32 3.0.33 3.0.34 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.4.0 3.4.1 3.4.10 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.10 3.5.11 3.5.12 3.5.13 3.5.14 3.5.15 3.5.16 3.5.17 3.5.18 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.6.3 3.7.0
facebook-for-woocommerce / facebook-for-woocommerce.php
facebook-for-woocommerce Last commit date
assets 1 year ago data 2 years ago i18n 1 year ago includes 1 year ago vendor 1 year ago LICENSE 7 years ago changelog.txt 1 year ago class-wc-facebookcommerce.php 1 year ago facebook-commerce-events-tracker.php 1 year ago facebook-commerce-pixel-event.php 2 years ago facebook-commerce.php 1 year ago facebook-config-warmer.php 3 years ago facebook-for-woocommerce.php 1 year ago readme.txt 1 year ago
facebook-for-woocommerce.php
327 lines
1 <?php
2 // phpcs:ignoreFile
3 /**
4 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
5 *
6 * This source code is licensed under the license found in the
7 * LICENSE file in the root directory of this source tree.
8 *
9 * Plugin Name: Facebook for WooCommerce
10 * Plugin URI: https://github.com/woocommerce/facebook-for-woocommerce/
11 * Description: Grow your business on Facebook! Use this official plugin to help sell more of your products using Facebook. After completing the setup, you'll be ready to create ads that promote your products and you can also create a shop section on your Page where customers can browse your products on Facebook.
12 * Author: Facebook
13 * Author URI: https://www.facebook.com/
14 * Version: 3.3.0
15 * Requires at least: 5.6
16 * Requires PHP: 7.4
17 * Text Domain: facebook-for-woocommerce
18 * Requires Plugins: woocommerce
19 * Tested up to: 6.7
20 * WC requires at least: 6.4
21 * WC tested up to: 9.4
22 *
23 * @package FacebookCommerce
24 */
25
26 require_once __DIR__ . '/vendor/autoload.php';
27
28 use Automattic\WooCommerce\Grow\Tools\CompatChecker\v0_0_1\Checker;
29 use Automattic\WooCommerce\Utilities\FeaturesUtil;
30
31 defined( 'ABSPATH' ) || exit;
32
33 // HPOS compatibility declaration.
34 add_action(
35 'before_woocommerce_init',
36 function() {
37 if ( class_exists( FeaturesUtil::class ) ) {
38 FeaturesUtil::declare_compatibility( 'custom_order_tables', plugin_basename( __FILE__ ), true );
39 }
40 }
41 );
42 /**
43 * The plugin loader class.
44 *
45 * @since 1.10.0
46 */
47 class WC_Facebook_Loader {
48
49 /**
50 * @var string the plugin version. This must be in the main plugin file to be automatically bumped by Woorelease.
51 */
52 const PLUGIN_VERSION = '3.3.0'; // WRCS: DEFINED_VERSION.
53
54 // Minimum PHP version required by this plugin.
55 const MINIMUM_PHP_VERSION = '7.4.0';
56
57 // Minimum WordPress version required by this plugin.
58 const MINIMUM_WP_VERSION = '4.4';
59
60 // Minimum WooCommerce version required by this plugin.
61 const MINIMUM_WC_VERSION = '5.3';
62
63 // SkyVerge plugin framework version used by this plugin.
64 const FRAMEWORK_VERSION = '5.10.0';
65
66 // The plugin name, for displaying notices.
67 const PLUGIN_NAME = 'Facebook for WooCommerce';
68
69
70 /**
71 * This class instance.
72 *
73 * @var \WC_Facebook_Loader single instance of this class.
74 */
75 private static $instance;
76
77 /**
78 * Admin notices to add.
79 *
80 * @var array Array of admin notices.
81 */
82 private $notices = array();
83
84
85 /**
86 * Constructs the class.
87 *
88 * @since 1.10.0
89 */
90 protected function __construct() {
91
92 register_activation_hook( __FILE__, array( $this, 'activation_check' ) );
93
94 add_action( 'admin_init', array( $this, 'check_environment' ) );
95
96 add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 );
97
98 // If the environment check fails, initialize the plugin.
99 if ( $this->is_environment_compatible() ) {
100 add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
101 }
102 }
103
104
105 /**
106 * Cloning instances is forbidden due to singleton pattern.
107 *
108 * @since 1.10.0
109 */
110 public function __clone() {
111
112 wc_doing_it_wrong( __FUNCTION__, sprintf( 'You cannot clone instances of %s.', get_class( $this ) ), '1.10.0' );
113 }
114
115
116 /**
117 * Unserializing instances is forbidden due to singleton pattern.
118 *
119 * @since 1.10.0
120 */
121 public function __wakeup() {
122
123 wc_doing_it_wrong( __FUNCTION__, sprintf( 'You cannot unserialize instances of %s.', get_class( $this ) ), '1.10.0' );
124 }
125
126
127 /**
128 * Initializes the plugin.
129 *
130 * @since 1.10.0
131 */
132 public function init_plugin() {
133
134 if ( ! Checker::instance()->is_compatible( __FILE__, self::PLUGIN_VERSION ) ) {
135 return;
136 }
137
138 require_once plugin_dir_path( __FILE__ ) . 'class-wc-facebookcommerce.php';
139
140 // fire it up!
141 if ( function_exists( 'facebook_for_woocommerce' ) ) {
142 facebook_for_woocommerce();
143 }
144 }
145
146
147 /**
148 * Gets the framework version in namespace form.
149 *
150 * @since 1.10.0
151 *
152 * @return string
153 */
154 public function get_framework_version_namespace() {
155 return 'v' . str_replace( '.', '_', $this->get_framework_version() );
156 }
157
158
159 /**
160 * Gets the framework version used by this plugin.
161 *
162 * @since 1.10.0
163 *
164 * @return string
165 */
166 public function get_framework_version() {
167
168 return self::FRAMEWORK_VERSION;
169 }
170
171
172 /**
173 * Checks the server environment and other factors and deactivates plugins as necessary.
174 *
175 * Based on http://wptavern.com/how-to-prevent-wordpress-plugins-from-activating-on-sites-with-incompatible-hosting-environments
176 *
177 * @internal
178 *
179 * @since 1.10.0
180 */
181 public function activation_check() {
182
183 if ( ! $this->is_environment_compatible() ) {
184
185 $this->deactivate_plugin();
186
187 wp_die( esc_html( self::PLUGIN_NAME . ' could not be activated. ' . $this->get_environment_message() ) );
188 }
189 }
190
191
192 /**
193 * Checks the environment on loading WordPress, just in case the environment changes after activation.
194 *
195 * @internal
196 *
197 * @since 1.10.0
198 */
199 public function check_environment() {
200
201 if ( ! $this->is_environment_compatible() && is_plugin_active( plugin_basename( __FILE__ ) ) ) {
202
203 $this->deactivate_plugin();
204
205 $this->add_admin_notice( 'bad_environment', 'error', self::PLUGIN_NAME . ' has been deactivated. ' . $this->get_environment_message() );
206 }
207 }
208
209
210 /**
211 * Deactivates the plugin.
212 *
213 * @internal
214 *
215 * @since 1.10.0
216 */
217 protected function deactivate_plugin() {
218
219 deactivate_plugins( plugin_basename( __FILE__ ) );
220
221 if ( isset( $_GET['activate'] ) ) {
222 unset( $_GET['activate'] );
223 }
224 }
225
226
227 /**
228 * Adds an admin notice to be displayed.
229 *
230 * @since 1.10.0
231 *
232 * @param string $slug The slug for the notice.
233 * @param string $class The css class for the notice.
234 * @param string $message The notice message.
235 */
236 private function add_admin_notice( $slug, $class, $message ) {
237
238 $this->notices[ $slug ] = array(
239 'class' => $class,
240 'message' => $message,
241 );
242 }
243
244
245 /**
246 * Displays any admin notices added with \WC_Facebook_Loader::add_admin_notice()
247 *
248 * @internal
249 *
250 * @since 1.10.0
251 */
252 public function admin_notices() {
253
254 foreach ( (array) $this->notices as $notice_key => $notice ) {
255
256 ?>
257 <div class="<?php echo esc_attr( $notice['class'] ); ?>">
258 <p>
259 <?php
260 echo wp_kses(
261 $notice['message'],
262 array(
263 'a' => array(
264 'href' => array(),
265 ),
266 'strong' => array(),
267 )
268 );
269 ?>
270 </p>
271 </div>
272 <?php
273 }
274 }
275
276
277 /**
278 * Determines if the server environment is compatible with this plugin.
279 *
280 * Override this method to add checks for more than just the PHP version.
281 *
282 * @since 1.10.0
283 *
284 * @return bool
285 */
286 private function is_environment_compatible() {
287 return version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '>=' );
288 }
289
290
291 /**
292 * Gets the message for display when the environment is incompatible with this plugin.
293 *
294 * @since 1.10.0
295 *
296 * @return string
297 */
298 private function get_environment_message() {
299
300 return sprintf( 'The minimum PHP version required for this plugin is %1$s. You are running %2$s.', self::MINIMUM_PHP_VERSION, PHP_VERSION );
301 }
302
303
304 /**
305 * Gets the main \WC_Facebook_Loader instance.
306 *
307 * Ensures only one instance can be loaded.
308 *
309 * @since 1.10.0
310 *
311 * @return \WC_Facebook_Loader
312 */
313 public static function instance() {
314
315 if ( null === self::$instance ) {
316 self::$instance = new self();
317 }
318
319 return self::$instance;
320 }
321
322
323 }
324
325 // fire it up!
326 WC_Facebook_Loader::instance();
327