block.php
46 lines
| 1 | <?php |
| 2 | namespace PISOL\DTT\BLOCK; |
| 3 | |
| 4 | use Automattic\WooCommerce\StoreApi\StoreApi; |
| 5 | use Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema; |
| 6 | use Automattic\WooCommerce\StoreApi\Schemas\V1\CartSchema; |
| 7 | use Automattic\WooCommerce\StoreApi\Schemas\V1\CartItemSchema; |
| 8 | |
| 9 | class BlockSupport{ |
| 10 | |
| 11 | private $extend; |
| 12 | |
| 13 | protected static $instance = null; |
| 14 | |
| 15 | const IDENTIFIER = 'pisol_dtt_block'; |
| 16 | |
| 17 | |
| 18 | public static function get_instance( ) { |
| 19 | if ( is_null( self::$instance ) ) { |
| 20 | self::$instance = new self(); |
| 21 | } |
| 22 | return self::$instance; |
| 23 | } |
| 24 | |
| 25 | function __construct(){ |
| 26 | add_action( 'wp_enqueue_scripts', [$this, 'front']); |
| 27 | } |
| 28 | |
| 29 | |
| 30 | function front(){ |
| 31 | //check for admin and editor |
| 32 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | |
| 37 | if(function_exists('is_checkout') && is_checkout()){ |
| 38 | wp_enqueue_script( 'pisol-dtt-block', plugin_dir_url( __FILE__ ) . 'js/block.js', array( 'wp-plugins', 'wc-blocks-checkout' ), '1.0.0', true ); |
| 39 | |
| 40 | wp_enqueue_style( 'pisol-dtt-block', plugin_dir_url( __FILE__ ) . 'css/block.css', array( 'wc-blocks-style' ), '1.0.0' ); |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | BlockSupport::get_instance(); |
| 46 |