Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/363 - Fatal Error when WooCommerce is disabled #367

Merged
merged 6 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions includes/class-wc-accommodation-bookings-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<div class="error"><p><strong>' . sprintf( esc_html__( 'Accommodation Bookings requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-accommodation-bookings' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
}

/**
* Load Classes
*/
Expand All @@ -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';
}
Expand Down
Loading