@@ -214,20 +214,18 @@ function perflab_dismiss_wp_pointer_wrapper(): void {
214
214
add_action ( 'wp_ajax_dismiss-wp-pointer ' , 'perflab_dismiss_wp_pointer_wrapper ' , 0 );
215
215
216
216
/**
217
- * Gets the URL to a script or stylesheet.
217
+ * Gets the path to a script or stylesheet.
218
218
*
219
219
* @since n.e.x.t
220
220
*
221
221
* @param string $src_path Source path.
222
222
* @param string|null $min_path Minified path. If not supplied, then '.min' is injected before the file extension in the source path.
223
223
* @return string URL to script or stylesheet.
224
224
*/
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 {
228
226
if ( null === $ min_path ) {
229
227
// 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 );
231
229
}
232
230
233
231
$ force_src = false ;
@@ -249,10 +247,10 @@ function perflab_get_asset_src( string $src_path, ?string $min_path = null ): st
249
247
}
250
248
251
249
if ( SCRIPT_DEBUG || $ force_src ) {
252
- return $ dir_url . $ src_path ;
250
+ return $ src_path ;
253
251
}
254
252
255
- return $ dir_url . $ min_path ;
253
+ return $ min_path ;
256
254
}
257
255
258
256
/**
@@ -270,7 +268,7 @@ function perflab_enqueue_features_page_scripts(): void {
270
268
// Enqueue plugin activate AJAX script and localize script data.
271
269
wp_enqueue_script (
272
270
'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 ' ),
274
272
array ( 'wp-i18n ' , 'wp-a11y ' , 'wp-api-fetch ' ),
275
273
PERFLAB_VERSION ,
276
274
true
0 commit comments