PluginProbe
Extendify / 3.1.5
Extendify v3.1.5
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / app / Notifications / Assets.php

Assets.php in Extendify 3.1.5, at app/Notifications/Assets.php

71 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Assets.
5 */
6
7 namespace Extendify\Notifications;
8
9 defined('ABSPATH') || die('No direct access.');
10
11 use Extendify\Config;
12
13 /**
14 * The one bundle every slot renders from, admin or front end.
15 */
16 class Assets
17 {
18 /**
19 * @return void
20 */
21 public static function enqueue()
22 {
23 $manifest = Config::$assetManifest;
24 if (
25 empty($manifest['extendify-notifications.php'])
26 || empty($manifest['extendify-notifications.js'])
27 ) {
28 return;
29 }
30
31 $version = constant('EXTENDIFY_DEVMODE') ? uniqid() : Config::$version;
32 $scriptAssetPath = EXTENDIFY_PATH . 'public/build/'
33 . $manifest['extendify-notifications.php'];
34 $fallback = [
35 'dependencies' => [],
36 'version' => $version,
37 ];
38 $scriptAsset = file_exists($scriptAssetPath) ? require $scriptAssetPath : $fallback;
39
40 foreach ($scriptAsset['dependencies'] as $style) {
41 \wp_enqueue_style($style);
42 }
43
44 \wp_enqueue_script(
45 Config::$slug . '-notifications-scripts',
46 EXTENDIFY_BASE_URL . 'public/build/' . $manifest['extendify-notifications.js'],
47 array_merge([Config::$slug . '-shared-scripts'], $scriptAsset['dependencies']),
48 $scriptAsset['version'],
49 true
50 );
51
52 \wp_set_script_translations(
53 Config::$slug . '-notifications-scripts',
54 'extendify-local',
55 EXTENDIFY_PATH . 'languages/js'
56 );
57
58 if (empty($manifest['extendify-notifications.css'])) {
59 return;
60 }
61
62 \wp_enqueue_style(
63 Config::$slug . '-notifications-styles',
64 EXTENDIFY_BASE_URL . 'public/build/' . $manifest['extendify-notifications.css'],
65 [],
66 Config::$version,
67 'all'
68 );
69 }
70 }
71