@@ -19,47 +19,42 @@ class MslsOptionsTax extends MslsOptions implements OptionsTaxInterface {
1919 * @return OptionsTaxInterface
2020 */
2121 public static function create ( $ id = 0 ): OptionsTaxInterface {
22- $ id = ! empty ( $ id ) ? (int ) $ id : get_queried_object_id ();
23-
24- $ req = '' ;
25- if ( is_admin () ) {
26- $ req = msls_content_types ()->acl_request ();
27- } elseif ( is_category () ) {
28- $ req = 'category ' ;
29- } elseif ( is_tag ( $ id ) ) {
30- $ req = 'post_tag ' ;
31- }
22+ $ id = ! empty ( $ id ) ? (int ) $ id : get_queried_object_id ();
23+ $ req = self ::get_content_type ( $ id );
3224
3325 switch ( $ req ) {
3426 case 'category ' :
3527 $ options = new MslsOptionsTaxTermCategory ( $ id );
36- add_filter ( 'msls_get_postlink ' , array ( $ options , 'check_base ' ), 9 , 2 );
3728 break ;
3829 case 'post_tag ' :
3930 $ options = new MslsOptionsTaxTerm ( $ id );
40- add_filter ( 'msls_get_postlink ' , array ( $ options , 'check_base ' ), 9 , 2 );
4131 break ;
4232 default :
43- global $ wp_rewrite ;
44-
45- $ options = new MslsOptionsTax ( $ id );
46- $ options ->with_front = ! empty ( $ wp_rewrite ->extra_permastructs [ $ options ->get_tax_query () ]['with_front ' ] );
33+ $ options = new MslsOptionsTax ( $ id );
4734 }
4835
49- return $ options ;
36+ return $ options-> handle_rewrite () ;
5037 }
5138
5239 /**
5340 * @param int $id
5441 *
5542 * @return string
5643 */
57- public function get_content_type ( int $ id ): string {
44+ public static function get_content_type ( int $ id ): string {
5845 if ( is_admin () ) {
5946 return msls_content_types ()->acl_request ();
6047 }
6148
62- return ( is_category () ? 'category ' : is_tag ( $ id ) ) ? 'post_tag ' : '' ;
49+ return ( is_category ( $ id ) ? 'category ' : ( is_tag ( $ id ) ? 'post_tag ' : '' ) );
50+ }
51+
52+ public function handle_rewrite (): OptionsTaxInterface {
53+ global $ wp_rewrite ;
54+
55+ $ this ->with_front = ! empty ( $ wp_rewrite ->extra_permastructs [ $ this ->get_tax_query () ]['with_front ' ] );
56+
57+ return $ this ;
6358 }
6459
6560 /**
0 commit comments