Tracker
2 weeks ago
Assets.php
2 weeks ago
FreeShippingNotice.php
2 weeks ago
FreeShippingNoticeData.php
2 weeks ago
FreeShippingNoticeGenerator.php
2 weeks ago
FreeShippingNoticeRenderer.php
2 weeks ago
LffsNoticeTextFormatValidator.php
2 weeks ago
NoticeTextSettings.php
2 weeks ago
ProgressBarSettings.php
2 weeks ago
Tracker.php
2 weeks ago
Assets.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FS\TableRate\FreeShipping; |
| 4 | |
| 5 | use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable; |
| 6 | use WPDesk\FS\Blocks\FreeShipping\FreeShippingBlock; |
| 7 | |
| 8 | /** |
| 9 | * Can enqueue assets. |
| 10 | */ |
| 11 | class Assets implements Hookable { |
| 12 | |
| 13 | /** |
| 14 | * @var string |
| 15 | */ |
| 16 | private $assets_url; |
| 17 | |
| 18 | /** |
| 19 | * @var string |
| 20 | */ |
| 21 | private $scripts_version; |
| 22 | |
| 23 | /** |
| 24 | * @param string $assets_url |
| 25 | * @param $scripts_version |
| 26 | */ |
| 27 | public function __construct( string $assets_url, $scripts_version ) { |
| 28 | $this->assets_url = $assets_url; |
| 29 | $this->scripts_version = $scripts_version; |
| 30 | } |
| 31 | |
| 32 | public function hooks() { |
| 33 | add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); |
| 34 | } |
| 35 | |
| 36 | public function enqueue_scripts() { |
| 37 | if ( apply_filters( 'flexible-shipping/free-shipping/enqueue_css', is_page() || is_checkout() || is_cart() || is_product() || is_shop() || has_block( FreeShippingBlock::BLOCK_NAME ) ) ) { |
| 38 | wp_enqueue_style( |
| 39 | 'flexible-shipping-free-shipping', |
| 40 | trailingslashit( $this->assets_url ) . 'dist/css/free-shipping.css', |
| 41 | [], |
| 42 | $this->scripts_version |
| 43 | ); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | } |
| 48 |