From fe7e81eb7cee86d61366e790ce148f9a62225d28 Mon Sep 17 00:00:00 2001 From: SohamPatel46 Date: Thu, 19 Dec 2024 16:33:38 +0530 Subject: [PATCH] Update all instance of plugin_dir_url() to plugins_url() --- plugins/embed-optimizer/hooks.php | 2 +- plugins/image-prioritizer/helper.php | 2 +- plugins/optimization-detective/detection.php | 4 ++-- plugins/optimization-detective/readme.txt | 2 +- plugins/performance-lab/includes/admin/load.php | 2 +- plugins/web-worker-offloading/helper.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/embed-optimizer/hooks.php b/plugins/embed-optimizer/hooks.php index 988a5a2dfd..33e8aff954 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 75c3e18d43..e333529790 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 2fa2a6dee7..116249704d 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 1e783ef823..6b21e03fdc 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 8416f3e74a..634c53795a 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 a3b15219a0..e9cc956d1c 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 ) {