ACF.php
2 days ago
BeaverBuilder.php
2 days ago
BuddyPress.php
2 days ago
EventsCalendar.php
2 days ago
Filter.php
2 days ago
GravityForms.php
2 days ago
IntegrationRepository.php
2 days ago
JetEngine.php
2 days ago
MediaLibraryAssistant.php
2 days ago
MetaBox.php
2 days ago
Pods.php
2 days ago
RankMath.php
2 days ago
SeoPress.php
2 days ago
Types.php
2 days ago
WooCommerce.php
2 days ago
YoastSeo.php
2 days ago
WooCommerce.php
76 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Integration; |
| 6 | |
| 7 | use AC; |
| 8 | use AC\Screen; |
| 9 | use AC\TableScreen; |
| 10 | use AC\Type\Integration; |
| 11 | use AC\Type\Url\Site; |
| 12 | |
| 13 | final class WooCommerce extends Integration |
| 14 | { |
| 15 | public function __construct() |
| 16 | { |
| 17 | parent::__construct( |
| 18 | 'ac-addon-woocommerce', |
| 19 | __('WooCommerce', 'codepress-admin-columns'), |
| 20 | 'assets/images/addons/woocommerce-icon.png', |
| 21 | __( |
| 22 | 'Manage products, orders, coupons, and subscriptions from one screen. Bulk edit prices, stock, and SKUs. Filter orders by any field, then export the results to CSV in one click.', |
| 23 | 'codepress-admin-columns' |
| 24 | ), |
| 25 | null, |
| 26 | new Site(Site::PAGE_ADDON_WOOCOMMERCE) |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | public function is_plugin_active(): bool |
| 31 | { |
| 32 | return AC\WooCommerce::is_active(); |
| 33 | } |
| 34 | |
| 35 | private function get_post_types(): array |
| 36 | { |
| 37 | return [ |
| 38 | 'product', |
| 39 | 'shop_order', |
| 40 | 'shop_coupon', |
| 41 | 'shop_subscription', |
| 42 | ]; |
| 43 | } |
| 44 | |
| 45 | public function show_notice(Screen $screen): bool |
| 46 | { |
| 47 | $is_user_screen = 'users' === $screen->get_id(); |
| 48 | $is_post_screen = 'edit' === $screen->get_base() |
| 49 | && in_array($screen->get_post_type(), $this->get_post_types(), true); |
| 50 | $is_order_screen = 'woocommerce_page_wc-orders' === $screen->get_id(); |
| 51 | |
| 52 | return $is_user_screen || $is_post_screen || $is_order_screen; |
| 53 | } |
| 54 | |
| 55 | private function get_list_keys(): array |
| 56 | { |
| 57 | $keys = [ |
| 58 | 'wp-users', |
| 59 | 'wc_order', |
| 60 | 'wc_order_subscription', |
| 61 | ]; |
| 62 | |
| 63 | foreach ($this->get_post_types() as $post_type) { |
| 64 | $keys[] = $post_type; |
| 65 | } |
| 66 | |
| 67 | return $keys; |
| 68 | } |
| 69 | |
| 70 | public function show_placeholder(TableScreen $table_screen): bool |
| 71 | { |
| 72 | return in_array((string)$table_screen->get_id(), $this->get_list_keys(), true); |
| 73 | } |
| 74 | |
| 75 | } |
| 76 |