Skip to content

Commit

Permalink
Merge pull request #49 from happyprime/fix/hide-private-taxonomies
Browse files Browse the repository at this point in the history
Hide private post type shadow terms in unauthed REST requests
  • Loading branch information
jeremyfelt authored Mar 1, 2024
2 parents 6c96cca + 4001c9f commit f30106d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions includes/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ function register_taxonomy( string $post_type ): void {
'show_admin_column' => true,
);

// If a post type is not publicly queryable and not visible in the REST API,
// we should not expose that post type's shadow terms to unauthorized users.
if ( false === $post_type_object->publicly_queryable && false === $post_type_object->show_in_rest && ! is_user_logged_in() ) {
$args['show_in_rest'] = false;
}

/**
* Filter the arguments used to register a shadow taxonomy.
*
Expand Down

0 comments on commit f30106d

Please sign in to comment.