-
-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathTaxonomyRewriteTesting.php
More file actions
40 lines (29 loc) · 806 Bytes
/
TaxonomyRewriteTesting.php
File metadata and controls
40 lines (29 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare( strict_types=1 );
namespace ExtCPTs;
use WP_Taxonomy;
class TaxonomyRewriteTesting extends ExtendedRewriteTesting {
public Taxonomy $taxo;
public function __construct( Taxonomy $taxo ) {
$this->taxo = $taxo;
}
/**
* @return array<string,array<string,string>>
*/
public function get_tests(): array {
global $wp_rewrite;
if ( ! $wp_rewrite->using_permalinks() ) {
return [];
}
if ( ! isset( $wp_rewrite->extra_permastructs[ $this->taxo->taxonomy ] ) ) {
return [];
}
$struct = $wp_rewrite->extra_permastructs[ $this->taxo->taxonomy ];
/** @var WP_Taxonomy */
$tax = get_taxonomy( $this->taxo->taxonomy );
$name = sprintf( '%s (%s)', $tax->labels->name, $this->taxo->taxonomy );
return [
$name => $this->get_rewrites( $struct, [] ),
];
}
}