PluginProbe
My WP Customize Admin/Frontend / 1.5
My WP Customize Admin/Frontend v1.5
1.27.4 1.27.3 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.10 1.10.1 1.10.2 1.11 1.12 1.12.1 1.12.2 1.13 1.13.1 1.13.2 1.14 1.15.0 1.16 1.17.0 All 76 releases
my-wp / controller / modules / mywp.controller.module.frontend.taxonomy-archive.php

mywp.controller.module.frontend.taxonomy-archive.php in My WP Customize Admin/Frontend 1.5, at controller/modules/mywp.controller.module.frontend.taxonomy-archive.php

110 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 if( ! class_exists( 'MywpControllerAbstractModule' ) ) {
8 return false;
9 }
10
11 if ( ! class_exists( 'MywpControllerModuleFrontendTaxonomyArchive' ) ) :
12
13 final class MywpControllerModuleFrontendTaxonomyArchive extends MywpControllerAbstractModule {
14
15 static protected $id = 'frontend_taxonomy_archive';
16
17 static private $taxonomy = '';
18
19 public static function mywp_controller_initial_data( $initial_data ) {
20
21 $initial_data['disable_archive'] = '';
22
23 return $initial_data;
24
25 }
26
27 public static function mywp_controller_default_data( $default_data ) {
28
29 $default_data['disable_archive'] = false;
30
31 return $default_data;
32
33 }
34
35 public static function mywp_get_option_key( $option_key ) {
36
37 if( empty( self::$taxonomy ) ) {
38
39 return $option_key;
40
41 }
42
43 $option_key .= '_' . self::$taxonomy;
44
45 return $option_key;
46
47 }
48
49 public static function mywp_wp_loaded() {
50
51 if( is_admin() ) {
52
53 return false;
54
55 }
56
57 if( ! self::is_do_controller() ) {
58
59 return false;
60
61 }
62
63 add_action( 'pre_get_posts' , array( __CLASS__ , 'disable_archive' ) );
64
65 }
66
67 public static function disable_archive( $wp_query ) {
68
69 if( ! self::is_do_function( __FUNCTION__ ) ) {
70
71 return $wp_query;
72
73 }
74
75 if( empty( $wp_query->is_category ) && empty( $wp_query->is_tag ) && empty( $wp_query->is_tax ) ) {
76
77 return $wp_query;
78
79 }
80
81 if( empty( $wp_query->tax_query ) && empty( $wp_query->tax_query->queried_terms )) {
82
83 return $wp_query;
84
85 }
86
87 self::$taxonomy = key( $wp_query->tax_query->queried_terms );
88
89 add_filter( 'mywp_get_option_key_mywp_frontend_taxonomy_archive' , array( __CLASS__ , 'mywp_get_option_key' ) );
90
91 $setting_data = self::get_setting_data();
92
93 if( empty( $setting_data['disable_archive'] ) ) {
94
95 return $wp_query;
96
97 }
98
99 $wp_query->set_404();
100
101 self::after_do_function( __FUNCTION__ );
102
103 }
104
105 }
106
107 MywpControllerModuleFrontendTaxonomyArchive::init();
108
109 endif;
110