FsiePluginAdvertMetabox.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FS\AdvertMetabox; |
| 4 | |
| 5 | use FSVendor\Octolize\Brand\Assets\AdminAssets; |
| 6 | use FSVendor\Octolize\Brand\UpsellingBox\SettingsSidebar; |
| 7 | use FSVendor\Octolize\Brand\UpsellingBox\ShippingMethodInstanceShouldShowStrategy; |
| 8 | use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable; |
| 9 | use FSVendor\WPDesk\PluginBuilder\Plugin\HookableCollection; |
| 10 | use FSVendor\WPDesk\PluginBuilder\Plugin\HookableParent; |
| 11 | use WPDesk\FS\TableRate\ShippingMethodSingle; |
| 12 | |
| 13 | |
| 14 | class FsiePluginAdvertMetabox implements Hookable, HookableCollection { |
| 15 | |
| 16 | use HookableParent; |
| 17 | |
| 18 | private string $assets_url; |
| 19 | |
| 20 | public function __construct( string $assets_url ) { |
| 21 | $this->assets_url = $assets_url; |
| 22 | } |
| 23 | |
| 24 | public function hooks() { |
| 25 | if ( ! defined( 'FLEXIBLE_SHIPPING_PRO_VERSION' ) || defined( 'FLEXIBLE_SHIPPING_IMPORT_EXPORT_VERSION' ) ) { |
| 26 | |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | $should_show_strategy = new ShippingMethodInstanceShouldShowStrategy( new \WC_Shipping_Zones(), ShippingMethodSingle::SHIPPING_METHOD_ID ); |
| 31 | $this->add_hookable( new AdminAssets( $this->assets_url, 'fs', $should_show_strategy ) ); |
| 32 | add_action( |
| 33 | 'admin_init', |
| 34 | function () use ( $should_show_strategy ) { |
| 35 | ( new SettingsSidebar( |
| 36 | 'woocommerce_settings_tabs_shipping', |
| 37 | $should_show_strategy, |
| 38 | __( 'Extend the Flexible Shipping capabilities with functional add-ons', 'flexible-shipping' ), |
| 39 | [ |
| 40 | __( 'Calculate the shipping cost based on your custom locations or the WooCommerce defaults', 'flexible-shipping' ), |
| 41 | __( 'Define shipping cost for each Vendor / Product Author in your marketplace', 'flexible-shipping' ), |
| 42 | __( 'Move, replace, update or backup multiple shipping methods with Import / Export feature', 'flexible-shipping' ), |
| 43 | ], |
| 44 | get_locale() === 'pl_PL' ? 'https://octol.io/fs-info-addons-pl' : 'https://octol.io/addons-box-fs', |
| 45 | __( 'Buy Flexible Shipping Add-ons', 'flexible-shipping' ), |
| 46 | 1200 |
| 47 | ) )->hooks(); |
| 48 | } |
| 49 | ); |
| 50 | |
| 51 | $this->hooks_on_hookable_objects(); |
| 52 | } |
| 53 | } |
| 54 |