Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Avoid crash in InboxNotifications if woocommerce-admin is entirely di…
Browse files Browse the repository at this point in the history
…sabled. (#5954)

* Avoid calling plugin_dir_url a lot

* Fix crash if woocommerce admin is disabled

With Woocommerce's PR
woocommerce/woocommerce#31991 applied, if
woocommerce admin is disabled via the woocommerce_admin_disabled
filter, the InboxNotifications block could crash.

* Fix coding style

* Simplify code path

* Remove unused initialization
  • Loading branch information
colinleroy authored Mar 2, 2022
1 parent cdb966d commit adc8d05
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/InboxNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public static function delete_surface_cart_checkout_blocks_notification() {
* Creates a notification letting merchants know about the Cart and Checkout Blocks.
*/
public static function create_surface_cart_checkout_blocks_notification() {

// If this is the feature plugin, then we don't need to do this. This should only show when Blocks is bundled
// with WooCommerce Core.
if ( Package::feature()->is_feature_plugin_build() ) {
Expand All @@ -74,9 +73,12 @@ public static function create_surface_cart_checkout_blocks_notification() {
return;
}

if ( apply_filters( 'woocommerce_admin_disabled', false ) ) {
return;
}

$data_store = \WC_Data_Store::load( 'admin-note' );
$note_ids = $data_store->get_notes_with_name( self::SURFACE_CART_CHECKOUT_NOTE_NAME );

// Calculate store's eligibility to be shown the notice, starting with whether they have any plugins we know to
// be incompatible with Blocks. This check is done before checking if the note exists already because we want to
// delete the note if the merchant activates an ineligible plugin.
Expand Down

0 comments on commit adc8d05

Please sign in to comment.