Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
57.14% |
12 / 21 |
|
100.00% |
1 / 1 |
CRAP | n/a |
0 / 0 |
|
| jetpack_boost_minify_load_library | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Load minify library code. |
| 5 | * |
| 6 | * @since 4.0.0 |
| 7 | * |
| 8 | * @return void |
| 9 | */ |
| 10 | function jetpack_boost_minify_load_library(): void { |
| 11 | require_once JETPACK_BOOST_DIR_PATH . '/app/lib/minify/class-utils.php'; |
| 12 | require_once JETPACK_BOOST_DIR_PATH . '/app/lib/minify/class-config.php'; |
| 13 | require_once JETPACK_BOOST_DIR_PATH . '/app/lib/minify/class-dependency-path-mapping.php'; |
| 14 | require_once JETPACK_BOOST_DIR_PATH . '/app/lib/minify/functions-helpers.php'; |
| 15 | require_once JETPACK_BOOST_DIR_PATH . '/app/lib/minify/functions-service-fallback.php'; |
| 16 | require_once JETPACK_BOOST_DIR_PATH . '/app/lib/minify/functions-service.php'; |
| 17 | } |
| 18 | jetpack_boost_minify_load_library(); |
| 19 | |
| 20 | add_action( |
| 21 | 'template_redirect', |
| 22 | function () { |
| 23 | // Only intercept 404 requests. |
| 24 | if ( ! is_404() ) { |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | // Get the path for the current request. |
| 29 | $request_uri = remove_query_arg( 'JB_NONEXISTENTQUERY_ARG' ); |
| 30 | if ( ! str_contains( strtolower( $request_uri ), '/wp-content/boost-cache/static/' ) ) { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | jetpack_boost_check_404_handler( $request_uri ); |
| 35 | |
| 36 | // Send a status 200 header, otherwise the browser will return a 404. |
| 37 | status_header( 200 ); |
| 38 | jetpack_boost_handle_minify_request( $request_uri ); |
| 39 | exit( 0 ); |
| 40 | } |
| 41 | ); |