88namespace Osi \Features \Inc ;
99
1010use Osi \Features \Inc \Traits \Singleton ;
11+ use Osi \Features \Inc \Post_Types \Post_Type_Board_Member ;
12+ use Osi \Features \Inc \Taxonomies \Taxonomy_Status ;
13+ use Osi \Features \Inc \Post_Types \Post_Type_License ;
14+ use Osi \Features \Inc \Taxonomies \Taxonomy_License_Category ;
15+ use Osi \Features \Inc \Post_Types \Post_Type_Press_Mentions ;
16+ use Osi \Features \Inc \Taxonomies \Taxonomy_Publication ;
17+ use Osi \Features \Inc \Taxonomies \Taxonomy_Seat_Type ;
18+ use Osi \Features \Inc \Taxonomies \Taxonomy_Steward ;
1119
1220/**
1321 * Class Rewrite
@@ -32,6 +40,7 @@ protected function __construct() {
3240 */
3341 protected function setup_hooks () {
3442 add_filter ( 'query_vars ' , array ( $ this , 'add_query_vars ' ), 10 );
43+ add_action ( 'init ' , [ $ this , 'add_custom_rewrite_rules ' ], 20 );
3544 }
3645
3746 public function add_query_vars ( $ vars ) {
@@ -40,4 +49,48 @@ public function add_query_vars( $vars ) {
4049 return $ vars ;
4150 }
4251
52+ /**
53+ * Add custom rewrite rules for custom post types and taxonomies.
54+ *
55+ * @return void
56+ */
57+ public function add_custom_rewrite_rules () {
58+ $ base = Post_Type_License::get_instance ()->get_slug ();
59+ add_rewrite_rule (
60+ '^ ' . $ base . '/steward/([^/]+)/?$ ' ,
61+ 'index.php?taxonomy= ' . Taxonomy_Steward::SLUG . '&term=$matches[1] ' ,
62+ 'top '
63+ );
64+
65+ $ base = Post_Type_Board_Member::get_instance ()->get_slug ();
66+ add_rewrite_rule (
67+ '^ ' . $ base . '/status/([^/]+)/?$ ' ,
68+ 'index.php?taxonomy= ' . Taxonomy_Status::SLUG . '&term=$matches[1] ' ,
69+ 'top '
70+ );
71+
72+ $ base = Post_Type_Board_Member::get_instance ()->get_slug ();
73+ add_rewrite_rule (
74+ '^ ' . $ base . '/seat-type/([^/]+)/?$ ' ,
75+ 'index.php?taxonomy= ' . Taxonomy_Seat_Type::SLUG . '&term=$matches[1] ' ,
76+ 'top '
77+ );
78+
79+ $ base = Post_Type_License::get_instance ()->get_slug ();
80+ add_rewrite_rule (
81+ '^ ' . $ base . '/category/([^/]+)/?$ ' ,
82+ 'index.php?taxonomy= ' . Taxonomy_License_Category::SLUG . '&term=$matches[1] ' ,
83+ 'top '
84+ );
85+
86+ $ base = Post_Type_Press_Mentions::get_instance ()->get_slug ();
87+ add_rewrite_rule (
88+ '^ ' . $ base . '/publication/([^/]+)/?$ ' ,
89+ 'index.php?taxonomy= ' . Taxonomy_Publication::SLUG . '&term=$matches[1] ' ,
90+ 'top '
91+ );
92+
93+
94+ }
95+
4396}
0 commit comments