Skip to content

Commit

Permalink
Remove filter_unique_term_slug since only applies when duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Nov 20, 2020
1 parent b483566 commit 52a30cc
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions src/PairedAmpRouting.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,39 +411,6 @@ public function filter_unique_post_slug( $slug, $post_id, /** @noinspection PhpU
return $slug;
}

/**
* Filters the term slug to prevent conflicting with the 'amp' slug.
*
* @see wp_unique_term_slug()
*
* @param string $slug Slug.
* @return string Slug.
* @global \wpdb $wpdb WP DB.
*/
public function filter_unique_term_slug( $slug ) {
global $wpdb;

$amp_slug = amp_get_slug();
if ( $amp_slug !== $slug ) {
return $slug;
}

$suffix = 2;
do {
$alt_slug = "$slug-$suffix";
$slug_check = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*) FROM $wpdb->terms WHERE slug = %s LIMIT 1",
$alt_slug
)
);
$suffix++;
} while ( $slug_check );
$slug = $alt_slug;

return $slug;
}

/**
* Add AMP hooks if it is an AMP request.
*/
Expand Down

0 comments on commit 52a30cc

Please sign in to comment.