From 55ebf25b91204474a19eff5b02fa685cfe714f51 Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Mon, 4 Sep 2023 15:35:42 +0530 Subject: [PATCH 1/4] Fix/363 - Fatal Error when WooCommerce is disabled --- .../class-wc-accommodation-bookings-plugin.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/includes/class-wc-accommodation-bookings-plugin.php b/includes/class-wc-accommodation-bookings-plugin.php index 03568b02..67edd25c 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 x.x.x + */ + public function woocommerce_accommodation_bookings_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,13 @@ 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, 'woocommerce_accommodation_bookings_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'; } From b12d56f389c25d556d311e165438448b5ea033d7 Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Wed, 6 Sep 2023 15:35:20 +0530 Subject: [PATCH 2/4] removing the prefix --- includes/class-wc-accommodation-bookings-plugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-accommodation-bookings-plugin.php b/includes/class-wc-accommodation-bookings-plugin.php index 67edd25c..6e03d878 100644 --- a/includes/class-wc-accommodation-bookings-plugin.php +++ b/includes/class-wc-accommodation-bookings-plugin.php @@ -192,7 +192,7 @@ public function load_plugin_textdomain() { * * @since x.x.x */ - public function woocommerce_accommodation_bookings_missing_wc_notice() { + 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' ) . '

'; } @@ -218,7 +218,7 @@ public function admin_includes() { // Return if WooCommerce class not found. if ( ! class_exists( 'WooCommerce' ) ) { - add_action( 'admin_notices', array( $this, 'woocommerce_accommodation_bookings_missing_wc_notice' ) ); + add_action( 'admin_notices', array( $this, 'missing_wc_notice' ) ); return; } From 8162df8857e38e8bc6a39d56f360b07256710ae1 Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Wed, 6 Sep 2023 15:36:09 +0530 Subject: [PATCH 3/4] remove extra line --- includes/class-wc-accommodation-bookings-plugin.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/class-wc-accommodation-bookings-plugin.php b/includes/class-wc-accommodation-bookings-plugin.php index 6e03d878..5fd7b087 100644 --- a/includes/class-wc-accommodation-bookings-plugin.php +++ b/includes/class-wc-accommodation-bookings-plugin.php @@ -215,7 +215,6 @@ 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' ) ); From 6a23dd42ad9679eb4a34c03a710906ef685931ee Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Mon, 18 Sep 2023 13:34:32 -0600 Subject: [PATCH 4/4] Update `@since` version --- includes/class-wc-accommodation-bookings-plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-accommodation-bookings-plugin.php b/includes/class-wc-accommodation-bookings-plugin.php index 5fd7b087..e0c9451f 100644 --- a/includes/class-wc-accommodation-bookings-plugin.php +++ b/includes/class-wc-accommodation-bookings-plugin.php @@ -190,7 +190,7 @@ public function load_plugin_textdomain() { /** * WooCommerce fallback notice. * - * @since x.x.x + * @since 1.2.1 */ public function missing_wc_notice() { /* translators: %s WC download URL link. */