Skip to content

Commit

Permalink
Merge pull request #20452 from Yoast/20066-add-default-allowlis-to-re…
Browse files Browse the repository at this point in the history
…move-unregistered-url-parameters

20066 add default allowlis to remove unregistered url parameters
  • Loading branch information
hdvos authored Jun 29, 2023
2 parents 4635643 + 37002fe commit 4d20cef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/helpers/crawl-cleanup-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,25 @@ public function should_avoid_redirect() {
* @return array The list of the allowed extra vars.
*/
public function get_allowed_extravars() {
$default_allowed_extravars = [
'utm_source',
'utm_medium',
'utm_campaign',
'utm_term',
'utm_content',
'gclid',
'gtm_debug',
];

/**
* Filter: 'Yoast\WP\SEO\allowlist_permalink_vars' - Allows plugins to register their own variables not to clean.
*
* @since 19.2.0
*
* @param array $allowed_extravars The list of the allowed vars (empty by default).
*/
$allowed_extravars = \apply_filters( 'Yoast\WP\SEO\allowlist_permalink_vars', [] );

$allowed_extravars = \apply_filters( 'Yoast\WP\SEO\allowlist_permalink_vars', $default_allowed_extravars );

$clean_permalinks_extra_variables = $this->options_helper->get( 'clean_permalinks_extra_variables' );

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/helpers/crawl-cleanup-helper-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function test_get_allowed_extravars( $clean_permalinks_extra_variables, $

Monkey\Functions\expect( 'apply_filters' )
->once()
->with( 'Yoast\WP\SEO\allowlist_permalink_vars', [] )
->with( 'Yoast\WP\SEO\allowlist_permalink_vars', [ 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gclid', 'gtm_debug' ] )
->andReturn( $permalink_vars );

$this->options_helper
Expand Down

0 comments on commit 4d20cef

Please sign in to comment.