PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
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 13.8.3 All 506 releases
jetpack / jetpack_vendor / automattic / jetpack-connection / src / class-connection-assets.php

class-connection-assets.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.5, at jetpack_vendor/automattic/jetpack-connection/src/class-connection-assets.php

63 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Connection_Assets.
4 *
5 * @package automattic/jetpack-connection
6 */
7
8 namespace Automattic\Jetpack\Connection;
9
10 use Automattic\Jetpack\Assets;
11
12 /**
13 * Connection_Assets class.
14 */
15 class Connection_Assets {
16
17 /**
18 * Initialize the class.
19 */
20 public static function configure() {
21 add_action( 'wp_loaded', array( __CLASS__, 'register_assets' ) );
22
23 add_filter( 'jetpack_admin_js_script_data', array( Initial_State::class, 'set_connection_script_data' ), 10, 1 );
24 // Priority 20: set_connection_script_data() replaces the whole `connection` key at 10.
25 add_filter( 'jetpack_admin_js_script_data', array( __CLASS__, 'add_script_data' ), 20 );
26 }
27
28 /**
29 * Add the package's image base URL to the admin script data.
30 *
31 * Other plugins' bundles request the disconnect dialog's images from this copy, so never rename one.
32 *
33 * @since 9.3.0
34 *
35 * @param array $data Script data.
36 * @return array
37 */
38 public static function add_script_data( $data ) {
39 $data['connection']['assetsUrl'] = trailingslashit( plugins_url( 'assets/images/', __DIR__ ) );
40
41 return $data;
42 }
43
44 /**
45 * Register assets.
46 *
47 * NOTICE: Please think twice before including Connection scripts in the frontend.
48 * Those scripts are intended to be used in WP admin area.
49 */
50 public static function register_assets() {
51
52 Assets::register_script(
53 'jetpack-connection',
54 '../dist/jetpack-connection.js',
55 __FILE__,
56 array(
57 'in_footer' => true,
58 'textdomain' => 'jetpack-connection',
59 )
60 );
61 }
62 }
63