MediaLibraryAssistant
1 day ago
AdvancedCustomFields.php
1 day ago
NinjaForms.php
1 day ago
WPML.php
1 day ago
WPMLColumn.php
1 day ago
WooCommerce.php
1 day ago
WooCommerce.php
61 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\ThirdParty; |
| 6 | |
| 7 | use AC; |
| 8 | use AC\Registerable; |
| 9 | use AC\Type\Url\Site; |
| 10 | use AC\Type\Url\UtmTags; |
| 11 | use Automattic\WooCommerce\Utilities\OrderUtil; |
| 12 | |
| 13 | class WooCommerce implements Registerable |
| 14 | { |
| 15 | public function register(): void |
| 16 | { |
| 17 | add_filter('ac/post_types', [$this, 'remove_webhook']); |
| 18 | add_filter('ac/admin/screen_notices', [$this, 'add_hpos_notice']); |
| 19 | } |
| 20 | |
| 21 | public function remove_webhook($post_types) |
| 22 | { |
| 23 | if (AC\WooCommerce::is_active()) { |
| 24 | unset($post_types['shop_webhook']); |
| 25 | } |
| 26 | |
| 27 | return $post_types; |
| 28 | } |
| 29 | |
| 30 | public function add_hpos_notice(array $notices): array |
| 31 | { |
| 32 | if (! $this->is_hpos_enabled()) { |
| 33 | return $notices; |
| 34 | } |
| 35 | |
| 36 | $notices[] = [ |
| 37 | 'list_key' => 'shop_order', |
| 38 | 'type' => 'info', |
| 39 | 'message' => sprintf( |
| 40 | __( |
| 41 | 'WooCommerce is using %s on your site. Columns configured here won\'t appear on the Orders screen. Upgrade to Admin Columns Pro for full order management with HPOS support.', |
| 42 | 'codepress-admin-columns' |
| 43 | ), |
| 44 | '<strong>' . __('High-Performance Order Storage', 'codepress-admin-columns') . '</strong>' |
| 45 | ), |
| 46 | 'cta_label' => __('Upgrade to Admin Columns Pro', 'codepress-admin-columns'), |
| 47 | 'cta_url' => (new UtmTags(new Site(Site::PAGE_ADDON_WOOCOMMERCE), 'hpos-notice'))->get_url(), |
| 48 | 'locked' => true, |
| 49 | ]; |
| 50 | |
| 51 | return $notices; |
| 52 | } |
| 53 | |
| 54 | private function is_hpos_enabled(): bool |
| 55 | { |
| 56 | return class_exists(OrderUtil::class) |
| 57 | && OrderUtil::custom_orders_table_usage_is_enabled(); |
| 58 | } |
| 59 | |
| 60 | } |
| 61 |