diff --git a/.github/workflows/deploy-plugins.yml b/.github/workflows/deploy-plugins.yml index 7a3c286d3..4cd7d41bc 100644 --- a/.github/workflows/deploy-plugins.yml +++ b/.github/workflows/deploy-plugins.yml @@ -69,9 +69,6 @@ jobs: - name: Install npm dependencies run: npm ci - - name: Check plugin versions - run: npm run versions -- --plugin=${{ matrix.plugin }} - - name: Build plugin run: npm run build:plugin:${{ matrix.plugin }} @@ -101,6 +98,10 @@ jobs: echo "deploy=true" >> $GITHUB_OUTPUT + - name: Check plugin version integrity + if: steps.check-deployment.outputs.deploy == 'true' + run: npm run versions -- --plugin=${{ matrix.plugin }} + - name: Create zip file if: steps.check-deployment.outputs.deploy == 'true' run: | 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/detect.js b/plugins/image-prioritizer/detect.js index 54fe64d09..63c1c2770 100644 --- a/plugins/image-prioritizer/detect.js +++ b/plugins/image-prioritizer/detect.js @@ -43,18 +43,6 @@ function log( ...message ) { console.log( consoleLogPrefix, ...message ); } -/** - * Logs a warning. - * - * @since 0.3.0 - * - * @param {...*} message - */ -function warn( ...message ) { - // eslint-disable-next-line no-console - console.warn( consoleLogPrefix, ...message ); -} - /** * Initializes extension. * @@ -77,27 +65,6 @@ export async function initialize( { isDebug, onLCP } ) { ); } -/** - * Gets the performance resource entry for a given URL. - * - * @since 0.3.0 - * - * @param {string} url - Resource URL. - * @return {PerformanceResourceTiming|null} Resource entry or null. - */ -function getPerformanceResourceByURL( url ) { - const entries = - /** @type PerformanceResourceTiming[] */ performance.getEntriesByType( - 'resource' - ); - for ( const entry of entries ) { - if ( entry.name === url ) { - return entry; - } - } - return null; -} - /** * Handles a new LCP metric being reported. * @@ -129,21 +96,6 @@ function handleLCPMetric( metric, isDebug ) { continue; } - // Now only consider proceeding with the URL if its loading was initiated with stylesheet or preload link. - const resourceEntry = getPerformanceResourceByURL( entry.url ); - if ( - ! resourceEntry || - ! [ 'css', 'link' ].includes( resourceEntry.initiatorType ) - ) { - if ( isDebug ) { - warn( - `Skipped considering URL (${ entry.url }) due to unexpected performance resource timing entry:`, - resourceEntry - ); - } - return; - } - // Skip URLs that are excessively long. This is the maxLength defined in image_prioritizer_add_element_item_schema_properties(). if ( entry.url.length > 500 ) { if ( isDebug ) { 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 ) {