Skip to content

Commit f54c488

Browse files
committed
Change perflab_get_asset_url() to return path instead of URL
1 parent 1ca7c77 commit f54c488

File tree

1 file changed

+6
-8
lines changed
  • plugins/performance-lab/includes/admin

1 file changed

+6
-8
lines changed

plugins/performance-lab/includes/admin/load.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,18 @@ function perflab_dismiss_wp_pointer_wrapper(): void {
214214
add_action( 'wp_ajax_dismiss-wp-pointer', 'perflab_dismiss_wp_pointer_wrapper', 0 );
215215

216216
/**
217-
* Gets the URL to a script or stylesheet.
217+
* Gets the path to a script or stylesheet.
218218
*
219219
* @since n.e.x.t
220220
*
221221
* @param string $src_path Source path.
222222
* @param string|null $min_path Minified path. If not supplied, then '.min' is injected before the file extension in the source path.
223223
* @return string URL to script or stylesheet.
224224
*/
225-
function perflab_get_asset_src( string $src_path, ?string $min_path = null ): string {
226-
$dir_url = plugin_dir_url( PERFLAB_MAIN_FILE );
227-
225+
function perflab_get_asset_path( string $src_path, ?string $min_path = null ): string {
228226
if ( null === $min_path ) {
229227
// Note: wp_scripts_get_suffix() is not used here because we need access to both the source and minified paths.
230-
$min_path = preg_replace( '/(?=\.\w+$)/', '.min', $src_path );
228+
$min_path = (string) preg_replace( '/(?=\.\w+$)/', '.min', $src_path );
231229
}
232230

233231
$force_src = false;
@@ -249,10 +247,10 @@ function perflab_get_asset_src( string $src_path, ?string $min_path = null ): st
249247
}
250248

251249
if ( SCRIPT_DEBUG || $force_src ) {
252-
return $dir_url . $src_path;
250+
return $src_path;
253251
}
254252

255-
return $dir_url . $min_path;
253+
return $min_path;
256254
}
257255

258256
/**
@@ -270,7 +268,7 @@ function perflab_enqueue_features_page_scripts(): void {
270268
// Enqueue plugin activate AJAX script and localize script data.
271269
wp_enqueue_script(
272270
'perflab-plugin-activate-ajax',
273-
perflab_get_asset_src( 'includes/admin/plugin-activate-ajax.js' ),
271+
plugin_dir_url( PERFLAB_MAIN_FILE ) . perflab_get_asset_path( 'includes/admin/plugin-activate-ajax.js' ),
274272
array( 'wp-i18n', 'wp-a11y', 'wp-api-fetch' ),
275273
PERFLAB_VERSION,
276274
true

0 commit comments

Comments
 (0)