PluginProbe
Sendy / 3.4.7
Sendy v3.4.7
3.4.6 3.4.7 trunk 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 All 32 releases
sendy / lib / Utils / BlocksIntegration.php

BlocksIntegration.php in Sendy 3.4.7, at lib/Utils/BlocksIntegration.php

96 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sendy\WooCommerce\Utils;
4
5 use Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface;
6 use Sendy\WooCommerce\Plugin;
7
8 define('SENDY_BLOCK_VERSION', '1.0.0');
9
10 class BlocksIntegration implements IntegrationInterface
11 {
12 public function get_name()
13 {
14 return 'sendy-pickup-points';
15 }
16
17 public function initialize()
18 {
19 $this->register_block_frontend_scripts();
20 $this->register_block_editor_scripts();
21 }
22
23 public function get_script_handles()
24 {
25 return ['sendy-checkout-block-frontend'];
26 }
27
28 public function get_editor_script_handles()
29 {
30 return ['sendy-block-editor'];
31 }
32
33 public function get_script_data()
34 {
35 return [];
36 }
37
38 private function register_block_frontend_scripts()
39 {
40 $script_url = SENDY_WC_PLUGIN_DIR_URL . '/build/sendy-checkout-block-frontend.js';
41 $script_asset_path = SENDY_WC_PLUGIN_DIR_URL . '/build/sendy-checkout-block-frontend.asset.php';
42
43 $script_asset = file_exists($script_asset_path)
44 ? require $script_asset_path
45 : [
46 'dependencies' => [],
47 'version' => $this->get_file_version($script_asset_path),
48 ];
49
50 wp_enqueue_style(
51 'sendy-checkout-block-frontend-styling',
52 SENDY_WC_PLUGIN_DIR_URL . '/resources/css/frontend.css',
53 [],
54 Plugin::VERSION,
55 );
56
57 wp_register_script(
58 'sendy-checkout-block-frontend',
59 $script_url,
60 $script_asset['dependencies'],
61 $script_asset['version'],
62 true,
63 );
64 }
65
66 private function register_block_editor_scripts()
67 {
68 $script_path = '/build/index.js';
69 $script_url = plugins_url('sendy' . $script_path);
70 $script_asset_path = plugins_url('sendy/build/index.asset.php');
71 $script_asset = file_exists($script_asset_path)
72 ? require $script_asset_path
73 : [
74 'dependencies' => [],
75 'version' => $this->get_file_version($script_asset_path),
76 ];
77
78 wp_register_script(
79 'sendy-block-editor',
80 $script_url,
81 $script_asset['dependencies'],
82 $script_asset['version'],
83 true,
84 );
85 }
86
87 protected function get_file_version($file)
88 {
89 if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG && file_exists($file)) {
90 return filemtime($file);
91 }
92
93 return SENDY_BLOCK_VERSION;
94 }
95 }
96