Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Slim SEO - 2 #32

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix merge conflict
  • Loading branch information
jdevalk committed Jul 2, 2024
commit 37a881b60fe8acbb772d2585818eac7658aff921
24 changes: 12 additions & 12 deletions src/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class Frontend {
* @return void
*/
public function register_hooks() {
add_action( 'template_redirect', [ $this, 'redirect_tag_pages' ] );
add_filter( 'get_the_tags', [ $this, 'filter_get_the_tags' ] );
add_filter( 'get_the_terms', [ $this, 'filter_get_the_terms' ], 10, 3 );
add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', [ $this, 'exclude_tags_from_yoast_sitemap' ] );
add_filter( 'wp_sitemaps_taxonomies_query_args', [ $this, 'exclude_tags_from_core_sitemap' ], 10, 2 );
add_filter( 'slim_seo_taxonomy_query_args', [ $this, 'exclude_tags_from_slim_seo_sitemap' ] );
\add_action( 'template_redirect', [ $this, 'redirect_tag_pages' ] );
\add_filter( 'get_the_tags', [ $this, 'filter_get_the_tags' ] );
\add_filter( 'get_the_terms', [ $this, 'filter_get_the_terms' ], 10, 3 );
\add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', [ $this, 'exclude_tags_from_yoast_sitemap' ] );
\add_filter( 'wp_sitemaps_taxonomies_query_args', [ $this, 'exclude_tags_from_core_sitemap' ], 10, 2 );
\add_filter( 'slim_seo_taxonomy_query_args', [ $this, 'exclude_tags_from_slim_seo_sitemap' ] );
}

/**
Expand Down Expand Up @@ -124,7 +124,7 @@ public function exclude_tags_from_slim_seo_sitemap( $args ) {
}

// exclude terms with too few posts.
$args['exclude'] = array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
$args['exclude'] = \array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
return $args;
}

Expand All @@ -141,13 +141,13 @@ public function get_tag_ids_with_fewer_than_min_posts() {
];

// Fetch all tag IDs.
$tag_ids = get_terms( $args );
$tag_ids = \get_terms( $args );

// Filter tag IDs based on post count.
$filtered_tag_ids = array_filter(
$filtered_tag_ids = \array_filter(
$tag_ids,
function ( $tag_id ) {
$tag = get_term( $tag_id, 'post_tag' );
$tag = \get_term( $tag_id, 'post_tag' );
return ( $tag->count < \FewerTags\Plugin::$min_posts_count );
}
);
Expand Down Expand Up @@ -175,9 +175,9 @@ public function exclude_tags_from_yoast_sitemap( $excluded_term_ids ) {

$tags = get_terms( $args );

if ( ! is_wp_error( $tags ) ) {
if ( ! \is_wp_error( $tags ) ) {
foreach ( $tags as $tag_id ) {
$term = get_term( $tag_id );
$term = \get_term( $tag_id );
if ( $term->count < \FewerTags\Plugin::$min_posts_count ) {
$excluded_term_ids[] = $tag_id;
}
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.