diff --git a/plugins/embed-optimizer/hooks.php b/plugins/embed-optimizer/hooks.php index e32e360cc..560a6096d 100644 --- a/plugins/embed-optimizer/hooks.php +++ b/plugins/embed-optimizer/hooks.php @@ -121,7 +121,7 @@ function embed_optimizer_filter_extension_module_urls( $extension_module_urls ): if ( ! is_array( $extension_module_urls ) ) { $extension_module_urls = array(); } - $extension_module_urls[] = add_query_arg( 'ver', EMBED_OPTIMIZER_VERSION, plugin_dir_url( __FILE__ ) . embed_optimizer_get_asset_path( 'detect.js' ) ); + $extension_module_urls[] = plugins_url( add_query_arg( 'ver', EMBED_OPTIMIZER_VERSION, embed_optimizer_get_asset_path( 'detect.js' ) ), __FILE__ ); return $extension_module_urls; } diff --git a/plugins/image-prioritizer/helper.php b/plugins/image-prioritizer/helper.php index 3e8dd49cf..789a6a843 100644 --- a/plugins/image-prioritizer/helper.php +++ b/plugins/image-prioritizer/helper.php @@ -93,7 +93,7 @@ function image_prioritizer_filter_extension_module_urls( $extension_module_urls if ( ! is_array( $extension_module_urls ) ) { $extension_module_urls = array(); } - $extension_module_urls[] = add_query_arg( 'ver', IMAGE_PRIORITIZER_VERSION, plugin_dir_url( __FILE__ ) . image_prioritizer_get_asset_path( 'detect.js' ) ); + $extension_module_urls[] = plugins_url( add_query_arg( 'ver', IMAGE_PRIORITIZER_VERSION, image_prioritizer_get_asset_path( 'detect.js' ) ), __FILE__ ); return $extension_module_urls; } diff --git a/plugins/optimization-detective/detection.php b/plugins/optimization-detective/detection.php index 2fa2a6dee..116249704 100644 --- a/plugins/optimization-detective/detection.php +++ b/plugins/optimization-detective/detection.php @@ -71,7 +71,7 @@ function od_get_cache_purge_post_id(): ?int { */ function od_get_detection_script( string $slug, OD_URL_Metric_Group_Collection $group_collection ): string { $web_vitals_lib_data = require __DIR__ . '/build/web-vitals.asset.php'; - $web_vitals_lib_src = add_query_arg( 'ver', $web_vitals_lib_data['version'], plugin_dir_url( __FILE__ ) . 'build/web-vitals.js' ); + $web_vitals_lib_src = plugins_url( add_query_arg( 'ver', $web_vitals_lib_data['version'], 'build/web-vitals.js' ), __FILE__ ); /** * Filters the list of extension script module URLs to import when performing detection. @@ -118,7 +118,7 @@ static function ( OD_URL_Metric_Group $group ): array { return wp_get_inline_script_tag( sprintf( 'import detect from %s; detect( %s );', - wp_json_encode( add_query_arg( 'ver', OPTIMIZATION_DETECTIVE_VERSION, plugin_dir_url( __FILE__ ) . od_get_asset_path( 'detect.js' ) ) ), + wp_json_encode( plugins_url( add_query_arg( 'ver', OPTIMIZATION_DETECTIVE_VERSION, od_get_asset_path( 'detect.js' ) ), __FILE__ ) ), wp_json_encode( $detect_args ) ), array( 'type' => 'module' ) diff --git a/plugins/optimization-detective/readme.txt b/plugins/optimization-detective/readme.txt index 62dac5293..5f7751c34 100644 --- a/plugins/optimization-detective/readme.txt +++ b/plugins/optimization-detective/readme.txt @@ -257,7 +257,7 @@ For example: add_filter( 'od_extension_module_urls', static function ( array $extension_module_urls ): array { - $extension_module_urls[] = add_query_arg( 'ver', '1.0', plugin_dir_url( __FILE__ ) . 'detect.js' ); + $extension_module_urls[] = plugins_url( add_query_arg( 'ver', '1.0', 'detect.js' ), __FILE__ ); return $extension_module_urls; } ); diff --git a/plugins/performance-lab/includes/admin/load.php b/plugins/performance-lab/includes/admin/load.php index aecac103d..c85db6d81 100644 --- a/plugins/performance-lab/includes/admin/load.php +++ b/plugins/performance-lab/includes/admin/load.php @@ -264,7 +264,7 @@ function perflab_enqueue_features_page_scripts(): void { // Enqueue plugin activate AJAX script and localize script data. wp_enqueue_script( 'perflab-plugin-activate-ajax', - plugin_dir_url( PERFLAB_MAIN_FILE ) . perflab_get_asset_path( 'includes/admin/plugin-activate-ajax.js' ), + plugins_url( perflab_get_asset_path( 'includes/admin/plugin-activate-ajax.js' ), PERFLAB_MAIN_FILE ), array( 'wp-i18n', 'wp-a11y', 'wp-api-fetch' ), PERFLAB_VERSION, true diff --git a/plugins/web-worker-offloading/helper.php b/plugins/web-worker-offloading/helper.php index a3b15219a..e9cc956d1 100644 --- a/plugins/web-worker-offloading/helper.php +++ b/plugins/web-worker-offloading/helper.php @@ -23,7 +23,7 @@ function plwwo_get_configuration(): array { $config = array( // The source code in the build directory is compiled from . // See webpack config in the WordPress/performance repo: . - 'lib' => wp_parse_url( plugin_dir_url( __FILE__ ), PHP_URL_PATH ) . 'build/', + 'lib' => wp_parse_url( plugins_url( 'build/', __FILE__ ), PHP_URL_PATH ), ); if ( WP_DEBUG && SCRIPT_DEBUG ) {