Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Assets
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 get_file_url_for_environment
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Asset Manager for Jetpack Boost.
4 *
5 * @link       https://automattic.com
6 * @since      1.0.0
7 * @package    automattic/jetpack-boost
8 */
9
10namespace Automattic\Jetpack_Boost\Lib;
11
12/**
13 * Class Assets
14 */
15class Assets {
16
17    /**
18     * Given a minified path, and a non-minified path, will return
19     * a minified or non-minified file URL based on whether SCRIPT_DEBUG is set and truthy.
20     *
21     * Both `$min_base` and `$non_min_base` are expected to be relative to the
22     * root Jetpack directory.
23     *
24     * @param string $min_path     minified path.
25     * @param string $non_min_path non-minified path.
26     *
27     * @return string The URL to the file
28     * @since   1.0.0
29     */
30    public static function get_file_url_for_environment( $min_path, $non_min_path ) {
31        /**
32         * Filters the internal path to the distributed assets used by the plugin
33         *
34         * @param string $path the path to the assets
35         *
36         * @since   1.0.0
37         */
38        $internal_path = apply_filters( 'jetpack_boost_asset_internal_path', 'app/assets/dist/' );
39        $url           = plugins_url( $internal_path . trim( $non_min_path, '/' ), JETPACK_BOOST_PATH );
40
41        /**
42         * Filters the URL for a file passed through the get_file_url_for_environment function.
43         *
44         * @param string $url          The URL to the file.
45         * @param string $min_path     The minified path.
46         * @param string $non_min_path The non-minified path.
47         *
48         * @since   1.0.0
49         */
50        return apply_filters( 'jetpack_boost_asset_url', $url, $min_path, $non_min_path );
51    }
52}