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.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / src / Blocks / Assets / Api.php
woocommerce / src / Blocks / Assets Last commit date
Api.php 1 year ago AssetDataRegistry.php 4 weeks ago
Api.php
363 lines
1 <?php
2 namespace Automattic\WooCommerce\Blocks\Assets;
3
4 use Automattic\WooCommerce\Blocks\Domain\Package;
5 use Exception;
6 use Automattic\Jetpack\Constants;
7 /**
8 * The Api class provides an interface to various asset registration helpers.
9 *
10 * Contains asset api methods
11 *
12 * @since 2.5.0
13 */
14 class Api {
15
16 /**
17 * Stores the prefixed WC version. Used because the WC Blocks version has not been updated since the monorepo merge.
18 *
19 * @var string
20 */
21 public $wc_version;
22
23 /**
24 * Stores inline scripts already enqueued.
25 *
26 * @var array
27 */
28 private $inline_scripts = [];
29
30 /**
31 * Determines if caching is enabled for script data.
32 *
33 * @var boolean
34 */
35 private $disable_cache = false;
36
37 /**
38 * Stores loaded script data for the current request
39 *
40 * @var array|null
41 */
42 private $script_data = null;
43
44 /**
45 * Tracks whether script_data was modified during the current request.
46 *
47 * @var boolean
48 */
49 private $script_data_modified = false;
50
51 /**
52 * Stores the hash for the script data, made up of the site url, plugin version and package path.
53 *
54 * @var string
55 */
56 private $script_data_hash;
57
58 /**
59 * Stores the transient key used to cache the script data. This will change if the site is accessed via HTTPS or HTTP.
60 *
61 * @var string
62 */
63 private $script_data_transient_key = 'woocommerce_blocks_asset_api_script_data';
64
65 /**
66 * Reference to the Package instance
67 *
68 * @var Package
69 */
70 private $package;
71
72 /**
73 * Constructor for class
74 *
75 * @param Package $package An instance of Package.
76 */
77 public function __construct( Package $package ) {
78 // Use wc- prefix here to prevent collisions when WC Core version catches up to a version previously used by the WC Blocks feature plugin.
79 $this->wc_version = 'wc-' . Constants::get_constant( 'WC_VERSION' );
80 $this->package = $package;
81 $this->disable_cache = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) || wp_get_environment_type() !== 'production';
82
83 // If the site is accessed via HTTPS, change the transient key. This is to prevent the script URLs being cached
84 // with the first scheme they are accessed on after cache expiry.
85 if ( is_ssl() ) {
86 $this->script_data_transient_key .= '_ssl';
87 }
88 if ( ! $this->disable_cache ) {
89 $this->script_data_hash = $this->get_script_data_hash();
90 }
91 add_action( 'shutdown', array( $this, 'update_script_data_cache' ), 20 );
92 }
93
94 /**
95 * Get the file modified time as a cache buster if we're in dev mode.
96 *
97 * @param string $file Local path to the file (relative to the plugin
98 * directory).
99 * @return string The cache buster value to use for the given file.
100 */
101 protected function get_file_version( $file ) {
102 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && file_exists( $this->package->get_path() . $file ) ) {
103 return filemtime( $this->package->get_path( trim( $file, '/' ) ) );
104 }
105 return $this->wc_version;
106 }
107
108 /**
109 * Retrieve the url to an asset for this plugin.
110 *
111 * @param string $relative_path An optional relative path appended to the
112 * returned url.
113 *
114 * @return string
115 */
116 protected function get_asset_url( $relative_path = '' ) {
117 return $this->package->get_url( $relative_path );
118 }
119
120 /**
121 * Get the path to a block's metadata
122 *
123 * @param string $block_name The block to get metadata for.
124 * @param string $path Optional. The path to the metadata file inside the 'assets/client/blocks' folder.
125 *
126 * @return string|boolean False if metadata file is not found for the block.
127 */
128 public function get_block_metadata_path( $block_name, $path = '' ) {
129 $path_to_metadata_from_plugin_root = $this->package->get_path( 'assets/client/blocks/' . $path . $block_name . '/block.json' );
130 if ( ! file_exists( $path_to_metadata_from_plugin_root ) ) {
131 return false;
132 }
133 return $path_to_metadata_from_plugin_root;
134 }
135
136 /**
137 * Generates a hash containing the site url, plugin version and package path.
138 *
139 * Moving the plugin, changing the version, or changing the site url will result in a new hash and the cache will be invalidated.
140 *
141 * @return string The generated hash.
142 */
143 private function get_script_data_hash() {
144 return md5( get_option( 'siteurl', '' ) . $this->wc_version . $this->package->get_path() );
145 }
146
147 /**
148 * Initialize and load cached script data from the transient cache.
149 *
150 * @return array
151 */
152 private function get_cached_script_data() {
153 if ( $this->disable_cache ) {
154 return [];
155 }
156
157 $transient_value = json_decode( (string) get_transient( $this->script_data_transient_key ), true );
158
159 if (
160 json_last_error() !== JSON_ERROR_NONE ||
161 empty( $transient_value ) ||
162 empty( $transient_value['script_data'] ) ||
163 empty( $transient_value['version'] ) ||
164 $transient_value['version'] !== $this->wc_version ||
165 empty( $transient_value['hash'] ) ||
166 $transient_value['hash'] !== $this->script_data_hash
167 ) {
168 return [];
169 }
170
171 return (array) ( $transient_value['script_data'] ?? [] );
172 }
173
174 /**
175 * Store all cached script data in the transient cache.
176 */
177 public function update_script_data_cache() {
178 if ( is_null( $this->script_data ) || $this->disable_cache ) {
179 return;
180 }
181 if ( ! $this->script_data_modified ) {
182 return;
183 }
184 set_transient(
185 $this->script_data_transient_key,
186 wp_json_encode(
187 array(
188 'script_data' => $this->script_data,
189 'version' => $this->wc_version,
190 'hash' => $this->script_data_hash,
191 )
192 ),
193 DAY_IN_SECONDS * 30
194 );
195 }
196
197 /**
198 * Use package path to find an asset data file and return the data.
199 *
200 * @param string $filename The filename of the asset.
201 * @return array The asset data.
202 */
203 public function get_asset_data( $filename ) {
204 $asset_path = $this->package->get_path( $filename );
205 $asset = file_exists( $asset_path ) ? require $asset_path : [];
206 return $asset;
207 }
208
209 /**
210 * Get src, version and dependencies given a script relative src.
211 *
212 * @param string $relative_src Relative src to the script.
213 * @param array $dependencies Optional. An array of registered script handles this script depends on. Default empty array.
214 *
215 * @return array src, version and dependencies of the script.
216 */
217 public function get_script_data( $relative_src, $dependencies = [] ) {
218 if ( ! $relative_src ) {
219 return array(
220 'src' => '',
221 'version' => '1',
222 'dependencies' => $dependencies,
223 );
224 }
225
226 if ( is_null( $this->script_data ) ) {
227 $this->script_data = $this->get_cached_script_data();
228 }
229
230 if ( empty( $this->script_data[ $relative_src ] ) ) {
231 $asset_path = $this->package->get_path( str_replace( '.js', '.asset.php', $relative_src ) );
232 // The following require is safe because we are checking if the file exists and it is not a user input.
233 // nosemgrep audit.php.lang.security.file.inclusion-arg.
234 $asset = file_exists( $asset_path ) ? require $asset_path : [];
235
236 $this->script_data[ $relative_src ] = array(
237 'src' => $this->get_asset_url( $relative_src ),
238 'version' => ! empty( $asset['version'] ) ? $asset['version'] : $this->get_file_version( $relative_src ),
239 'dependencies' => ! empty( $asset['dependencies'] ) ? $asset['dependencies'] : [],
240 );
241 $this->script_data_modified = true;
242 }
243
244 // Return asset details as well as the requested dependencies array.
245 return [
246 'src' => $this->script_data[ $relative_src ]['src'],
247 'version' => $this->script_data[ $relative_src ]['version'],
248 'dependencies' => array_merge( $this->script_data[ $relative_src ]['dependencies'], $dependencies ),
249 ];
250 }
251
252 /**
253 * Registers a script according to `wp_register_script`, adding the correct prefix, and additionally loading translations.
254 *
255 * When creating script assets, the following rules should be followed:
256 * 1. All asset handles should have a `wc-` prefix.
257 * 2. If the asset handle is for a Block (in editor context) use the `-block` suffix.
258 * 3. If the asset handle is for a Block (in frontend context) use the `-block-frontend` suffix.
259 * 4. If the asset is for any other script being consumed or enqueued by the blocks plugin, use the `wc-blocks-` prefix.
260 *
261 * @since 2.5.0
262 * @throws Exception If the registered script has a dependency on itself.
263 *
264 * @param string $handle Unique name of the script.
265 * @param string $relative_src Relative url for the script to the path from plugin root.
266 * @param array $dependencies Optional. An array of registered script handles this script depends on. Default empty array.
267 * @param bool $has_i18n Optional. Whether to add a script translation call to this file. Default: true.
268 */
269 public function register_script( $handle, $relative_src, $dependencies = [], $has_i18n = true ) {
270 $script_data = $this->get_script_data( $relative_src, $dependencies );
271
272 if ( in_array( $handle, $script_data['dependencies'], true ) ) {
273 if ( wp_get_environment_type() === 'development' ) {
274 $dependencies = array_diff( $script_data['dependencies'], [ $handle ] );
275 add_action(
276 'admin_notices',
277 function () use ( $handle ) {
278 echo '<div class="error"><p>';
279 /* translators: %s file handle name. */
280 printf( esc_html__( 'Script with handle %s had a dependency on itself which has been removed. This is an indicator that your JS code has a circular dependency that can cause bugs.', 'woocommerce' ), esc_html( $handle ) );
281 echo '</p></div>';
282 }
283 );
284 } else {
285 throw new Exception( sprintf( 'Script with handle %s had a dependency on itself. This is an indicator that your JS code has a circular dependency that can cause bugs.', $handle ) );
286 }
287 }
288
289 /**
290 * Filters the list of script dependencies.
291 *
292 * @since 3.0.0
293 *
294 * @param array $dependencies The list of script dependencies.
295 * @param string $handle The script's handle.
296 * @return array
297 */
298 $script_dependencies = apply_filters( 'woocommerce_blocks_register_script_dependencies', $script_data['dependencies'], $handle );
299
300 wp_register_script( $handle, $script_data['src'], $script_dependencies, $script_data['version'], true );
301
302 if ( $has_i18n && function_exists( 'wp_set_script_translations' ) ) {
303 wp_set_script_translations( $handle, 'woocommerce', $this->package->get_path( 'languages' ) );
304 wp_set_script_translations( $handle, 'woocommerce', $this->package->get_path( 'i18n/languages' ) );
305 }
306 }
307
308 /**
309 * Registers a style according to `wp_register_style`.
310 *
311 * @since 2.5.0
312 * @since 2.6.0 Change src to be relative source.
313 *
314 * @param string $handle Name of the stylesheet. Should be unique.
315 * @param string $relative_src Relative source of the stylesheet to the plugin path.
316 * @param array $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array.
317 * @param string $media Optional. The media for which this stylesheet has been defined. Default 'all'. Accepts media types like
318 * 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'.
319 * @param boolean $rtl Optional. Whether or not to register RTL styles.
320 */
321 public function register_style( $handle, $relative_src, $deps = [], $media = 'all', $rtl = false ) {
322 $filename = str_replace( plugins_url( '/', dirname( __DIR__ ) ), '', $relative_src );
323 $src = $this->get_asset_url( $relative_src );
324 $ver = $this->get_file_version( $filename );
325 wp_register_style( $handle, $src, $deps, $ver, $media );
326
327 if ( $rtl ) {
328 wp_style_add_data( $handle, 'rtl', 'replace' );
329 }
330 }
331
332 /**
333 * Returns the appropriate asset path for current builds.
334 *
335 * @param string $filename Filename for asset path (without extension).
336 * @param string $type File type (.css or .js).
337 * @return string The generated path.
338 */
339 public function get_block_asset_build_path( $filename, $type = 'js' ) {
340 return "assets/client/blocks/$filename.$type";
341 }
342
343 /**
344 * Adds an inline script, once.
345 *
346 * @param string $handle Script handle.
347 * @param string $script Script contents.
348 */
349 public function add_inline_script( $handle, $script ) {
350 if ( ! empty( $this->inline_scripts[ $handle ] ) && in_array( $script, $this->inline_scripts[ $handle ], true ) ) {
351 return;
352 }
353
354 wp_add_inline_script( $handle, $script );
355
356 if ( isset( $this->inline_scripts[ $handle ] ) ) {
357 $this->inline_scripts[ $handle ][] = $script;
358 } else {
359 $this->inline_scripts[ $handle ] = array( $script );
360 }
361 }
362 }
363