PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.5
ShopBuilder – WooCommerce Builder For Elementor v3.2.5
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Controllers/AssetRegistry.php +10 -83 3.4.23.2.5 View file →
@@ -146,25 +146,21 @@
146 146
147 147 /**
148 148 * Get bundled JS assets by context.
149 149 *
150 - * @param bool $all Build every materialised context rather than only the one
151 - * this request serves. Used by the manual regeneration path.
152 - *
153 150 * @return array
154 151 */
155 - public function get_bundled_js_by_context( $all = false ) {
152 + public function get_bundled_js_by_context() {
156 153 $js_files_by_context = $this->get_contextual_assets( 'js' );
157 154 $bundled_contexts = [];
158 - $wanted = $all ? array_keys( $js_files_by_context ) : $this->contexts_to_build( $js_files_by_context );
159 155
160 156 foreach ( $js_files_by_context as $context => $files ) {
161 - if ( empty( $files ) || ! in_array( $context, $wanted, true ) ) {
157 + if ( empty( $files ) ) {
162 158 continue;
163 159 }
164 160
165 161 $bundler = new AssetBundler( "rtsb-bundled-$context", $files, 'js' );
166 - $src = $this->build_bundle( $bundler, $context );
162 + $src = $bundler->build();
167 163 $deps = [ 'jquery', 'rtsb-tipsy' ];
168 164
169 165 $builder_page_id = BuilderFns::builder_page_id_by_page();
170 166
@@ -1195,9 +1191,9 @@
1195 1191 }
1196 1192
1197 1193 $handle = 'rtsb-bundled';
1198 1194 $bundler = new AssetBundler( $handle, $this->js_files, 'js' );
1199 - $src = $this->build_bundle( $bundler );
1195 + $src = $bundler->build();
1200 1196 $deps = [ 'jquery', 'rtsb-tipsy' ];
1201 1197
1202 1198 $builder_page_id = BuilderFns::builder_page_id_by_page();
1203 1199
@@ -1229,9 +1225,9 @@
1229 1225 return null;
1230 1226 }
1231 1227
1232 1228 $bundler = new AssetBundler( 'rtsb-bundled', $this->css_files, 'css' );
1233 - $src = $this->build_bundle( $bundler );
1229 + $src = $bundler->build();
1234 1230
1235 1231 $this->bundled_css = [
1236 1232 'handle' => 'rtsb-bundled',
1237 1233 'src' => $src,
@@ -1242,25 +1238,21 @@
1242 1238
1243 1239 /**
1244 1240 * Get bundled CSS by context
1245 1241 *
1246 - * @param bool $all Build every materialised context rather than only the one
1247 - * this request serves. Used by the manual regeneration path.
1248 - *
1249 1242 * @return array|null
1250 1243 */
1251 - public function get_bundled_css_by_context( $all = false ) {
1244 + public function get_bundled_css_by_context() {
1252 1245 $css_files_by_context = $this->get_contextual_assets( 'css' );
1253 1246 $bundled_contexts = [];
1254 - $wanted = $all ? array_keys( $css_files_by_context ) : $this->contexts_to_build( $css_files_by_context );
1255 1247
1256 1248 foreach ( $css_files_by_context as $context => $files ) {
1257 - if ( empty( $files ) || ! in_array( $context, $wanted, true ) ) {
1249 + if ( empty( $files ) ) {
1258 1250 continue;
1259 1251 }
1260 1252
1261 1253 $bundler = new AssetBundler( "rtsb-bundled-$context", $files, 'css' );
1262 - $src = $this->build_bundle( $bundler, $context );
1254 + $src = $bundler->build();
1263 1255
1264 1256 $bundled_contexts[ $context ] = [
1265 1257 'handle' => "rtsb-bundled-$context",
1266 1258 'src' => $src,
@@ -1270,70 +1262,8 @@
1270 1262 return $bundled_contexts;
1271 1263 }
1272 1264
1273 1265 /**
1274 - * The context or contexts this request actually needs built.
1275 - *
1276 - * A request serves exactly one bundle per type: load_optimized_assets() and
1277 - * enqueue_optimized_assets() both resolve the detected context, falling back
1278 - * to `global` when it has no mapping of its own. Building the others produces
1279 - * files this request will never reference.
1280 - *
1281 - * Only the selected context is returned, never context plus global: where a
1282 - * contextual bundle exists, get_contextual_assets() has already merged the
1283 - * global files into it, so global is not served alongside.
1284 - *
1285 - * Resolved separately for CSS and JS, because the two maps are built
1286 - * independently and a context can be mapped for one type but not the other.
1287 - *
1288 - * @param array $map Context to file-list map for a single asset type.
1289 - *
1290 - * @return array List of context keys to build.
1291 - */
1292 - protected function contexts_to_build( array $map ) {
1293 - $context = Fns::detect_context();
1294 -
1295 - if ( isset( $map[ $context ] ) ) {
1296 - return [ $context ];
1297 - }
1298 -
1299 - return isset( $map['global'] ) ? [ 'global' ] : [];
1300 - }
1301 -
1302 - /**
1303 - * Build a bundle and report an unusable result to Fns.
1304 - *
1305 - * AssetBundler::build() returns an empty string when it cannot write a file,
1306 - * for example when the cache directory is not writable or when the scoped
1307 - * minifier is not loadable yet on the first request after an upgrade.
1308 - * Registering a handle with an empty source makes WordPress print nothing at
1309 - * all, so the request must fall back to the unbundled assets instead.
1310 - *
1311 - * @param AssetBundler $bundler Bundler instance.
1312 - * @param string|null $context Context this bundle belongs to, null when not
1313 - * using contextual loading.
1314 - *
1315 - * @return string Bundle URL, or an empty string on failure.
1316 - */
1317 - private function build_bundle( AssetBundler $bundler, $context = null ) {
1318 - $src = $bundler->build();
1319 -
1320 - if ( '' !== $src ) {
1321 - return $src;
1322 - }
1323 -
1324 - // Only fall back when the bundle that would actually be served is the one
1325 - // that failed. enqueue_optimized_assets() serves the detected context and
1326 - // falls back to `global`, so a failure in any other context is harmless
1327 - // and must not disable optimization for the whole request.
1328 - if ( null === $context || 'global' === $context || Fns::detect_context() === $context ) {
1329 - Fns::mark_optimization_unavailable();
1330 - }
1331 -
1332 - return $src;
1333 - }
1334 -
1335 - /**
1336 1266 * Forcefully regenerate bundled JS and CSS assets.
1337 1267 *
1338 1268 * @return array
1339 1269 */
@@ -1344,14 +1274,11 @@
1344 1274 $this->css_files = [];
1345 1275
1346 1276 $this->collect_assets();
1347 1277
1348 - // Explicitly eager: this is the manual "Purge Asset Cache" path, which is
1349 - // expected to rebuild every materialised context rather than only the one
1350 - // the current request happens to serve.
1351 1278 return [
1352 - 'js' => $this->contextual_loading ? $this->get_bundled_js_by_context( true ) : $this->get_bundled_js(),
1353 - 'css' => $this->contextual_loading ? $this->get_bundled_css_by_context( true ) : $this->get_bundled_css(),
1279 + 'js' => $this->contextual_loading ? $this->get_bundled_js_by_context() : $this->get_bundled_js(),
1280 + 'css' => $this->contextual_loading ? $this->get_bundled_css_by_context() : $this->get_bundled_css(),
1354 1281 ];
1355 1282 }
1356 1283
1357 1284 /**