Skip to content

Use plugins_url() to allow Workbox script URLs to be filtered#600

Merged
westonruter merged 2 commits intodevelopfrom
add/plugin-url-filterability
Aug 24, 2021
Merged

Use plugins_url() to allow Workbox script URLs to be filtered#600
westonruter merged 2 commits intodevelopfrom
add/plugin-url-filterability

Conversation

@westonruter
Copy link
Collaborator

@westonruter westonruter commented Aug 23, 2021

Fixes #543.

Let's say you have all of the PWA plugin's files located at a CDN with the URL https://pwa-wp-cdn.example.com/. You could achieve that with the following plugin code:

if ( defined( 'PWA_PLUGIN_FILE' ) ) {
	add_filter(
		'plugins_url',
		static function ( $url, $path, $plugin ) {
			if ( PWA_PLUGIN_FILE === $plugin ) {
				$url = "https://pwa-wp-cdn.example.com/{$path}";
			}
			return $url;
		},
		10,
		3
	);
}
@westonruter westonruter added this to the 0.7 milestone Aug 23, 2021
@google-cla google-cla bot added the cla: yes label Aug 23, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #600 (df1598b) into update/skip-waiting-message (49603fe) will decrease coverage by 0.04%.
The diff coverage is 0.00%.

Impacted file tree graph

@@                        Coverage Diff                        @@
##             update/skip-waiting-message     #600      +/-   ##
=================================================================
- Coverage                          16.78%   16.74%   -0.05%     
  Complexity                           305      305              
=================================================================
  Files                                 55       55              
  Lines                               2008     2013       +5     
=================================================================
  Hits                                 337      337              
- Misses                              1671     1676       +5     
Flag Coverage Δ
php 16.74% <0.00%> (-0.05%) ⬇️
unit 16.74% <0.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...lass-wp-service-worker-configuration-component.php 0.00% <0.00%> (ø)
wp-includes/service-workers.php 18.96% <0.00%> (-0.68%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49603fe...df1598b. Read the comment docs.

Base automatically changed from update/skip-waiting-message to develop August 24, 2021 00:55
@westonruter westonruter force-pushed the add/plugin-url-filterability branch from df1598b to 8f87703 Compare August 24, 2021 00:58
@westonruter westonruter merged commit ecad71d into develop Aug 24, 2021
@westonruter westonruter deleted the add/plugin-url-filterability branch August 24, 2021 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants