Code Duplication    Length = 29-29 lines in 2 locations

packages/assets/src/class-assets.php 1 location

@@ 101-129 (lines=29) @@
98
	 * @param string $non_min_path non-minified path.
99
	 * @return string The URL to the file
100
	 */
101
	public static function get_file_url_for_environment( $min_path, $non_min_path ) {
102
		$path = ( Jetpack_Constants::is_defined( 'SCRIPT_DEBUG' ) && Jetpack_Constants::get_constant( 'SCRIPT_DEBUG' ) )
103
			? $non_min_path
104
			: $min_path;
105
106
		/*
107
		 * If the path is actually a full URL, keep that.
108
		 * We look for a host value, since enqueues are sometimes without a scheme.
109
		 */
110
		$file_parts = wp_parse_url( $path );
111
		if ( ! empty( $file_parts['host'] ) ) {
112
				$url = $path;
113
		} else {
114
			$url = plugins_url( $path, Jetpack_Constants::get_constant( 'JETPACK__PLUGIN_FILE' ) );
115
		}
116
117
		/**
118
		 * Filters the URL for a file passed through the get_file_url_for_environment function.
119
		 *
120
		 * @since 8.1.0
121
		 *
122
		 * @package assets
123
		 *
124
		 * @param string $url The URL to the file.
125
		 * @param string $min_path The minified path.
126
		 * @param string $non_min_path The non-minified path.
127
		 */
128
		return apply_filters( 'jetpack_get_file_for_environment', $url, $min_path, $non_min_path );
129
	}
130
131
	/**
132
	 * A helper function that lets you enqueue scripts in an async fashion.

packages/lazy-images/src/lazy-images.php 1 location

@@ 101-129 (lines=29) @@
98
	 * @param string $non_min_path Non-minified path.
99
	 * @return string The URL to the file.
100
	 */
101
	public static function get_file_url_for_environment( $min_path, $non_min_path ) {
102
		$path = ( Jetpack_Constants::is_defined( 'SCRIPT_DEBUG' ) && Jetpack_Constants::get_constant( 'SCRIPT_DEBUG' ) )
103
				? $non_min_path
104
				: $min_path;
105
106
		/*
107
		 * If the path is actually a full URL, keep that.
108
		 * We look for a host value, since enqueues are sometimes without a scheme.
109
		 */
110
		$file_parts = wp_parse_url( $path );
111
		if ( ! empty( $file_parts['host'] ) ) {
112
			$url = $path;
113
		} else {
114
			$url = plugins_url( $path, __FILE__ );
115
		}
116
117
		/**
118
		 * Filters the URL for a file passed through the get_file_url_for_environment function.
119
		 *
120
		 * @since 8.8
121
		 *
122
		 * @package automattic/jetpack-lazy-images
123
		 *
124
		 * @param string $url The URL to the file.
125
		 * @param string $min_path The minified path.
126
		 * @param string $non_min_path The non-minified path.
127
		 */
128
		return apply_filters( 'jetpack_lazy_load_get_file_for_environment', $url, $min_path, $non_min_path );
129
	}
130
131
	/**
132
	 * Registers actions.