PluginProbe
My WP Customize Admin/Frontend / 1.22.0
My WP Customize Admin/Frontend v1.22.0
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 / abstract.controller.module.php

abstract.controller.module.php in My WP Customize Admin/Frontend 1.22.0, at controller/abstract.controller.module.php

161 lines 3.2 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
9 abstract class MywpControllerAbstractModule {
10
11 static protected $id = '';
12
13 static protected $priority = 10;
14
15 static protected $network = false;
16
17 static protected $is_do_controller = false;
18
19 public static function init() {
20
21 $class = get_called_class();
22
23 if( empty( static::$id ) ) {
24
25 $called_text = sprintf( 'class %s' , $class );
26
27 MywpHelper::error_require_message( '"static protected $id"' , $called_text );
28
29 return false;
30
31 }
32
33 add_filter( 'mywp_controllers' , array( $class , 'mywp_controllers' ) , static::$priority );
34
35 add_filter( "mywp_controller_initial_data_{$class::$id}" , array( $class , 'mywp_controller_initial_data' ) , 9 );
36
37 add_filter( "mywp_controller_default_data_{$class::$id}" , array( $class , 'mywp_controller_default_data' ) , 9 );
38
39 add_action( 'mywp_wp_loaded' , array( $class , 'mywp_wp_loaded' ) , 1000 );
40
41 static::after_init();
42
43 }
44
45 protected static function after_init() {}
46
47 public static function mywp_controllers( $controllers ) {
48
49 $controllers[ static::$id ] = array(
50 'network' => static::$network,
51 );
52
53 return $controllers;
54
55 }
56
57 public static function mywp_controller_initial_data( $initial_data ) {
58
59 return $initial_data;
60
61 }
62
63 public static function mywp_controller_default_data( $default_data ) {
64
65 return $default_data;
66
67 }
68
69 public static function get_model() {
70
71 $controller = MywpController::get_controller( static::$id );
72
73 if( empty( $controller['model'] ) ) {
74
75 $called_text = sprintf( '%s::%s()' , __CLASS__ , __FUNCTION__ );
76
77 MywpHelper::error_not_found_message( '$controller["model"]' , $called_text );
78
79 return false;
80
81 }
82
83 return $controller["model"];
84
85 }
86
87 public static function get_setting_data() {
88
89 $mywp_model = static::get_model();
90
91 if( empty( $mywp_model ) ) {
92
93 $called_text = sprintf( '%s::%s()' , __CLASS__ , __FUNCTION__ );
94
95 MywpHelper::error_not_found_message( '$mywp_model' , $called_text );
96
97 return false;
98
99 }
100
101 return $mywp_model->get_setting_data();
102
103 }
104
105 protected static function is_do_controller() {
106
107 if( ! empty( static::$is_do_controller ) ) {
108
109 return true;
110
111 }
112
113 $class = get_called_class();
114
115 $is_do_controller = apply_filters( "mywp_controller_is_do_{$class::$id}" , true );
116 $is_do_controller = apply_filters( 'mywp_controller_is_do' , $is_do_controller , static::$id );
117
118 return $is_do_controller;
119
120 }
121
122 protected static function is_do_function( $function_name = false ) {
123
124 if( empty( $function_name ) ) {
125
126 return false;
127
128 }
129
130 $class = get_called_class();
131
132 $function_name = strip_tags( $function_name );
133
134 $is_do_function = apply_filters( "mywp_controller_is_do_function_{$class::$id}_{$function_name}" , true );
135
136 return $is_do_function;
137
138 }
139
140 protected static function after_do_function( $function_name = false ) {
141
142 if( empty( $function_name ) ) {
143
144 return false;
145
146 }
147
148 $class = get_called_class();
149
150 $function_name = strip_tags( $function_name );
151
152 do_action( "mywp_controller_after_do_{$class::$id}_{$function_name}" );
153
154 }
155
156 public static function mywp_wp_loaded() {}
157
158 }
159
160 endif;
161