File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1115,13 +1115,25 @@ public function get_url( bool $use_min_if_available = true ): string {
1115
1115
* Get the asset's full path - considering if minified exists.
1116
1116
*
1117
1117
* @since 1.4.6
1118
+ * @since 1.4.7 When the path is a URL, return the URL.
1118
1119
*
1119
1120
* @param bool $use_min_if_available
1120
1121
*
1121
1122
* @return string
1122
1123
*/
1123
1124
public function get_full_resource_path ( bool $ use_min_if_available = true ): string {
1124
1125
$ resource_path_data = $ this ->build_resource_path_data ();
1126
+ if ( empty ( $ resource_path_data ['resource ' ] ) ) {
1127
+ return '' ;
1128
+ }
1129
+
1130
+ if (
1131
+ str_starts_with ( $ resource_path_data ['resource ' ], 'http:// ' ) ||
1132
+ str_starts_with ( $ resource_path_data ['resource ' ], 'https:// ' ) ||
1133
+ str_starts_with ( $ resource_path_data ['resource ' ], '// ' )
1134
+ ) {
1135
+ return $ resource_path_data ['resource ' ];
1136
+ }
1125
1137
$ resource = $ resource_path_data ['resource ' ];
1126
1138
$ resource_path = $ resource_path_data ['resource_path ' ];
1127
1139
Original file line number Diff line number Diff line change @@ -298,6 +298,14 @@ public function it_should_get_the_correct_url_when_wp_content_dir_and_wp_content
298
298
}
299
299
}
300
300
301
+ /**
302
+ * @test
303
+ */
304
+ public function it_should_return_url_as_the_full_resource_path_when_the_path_is_a_url () {
305
+ $ asset = Asset::add ( 'fake-script ' , 'https://example.com/fake.js ' );
306
+ $ this ->assertEquals ( 'https://example.com/fake.js ' , $ asset ->get_full_resource_path () );
307
+ }
308
+
301
309
public function constantProvider () {
302
310
$ data = [
303
311
[
You can’t perform that action at this time.
0 commit comments