Skip to content

Commit d332c1b

Browse files
Merge pull request #20740 from Yoast/20729-wp-64-pattern-categories-are-displayed-in-settings-and-sitemap
20729 wp 64 pattern categories are displayed in settings and sitemap
2 parents 7b2e118 + 74518e4 commit d332c1b

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

inc/sitemaps/class-taxonomy-sitemap-provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public function is_valid_taxonomy( $taxonomy_name ) {
287287
return false;
288288
}
289289

290-
if ( in_array( $taxonomy_name, [ 'link_category', 'nav_menu' ], true ) ) {
290+
if ( in_array( $taxonomy_name, [ 'link_category', 'nav_menu', 'wp_pattern_category' ], true ) ) {
291291
return false;
292292
}
293293

src/integrations/admin/indexables-exclude-taxonomy-integration.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ public function register_hooks() {
4141
*
4242
* @param array $excluded_taxonomies The excluded taxonomies.
4343
*
44-
* @return array The excluded post types, including the specific post type.
44+
* @return array The excluded taxonomies, including specific taxonomies.
4545
*/
4646
public function exclude_taxonomies_for_indexation( $excluded_taxonomies ) {
47+
$taxonomies_to_exclude = \array_merge( $excluded_taxonomies, [ 'wp_pattern_category' ] );
48+
4749
if ( $this->options_helper->get( 'disable-post_format', false ) ) {
48-
return \array_merge( $excluded_taxonomies, [ 'post_format' ] );
50+
return \array_merge( $taxonomies_to_exclude, [ 'post_format' ] );
4951
}
5052

51-
return $excluded_taxonomies;
53+
return $taxonomies_to_exclude;
5254
}
5355
}

tests/integration/sitemaps/test-class-wpseo-taxonomy-sitemap-provider.php

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Class WPSEO_Taxonomy_Sitemap_Provider_Test.
1010
*
1111
* @group sitemaps
12+
* @coversDefaultClass WPSEO_Taxonomy_Sitemap_Provider
1213
*/
1314
class WPSEO_Taxonomy_Sitemap_Provider_Test extends WPSEO_UnitTestCase {
1415

@@ -31,7 +32,7 @@ public function set_up() {
3132
/**
3233
* Tests the retrieval of the index links.
3334
*
34-
* @covers WPSEO_Taxonomy_Sitemap_Provider::get_index_links
35+
* @covers ::get_index_links
3536
*/
3637
public function test_get_index_links() {
3738

@@ -57,7 +58,7 @@ public function test_get_index_links() {
5758
/**
5859
* Tests retrieval of the sitemap links.
5960
*
60-
* @covers WPSEO_Taxonomy_Sitemap_Provider::get_sitemap_links
61+
* @covers ::get_sitemap_links
6162
*/
6263
public function test_get_sitemap_links() {
6364

@@ -71,7 +72,7 @@ public function test_get_sitemap_links() {
7172
/**
7273
* Makes sure invalid sitemap pages return no contents (404).
7374
*
74-
* @covers WPSEO_Taxonomy_Sitemap_Provider::get_index_links
75+
* @covers ::get_index_links
7576
*/
7677
public function test_get_index_links_empty_sitemap() {
7778
// Fetch the global sitemap.
@@ -87,4 +88,44 @@ public function test_get_index_links_empty_sitemap() {
8788
// Expect an empty page (404) to be returned.
8889
$this->expectOutputString( '' );
8990
}
91+
92+
/**
93+
* Data provider for is_valid_taxonomy test.
94+
*
95+
* @return array
96+
*/
97+
public function data_provider_is_valis_taxonomy() {
98+
return [
99+
'Pattern Categories' => [
100+
'taxonomy' => 'wp_pattern_category',
101+
'expected' => false,
102+
],
103+
'nav_menu' => [
104+
'taxonomy' => 'nav_menu',
105+
'expected' => false,
106+
],
107+
'link_category' => [
108+
'taxonomy' => 'link_category',
109+
'expected' => false,
110+
],
111+
'post_format' => [
112+
'taxonomy' => 'post_format',
113+
'expected' => false,
114+
],
115+
];
116+
}
117+
118+
/**
119+
* Tetst of is_valid_taxonomy.
120+
*
121+
* @covers ::is_valid_taxonomy
122+
*
123+
* @dataProvider data_provider_is_valis_taxonomy
124+
*
125+
* @param string $taxonomy Taxonomy name.
126+
* @param bool $expected Expected result.
127+
*/
128+
public function test_is_valid_taxonomy( $taxonomy, $expected ) {
129+
$this->assertSame( $expected, self::$class_instance->is_valid_taxonomy( $taxonomy ) );
130+
}
90131
}

0 commit comments

Comments
 (0)