diff --git a/multisite-global-media.php b/multisite-global-media.php index 23ed140..9498048 100644 --- a/multisite-global-media.php +++ b/multisite-global-media.php @@ -109,7 +109,6 @@ function bootstrap() $assets = new Assets($pluginProperties); $attachment = new Attachment($site, $singleSwitcher); $thumbnail = new Thumbnail($site, $singleSwitcher); - $wooCommerceGallery = new WooCommerce\Gallery($site, $singleSwitcher); add_action('admin_enqueue_scripts', [$assets, 'enqueueScripts']); add_action('admin_enqueue_scripts', [$assets, 'enqueueStyles']); @@ -124,6 +123,12 @@ function bootstrap() add_filter('admin_post_thumbnail_html', [$thumbnail, 'adminPostThumbnailHtml'], 99, 3); add_filter('post_thumbnail_html', [$thumbnail, 'postThumbnailHtml'], 99, 5); + if (!function_exists('wc')) { + return; + } + + $wooCommerceGallery = new WooCommerce\Gallery($site, $singleSwitcher); + add_action('woocommerce_new_product', [$wooCommerceGallery, 'saveGalleryIds']); add_action('woocommerce_update_product', [$wooCommerceGallery, 'saveGalleryIds']); add_action('add_meta_boxes', [$wooCommerceGallery, 'overrideMetaboxCallback'], PHP_INT_MAX);