date-time-location
9 months ago
class-date-time-location-block-integration.php
9 months ago
class-date-time-location-block.php
9 months ago
class-date-time-location-storage.php
9 months ago
class-date-time-location-block-integration.php
89 lines
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | use Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface; |
| 7 | |
| 8 | |
| 9 | class Date_Time_Location_Block_Integration implements IntegrationInterface { |
| 10 | |
| 11 | /** |
| 12 | * The name of the integration. |
| 13 | * |
| 14 | * @return string |
| 15 | */ |
| 16 | public function get_name() { |
| 17 | return 'date-time-location'; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * When called invokes any initialization/setup for the integration. |
| 22 | */ |
| 23 | public function initialize() { |
| 24 | $this->register_block_frontend_scripts(); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Returns an array of script handles to enqueue in the frontend context. |
| 29 | * |
| 30 | * @return string[] |
| 31 | */ |
| 32 | public function get_script_handles() { |
| 33 | return array( 'pisol-dtt-date-time-location-block','jquery-ui-datepicker' ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Returns an array of script handles to enqueue in the editor context. |
| 38 | * |
| 39 | * @return string[] |
| 40 | */ |
| 41 | public function get_editor_script_handles() { |
| 42 | return []; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * An array of key, value pairs of data made available to the block on the client side. |
| 47 | * |
| 48 | * @return array |
| 49 | */ |
| 50 | public function get_script_data() { |
| 51 | return array(); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Register scripts for delivery date block editor. |
| 56 | * |
| 57 | * @return void |
| 58 | */ |
| 59 | public function register_block_editor_scripts() { |
| 60 | |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Register scripts for frontend block. |
| 65 | * |
| 66 | * @return void |
| 67 | */ |
| 68 | public function register_block_frontend_scripts() { |
| 69 | wp_register_script( 'pisol-dtt-date-time-location-block', plugin_dir_url( __FILE__ ) . 'date-time-location/js/date-time-block.js', array( 'wp-plugins', 'wc-blocks-checkout','jquery-ui-datepicker' ), $this->get_file_version(plugin_dir_path( __FILE__ ) . 'date-time-location/js/date-time-block.js'), true ); |
| 70 | |
| 71 | wp_enqueue_style( 'pisol-dtt-date-time-location-block', plugin_dir_url( __FILE__ ) . 'date-time-location/css/date-time-block.css', array(), $this->get_file_version(plugin_dir_path( __FILE__ ) . 'date-time-location/css/date-time-block.css') ); |
| 72 | |
| 73 | \pi_dtt_css::inlineCss('pisol-dtt-date-time-location-block'); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Get the file modified time as a cache buster if we're in dev mode. |
| 78 | * |
| 79 | * @param string $file Local path to the file. |
| 80 | * @return string The cache buster value to use for the given file. |
| 81 | */ |
| 82 | protected function get_file_version( $file ) { |
| 83 | if ( defined( 'WP_DEBUG' ) && WP_DEBUG && file_exists( $file ) ) { |
| 84 | return filemtime( $file ); |
| 85 | } |
| 86 | return PISOL_DTT_PLUGIN_VERSION; |
| 87 | } |
| 88 | |
| 89 | } |