diff --git a/includes/class-wc-accommodation-bookings-plugin.php b/includes/class-wc-accommodation-bookings-plugin.php index 03568b02..e0c9451f 100644 --- a/includes/class-wc-accommodation-bookings-plugin.php +++ b/includes/class-wc-accommodation-bookings-plugin.php @@ -187,6 +187,16 @@ public function load_plugin_textdomain() { load_plugin_textdomain( 'woocommerce-accommodation-bookings', false, dirname( plugin_basename( $this->plugin_file ) ) . '/languages/' ); } + /** + * WooCommerce fallback notice. + * + * @since 1.2.1 + */ + public function missing_wc_notice() { + /* translators: %s WC download URL link. */ + echo '

' . sprintf( esc_html__( 'Accommodation Bookings requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-accommodation-bookings' ), 'WooCommerce' ) . '

'; + } + /** * Load Classes */ @@ -205,6 +215,12 @@ public function includes() { * Include admin */ public function admin_includes() { + // Return if WooCommerce class not found. + if ( ! class_exists( 'WooCommerce' ) ) { + add_action( 'admin_notices', array( $this, 'missing_wc_notice' ) ); + return; + } + include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-panels.php'; include WC_ACCOMMODATION_BOOKINGS_INCLUDES_PATH . 'admin/class-wc-accommodation-booking-admin-product-settings.php'; }