Skip to content

Commit a6d398a

Browse files
committed
2 parents 64b8115 + 0f4eb58 commit a6d398a

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

woocommerce-product-tables-feature-plugin.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,37 @@
2020
exit;
2121
}
2222

23-
define( 'WC_PRODUCT_TABLES_FILE', __FILE__ );
23+
/**
24+
* Admin notice for when WooCommerce not installed
25+
*
26+
* @return void
27+
*/
28+
function wc_custom_product_tables_need_wc() {
29+
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( 'notice notice-error' ), esc_html( 'You need to have WooCommerce 3.5 development version or above installed to run the Custom Product Tables plugin.', 'woocommerce' ) );
30+
}
31+
32+
/**
33+
* Bootstrap function, loads everything up.
34+
*
35+
* @return void
36+
*/
37+
function wc_custom_product_tables_bootstrap() {
38+
if ( ! class_exists( 'WooCommerce' ) ) {
39+
if ( is_admin() ) {
40+
add_action( 'admin_notices', 'wc_custom_product_tables_need_wc' );
41+
}
42+
return;
43+
}
44+
45+
if ( version_compare( WC_VERSION, '3.5.dev', '<' ) ) {
46+
WC_Admin_Notices::add_notice( __( 'You need WooCommerce 3.5 development version or higher to run the Custom Product Tables plugin.', 'woocommerce' ) );
47+
return;
48+
}
49+
50+
define( 'WC_PRODUCT_TABLES_FILE', __FILE__ );
51+
52+
// Include the main bootstrap class.
53+
require_once dirname( __FILE__ ) . '/includes/class-wc-product-tables-bootstrap.php';
54+
}
2455

25-
// Include the main bootstrap class.
26-
require_once dirname( __FILE__ ) . '/includes/class-wc-product-tables-bootstrap.php';
56+
add_action( 'plugins_loaded', 'wc_custom_product_tables_bootstrap' );

0 commit comments

Comments
 (0)