| @@ -1,0 +1,164 @@ | ||
| 1 | +<?php | |
| 2 | +namespace ABlocks\Classes; | |
| 3 | + | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | + | |
| 8 | + | |
| 9 | +class RegisterScripts { | |
| 10 | + public static function get_register_styles() { | |
| 11 | + return apply_filters('ablocks/register_styles', [ | |
| 12 | + 'ablocks-prism-style' => [ | |
| 13 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/prism/prism.css', | |
| 14 | + 'url' => ABLOCKS_ASSETS_URL . 'library/prism/prism.css', | |
| 15 | + 'deps' => array(), | |
| 16 | + 'ver' => false, | |
| 17 | + 'media' => 'all' | |
| 18 | + ], | |
| 19 | + 'ablocks-prism-line-numbers-style' => [ | |
| 20 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/prism/prism-line-numbers.css', | |
| 21 | + 'url' => ABLOCKS_ASSETS_URL . 'library/prism/prism-line-numbers.css', | |
| 22 | + 'deps' => array(), | |
| 23 | + 'ver' => false, | |
| 24 | + 'media' => 'all' | |
| 25 | + ], | |
| 26 | + 'ablocks-prism-line-highlight-style' => [ | |
| 27 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/prism/prism-line-highlight.css', | |
| 28 | + 'url' => ABLOCKS_ASSETS_URL . 'library/prism/prism-line-highlight.css', | |
| 29 | + 'deps' => array(), | |
| 30 | + 'ver' => false, | |
| 31 | + 'media' => 'all' | |
| 32 | + ], | |
| 33 | + 'ablocks-leaflet-style' => [ | |
| 34 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/leaflet/leaflet.css', | |
| 35 | + 'url' => ABLOCKS_ASSETS_URL . 'library/leaflet/leaflet.css', | |
| 36 | + 'deps' => array(), | |
| 37 | + 'ver' => false, | |
| 38 | + 'media' => 'all' | |
| 39 | + ], | |
| 40 | + 'ablocks-leaflet-full-screen-style' => [ | |
| 41 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/leaflet/leaflet.fullscreen.css', | |
| 42 | + 'url' => ABLOCKS_ASSETS_URL . 'library/leaflet/leaflet.fullscreen.css', | |
| 43 | + 'deps' => array(), | |
| 44 | + 'ver' => false, | |
| 45 | + 'media' => 'all' | |
| 46 | + ], | |
| 47 | + 'ablocks-animate-style' => [ | |
| 48 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/animate/animate.min.css', | |
| 49 | + 'url' => ABLOCKS_ASSETS_URL . 'library/animate/animate.min.css', | |
| 50 | + 'deps' => array(), | |
| 51 | + 'ver' => false, | |
| 52 | + 'media' => 'all' | |
| 53 | + ], | |
| 54 | + 'ablocks-swiper-style' => [ | |
| 55 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/swiper/swiper-bundle.min.css', | |
| 56 | + 'url' => ABLOCKS_ASSETS_URL . 'library/swiper/swiper-bundle.min.css', | |
| 57 | + 'deps' => array(), | |
| 58 | + 'ver' => false, | |
| 59 | + 'media' => 'all' | |
| 60 | + ], | |
| 61 | + 'ablocks-plyr-style' => [ | |
| 62 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/plyr/plyr.css', | |
| 63 | + 'url' => ABLOCKS_ASSETS_URL . 'library/plyr/plyr.css', | |
| 64 | + 'deps' => array(), | |
| 65 | + 'ver' => false, | |
| 66 | + 'media' => 'all' | |
| 67 | + ], | |
| 68 | + 'ablocks-common-style' => [ | |
| 69 | + 'path' => ABLOCKS_ASSETS_PATH . 'build/blocks-common.css', | |
| 70 | + 'url' => ABLOCKS_ASSETS_URL . 'build/blocks-common.css', | |
| 71 | + 'deps' => array(), | |
| 72 | + 'ver' => false, | |
| 73 | + 'media' => 'all' | |
| 74 | + ], | |
| 75 | + ]); | |
| 76 | + } | |
| 77 | + public static function get_register_scripts() { | |
| 78 | + $script_loading_strategy = \ABlocks\Helper::get_script_loading_strategy(); | |
| 79 | + $args = [ 'strategy' => $script_loading_strategy ]; | |
| 80 | + return apply_filters('ablocks/register_scripts', [ | |
| 81 | + // Data-only handle (no src) that hosts the single frontend | |
| 82 | + // ABlocksGlobal payload. Every aBlocks frontend script depends on it | |
| 83 | + // — directly, or transitively through ablocks-common-script — so WP | |
| 84 | + // prints the object exactly once per page instead of once per block | |
| 85 | + // script handle (asset-generation off) or once per combined template | |
| 86 | + // script (asset-generation on). See Assets::localize_globals_once(). | |
| 87 | + 'ablocks-globals' => [ | |
| 88 | + 'url' => false, | |
| 89 | + 'deps' => array(), | |
| 90 | + 'ver' => ABLOCKS_VERSION, | |
| 91 | + 'args' => array(), | |
| 92 | + ], | |
| 93 | + 'ablocks-prism-script' => [ | |
| 94 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/prism/prism.js', | |
| 95 | + 'url' => ABLOCKS_ASSETS_URL . 'library/prism/prism.js', | |
| 96 | + 'deps' => array(), | |
| 97 | + 'ver' => false, | |
| 98 | + 'args' => $args | |
| 99 | + ], | |
| 100 | + 'ablocks-prism-line-numbers-script' => [ | |
| 101 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/prism/prism-line-numbers.js', | |
| 102 | + 'url' => ABLOCKS_ASSETS_URL . 'library/prism/prism-line-numbers.js', | |
| 103 | + 'deps' => array(), | |
| 104 | + 'ver' => false, | |
| 105 | + 'args' => $args | |
| 106 | + ], | |
| 107 | + 'ablocks-prism-line-highlight-script' => [ | |
| 108 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/prism/prism-line-highlight.js', | |
| 109 | + 'url' => ABLOCKS_ASSETS_URL . 'library/prism/prism-line-highlight.js', | |
| 110 | + 'deps' => array(), | |
| 111 | + 'ver' => false, | |
| 112 | + 'args' => $args | |
| 113 | + ], | |
| 114 | + 'ablocks-leaflet-script' => [ | |
| 115 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/leaflet/leaflet.js', | |
| 116 | + 'url' => ABLOCKS_ASSETS_URL . 'library/leaflet/leaflet.js', | |
| 117 | + 'deps' => array(), | |
| 118 | + 'ver' => false, | |
| 119 | + 'args' => $args | |
| 120 | + ], | |
| 121 | + 'ablocks-leaflet-full-screen-script' => [ | |
| 122 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/leaflet/Leaflet.fullscreen.js', | |
| 123 | + 'url' => ABLOCKS_ASSETS_URL . 'library/leaflet/Leaflet.fullscreen.js', | |
| 124 | + 'deps' => array(), | |
| 125 | + 'ver' => false, | |
| 126 | + 'args' => $args | |
| 127 | + ], | |
| 128 | + 'ablocks-swiper-script' => [ | |
| 129 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/swiper/swiper-bundle.min.js', | |
| 130 | + 'url' => ABLOCKS_ASSETS_URL . 'library/swiper/swiper-bundle.min.js', | |
| 131 | + 'deps' => array(), | |
| 132 | + 'ver' => false, | |
| 133 | + 'args' => $args | |
| 134 | + ], | |
| 135 | + 'ablocks-chart.js-script' => [ | |
| 136 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/chart/chart.js', | |
| 137 | + 'url' => ABLOCKS_ASSETS_URL . 'library/chart/chart.js', | |
| 138 | + 'deps' => array(), | |
| 139 | + 'ver' => false, | |
| 140 | + 'args' => $args | |
| 141 | + ], | |
| 142 | + 'ablocks-plyr-script' => [ | |
| 143 | + 'path' => ABLOCKS_ASSETS_PATH . 'library/plyr/plyr.js', | |
| 144 | + 'url' => ABLOCKS_ASSETS_URL . 'library/plyr/plyr.js', | |
| 145 | + 'deps' => array(), | |
| 146 | + 'ver' => false, | |
| 147 | + 'args' => true, | |
| 148 | + 'dependencies' => ABLOCKS_ASSETS_PATH . 'build/blocks-common.asset.php' | |
| 149 | + ], | |
| 150 | + 'ablocks-common-script' => [ | |
| 151 | + 'path' => ABLOCKS_ASSETS_PATH . 'build/blocks-common.js', | |
| 152 | + 'url' => ABLOCKS_ASSETS_URL . 'build/blocks-common.js', | |
| 153 | + // Every block script depends on this handle (see | |
| 154 | + // BlockBaseAbstract::get_script_depends), so hanging | |
| 155 | + // ablocks-globals off it makes the payload reachable from any | |
| 156 | + // rendered block without touching each block's own deps. | |
| 157 | + 'deps' => array( 'ablocks-globals' ), | |
| 158 | + 'ver' => false, | |
| 159 | + 'args' => $args, | |
| 160 | + 'dependencies' => ABLOCKS_ASSETS_PATH . 'build/blocks-common.asset.php' | |
| 161 | + ], | |
| 162 | + ]); | |
| 163 | + } | |
| 164 | +} | |