PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | jetpack_vendor/automattic/jetpack-premium-analytics/build/scripts.php +85 -0 16.2-beta → 16.3-beta View file →
@@ -1,0 +1,85 @@
1 +<?php
2 +/**
3 + * Script registration - Auto-generated by build process.
4 + * Do not edit this file manually.
5 + *
6 + * @package jpa
7 + */
8 +
9 +/**
10 + * Registers a script according to `wp_register_script`. Honors this request by
11 + * reassigning internal dependency properties of any script handle already
12 + * registered by that name. It does not deregister the original script, to
13 + * avoid losing inline scripts which may have been attached.
14 + *
15 + * @param WP_Scripts $scripts WP_Scripts instance.
16 + * @param string $handle Name of the script. Should be unique.
17 + * @param string $src Full URL of the script, or path of the script relative to the WordPress root directory.
18 + * @param array $deps Optional. An array of registered script handles this script depends on. Default empty array.
19 + * @param string|bool|null $ver Optional. String specifying script version number, if it has one, which is added to the URL
20 + * as a query string for cache busting purposes. If version is set to false, a version
21 + * number is automatically added equal to current installed WordPress version.
22 + * If set to null, no version is added.
23 + * @param bool $in_footer Optional. Whether to enqueue the script before </body> instead of in the <head>.
24 + * Default 'false'.
25 + */
26 +function jpa_override_script( $scripts, $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
27 + $script = $scripts->query( $handle, 'registered' );
28 + if ( $script ) {
29 + /*
30 + * In many ways, this is a reimplementation of `wp_register_script` but
31 + * bypassing consideration of whether a script by the given handle had
32 + * already been registered.
33 + */
34 +
35 + // See: `_WP_Dependency::__construct` .
36 + $script->src = $src;
37 + $script->deps = $deps;
38 + $script->ver = $ver;
39 + $script->args = $in_footer ? 1 : null;
40 + } else {
41 + $scripts->add( $handle, $src, $deps, $ver, ( $in_footer ? 1 : null ) );
42 + }
43 +
44 + if ( in_array( 'wp-i18n', $deps, true ) ) {
45 + $scripts->set_translations( $handle );
46 + }
47 +}
48 +
49 +/**
50 + * Register all package scripts.
51 + */
52 +function jpa_register_package_scripts( $scripts ) {
53 + // Load build constants
54 + $build_constants = require __DIR__ . '/constants.php';
55 + $default_version = ! SCRIPT_DEBUG ? $build_constants['version'] : time();
56 + $extension = '.min.js';
57 +
58 + $scripts_dir = __DIR__ . '/scripts';
59 + $scripts_file = $scripts_dir . '/registry.php';
60 +
61 + if ( ! file_exists( $scripts_file ) ) {
62 + return;
63 + }
64 +
65 + $scripts_data = require $scripts_file;
66 + $plugin_dir = dirname( __FILE__ );
67 +
68 + foreach ( $scripts_data as $script_data ) {
69 + $asset_file = $scripts_dir . '/' . $script_data['asset'];
70 + $asset = file_exists( $asset_file ) ? require $asset_file : array();
71 + $dependencies = $asset['dependencies'] ?? array();
72 + $version = $asset['version'] ?? $default_version;
73 +
74 + jpa_override_script(
75 + $scripts,
76 + $script_data['handle'],
77 + $build_constants['build_url'] . 'scripts/' . $script_data['path'] . $extension,
78 + $dependencies,
79 + $version,
80 + true
81 + );
82 + }
83 +}
84 +
85 +add_action( 'wp_default_scripts', 'jpa_register_package_scripts' );