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.admin.general.php

mywp.controller.module.admin.general.php in My WP Customize Admin/Frontend 1.5, at controller/modules/mywp.controller.module.admin.general.php

509 lines 10.4 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( 'MywpControllerModuleAdminGeneral' ) ) :
12
13 final class MywpControllerModuleAdminGeneral extends MywpControllerAbstractModule {
14
15 static protected $id = 'admin_general';
16
17 public static function mywp_controller_initial_data( $initial_data ) {
18
19 $initial_data['hide_update_notice'] = array(
20 'core' => '',
21 'plugins' => '',
22 'themes' => '',
23 'translations' => '',
24 );
25
26 $initial_data['hide_screen_tabs'] = array(
27 'options' => '',
28 'help' => '',
29 );
30
31 $initial_data['hide_footer_text'] = array(
32 'left' => '',
33 'right' => '',
34 );
35
36 $initial_data['custom_footer_text'] = '';
37 $initial_data['hide_core_title_tag'] = '';
38 $initial_data['include_css_file'] = '';
39 $initial_data['include_js_file'] = '';
40 $initial_data['input_css'] = '';
41 $initial_data['max_post_revision'] = '';
42 $initial_data['not_use_admin'] = '';
43
44 return $initial_data;
45
46 }
47
48 public static function mywp_controller_default_data( $default_data ) {
49
50 $default_data['hide_update_notice'] = array(
51 'core' => false,
52 'plugins' => false,
53 'themes' => false,
54 'translations' => false,
55 );
56
57 $default_data['hide_screen_tabs'] = array(
58 'options' => false,
59 'help' => false,
60 );
61
62 $default_data['hide_footer_text'] = array(
63 'left' => false,
64 'right' => false,
65 );
66
67 $default_data['custom_footer_text'] = '';
68 $default_data['hide_core_title_tag'] = false;
69 $default_data['include_css_file'] = '';
70 $default_data['include_js_file'] = '';
71 $default_data['input_css'] = '';
72 $default_data['max_post_revision'] = -1;
73 $default_data['not_use_admin'] = false;
74
75 return $default_data;
76
77 }
78
79 public static function mywp_wp_loaded() {
80
81 if( ! is_admin() ) {
82
83 return false;
84
85 }
86
87 if( is_network_admin() ) {
88
89 return false;
90
91 }
92
93 if( ! self::is_do_controller() ) {
94
95 return false;
96
97 }
98
99 self::not_use_admin();
100
101 add_filter( 'site_transient_update_plugins' , array( __CLASS__ , 'hide_update_notice_plugins' ) );
102
103 add_filter( 'site_transient_update_themes' , array( __CLASS__ , 'hide_update_notice_themes' ) );
104
105 add_filter( 'site_transient_update_core' , array( __CLASS__ , 'hide_update_notice_core' ) );
106
107 add_filter( 'wp_revisions_to_keep' , array( __CLASS__ , 'max_post_revision' ) );
108
109 add_filter( 'admin_title' , array( __CLASS__ , 'hide_core_title_tag' ) );
110
111 add_action( 'admin_enqueue_scripts' , array( __CLASS__ , 'admin_enqueue_scripts' ) );
112
113 add_action( 'admin_enqueue_scripts' , array( __CLASS__ , 'include_jc_css' ) );
114
115 add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_screen_tabs' ) );
116
117 add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_footer_text' ) );
118
119 add_action( 'admin_print_styles' , array( __CLASS__ , 'input_css' ) );
120
121 add_action( 'admin_footer' , array( __CLASS__ , 'custom_footer_text' ) );
122
123 }
124
125 private static function not_use_admin() {
126
127 if( ! self::is_do_function( __FUNCTION__ ) ) {
128
129 return false;
130
131 }
132
133 if( MywpHelper::is_doing( 'cron' ) or MywpHelper::is_doing( 'xmlrpc' ) or MywpHelper::is_doing( 'ajax' ) or MywpHelper::is_doing( 'rest' ) ) {
134
135 return false;
136
137 }
138
139 $setting_data = self::get_setting_data();
140
141 if( empty( $setting_data['not_use_admin'] ) ) {
142
143 return false;
144
145 }
146
147 wp_redirect( do_shortcode( '[mywp_url site="1"]' ) );
148
149 self::after_do_function( __FUNCTION__ );
150
151 exit;
152
153 }
154
155 public static function hide_update_notice_plugins( $site_transient ) {
156
157 if( ! self::is_do_function( __FUNCTION__ ) ) {
158
159 return $site_transient;
160
161 }
162
163 if( empty( $site_transient ) or empty( $site_transient->response ) ) {
164
165 return $site_transient;
166
167 }
168
169 $setting_data = self::get_setting_data();
170
171 if( ! empty( $setting_data['hide_update_notice']['translations'] ) ) {
172
173 if( ! empty( $site_transient->translations ) && is_array( $site_transient->translations ) ) {
174
175 $site_transient->translations = array();
176
177 }
178
179 }
180
181 if( ! empty( $setting_data['hide_update_notice']['plugins'] ) ) {
182
183 $site_transient->response = array();
184
185 }
186
187 self::after_do_function( __FUNCTION__ );
188
189 return $site_transient;
190
191 }
192
193 public static function hide_update_notice_themes( $site_transient ) {
194
195 if( ! self::is_do_function( __FUNCTION__ ) ) {
196
197 return $site_transient;
198
199 }
200
201 if( empty( $site_transient ) or empty( $site_transient->response ) ) {
202
203 return $site_transient;
204
205 }
206
207 $setting_data = self::get_setting_data();
208
209 if( ! empty( $setting_data['hide_update_notice']['translations'] ) ) {
210
211 if( ! empty( $site_transient->translations ) && is_array( $site_transient->translations ) ) {
212
213 $site_transient->translations = array();
214
215 }
216
217 }
218
219 if( ! empty( $setting_data['hide_update_notice']['themes'] ) ) {
220
221 $site_transient->response = array();
222
223 }
224
225 self::after_do_function( __FUNCTION__ );
226
227 return $site_transient;
228
229 }
230
231 public static function hide_update_notice_core( $site_transient ) {
232
233 if( ! self::is_do_function( __FUNCTION__ ) ) {
234
235 return $site_transient;
236
237 }
238
239 if( empty( $site_transient ) or empty( $site_transient->updates[0] ) or empty( $site_transient->updates[0]->response ) ) {
240
241 return $site_transient;
242
243 }
244
245 $setting_data = self::get_setting_data();
246
247 if( ! empty( $setting_data['hide_update_notice']['translations'] ) ) {
248
249 if( ! empty( $site_transient->translations ) && is_array( $site_transient->translations ) ) {
250
251 $site_transient->translations = array();
252
253 }
254
255 }
256
257 if( ! empty( $setting_data['hide_update_notice']['core'] ) ) {
258
259 $site_transient->updates[0]->response = 'latest';
260
261 }
262
263 self::after_do_function( __FUNCTION__ );
264
265 return $site_transient;
266
267 }
268
269 public static function max_post_revision( $revision_num ) {
270
271 if( ! self::is_do_function( __FUNCTION__ ) ) {
272
273 return $revision_num;
274
275 }
276
277 $setting_data = self::get_setting_data();
278
279 if( ! isset( $setting_data['max_post_revision'] ) ) {
280
281 return $revision_num;
282
283 }
284
285 if( $setting_data['max_post_revision'] === '' ) {
286
287 return $revision_num;
288
289 }
290
291 $revision_num = (int) $setting_data['max_post_revision'];
292
293 self::after_do_function( __FUNCTION__ );
294
295 return $revision_num;
296
297 }
298
299 public static function hide_core_title_tag( $title ) {
300
301 if( ! self::is_do_function( __FUNCTION__ ) ) {
302
303 return $title;
304
305 }
306
307 $setting_data = self::get_setting_data();
308
309 if( empty( $setting_data['hide_core_title_tag'] ) ) {
310
311 return $title;
312
313 }
314
315 $title = str_replace( ' &#8212; WordPress' , '' , $title );
316
317 self::after_do_function( __FUNCTION__ );
318
319 return $title;
320
321 }
322
323 public static function admin_enqueue_scripts() {
324
325 wp_register_style( 'mywp_admin_general' , MywpApi::get_plugin_url( 'css' ) . 'admin-general.css' , array() , MYWP_VERSION );
326
327 wp_enqueue_style( 'mywp_admin_general' );
328
329 }
330
331 public static function include_jc_css() {
332
333 if( ! self::is_do_function( __FUNCTION__ ) ) {
334
335 return false;
336
337 }
338
339 $setting_data = self::get_setting_data();
340
341 if( empty( $setting_data['include_js_file'] ) && empty( $setting_data['include_css_file'] ) ) {
342
343 return false;
344
345 }
346
347 $include_js_file = do_shortcode( $setting_data['include_js_file'] );
348 $include_css_file = do_shortcode( $setting_data['include_css_file'] );
349
350 if( ! empty( $include_js_file ) ) {
351
352 wp_enqueue_script( 'mywp_admin_include' , $include_js_file , array() , MYWP_VERSION , true );
353
354 }
355
356 if( ! empty( $include_css_file ) ) {
357
358 wp_enqueue_style( 'mywp_admin_include' , $include_css_file , array() , MYWP_VERSION );
359
360 }
361
362 self::after_do_function( __FUNCTION__ );
363
364 }
365
366 public static function hide_screen_tabs() {
367
368 if( ! self::is_do_function( __FUNCTION__ ) ) {
369
370 return false;
371
372 }
373
374 $setting_data = self::get_setting_data();
375
376 if( empty( $setting_data['hide_screen_tabs']['options'] ) && empty( $setting_data['hide_screen_tabs']['help'] ) ) {
377
378 return false;
379
380 }
381
382 echo '<style>';
383
384 if( ! empty( $setting_data['hide_screen_tabs']['options'] ) ) {
385
386 echo 'body.wp-admin #screen-options-link-wrap { display: none; }';
387
388 }
389
390 if( ! empty( $setting_data['hide_screen_tabs']['help'] ) ) {
391
392 echo 'body.wp-admin #contextual-help-link-wrap { display: none; }';
393
394 }
395
396 echo '</style>';
397
398 self::after_do_function( __FUNCTION__ );
399
400 }
401
402 public static function hide_footer_text() {
403
404 if( ! self::is_do_function( __FUNCTION__ ) ) {
405
406 return false;
407
408 }
409
410 $setting_data = self::get_setting_data();
411
412 if( empty( $setting_data['hide_footer_text']['left'] ) && empty( $setting_data['hide_footer_text']['right'] ) ) {
413
414 return false;
415
416 }
417
418 echo '<style>';
419
420 if( ! empty( $setting_data['hide_footer_text']['left'] ) && ! empty( $setting_data['hide_footer_text']['right'] ) ) {
421
422 echo 'body.wp-admin #wpfooter { display: none; }';
423
424 } else {
425
426 if( ! empty( $setting_data['hide_footer_text']['left'] ) ) {
427
428 echo 'body.wp-admin #wpfooter #footer-left { display: none; }';
429
430 }
431
432 if( ! empty( $setting_data['hide_footer_text']['right'] ) ) {
433
434 echo 'body.wp-admin #wpfooter #footer-upgrade { display: none; }';
435
436 }
437
438 }
439
440 echo '</style>';
441
442 self::after_do_function( __FUNCTION__ );
443
444 }
445
446 public static function input_css() {
447
448 if( ! self::is_do_function( __FUNCTION__ ) ) {
449
450 return false;
451
452 }
453
454 $setting_data = self::get_setting_data();
455
456 if( empty( $setting_data['input_css'] ) ) {
457
458 return false;
459
460 }
461
462 $input_css = do_shortcode( $setting_data['input_css'] );
463
464 echo '<style>';
465 echo $input_css;
466 echo '</style>';
467
468 self::after_do_function( __FUNCTION__ );
469
470 }
471
472 public static function custom_footer_text() {
473
474 if( ! self::is_do_function( __FUNCTION__ ) ) {
475
476 return false;
477
478 }
479
480 $setting_data = self::get_setting_data();
481
482 if( empty( $setting_data['custom_footer_text'] ) ) {
483
484 return false;
485
486 }
487
488 $custom_footer_text = do_shortcode( $setting_data['custom_footer_text'] );
489
490 echo '<style>';
491 echo 'body.wp-admin #wpfooter { position: relative; }';
492 echo '</style>';
493
494 echo '<div class="clear"></div>';
495
496 echo '<div id="mywp-custom-footer-text">';
497 echo $custom_footer_text;
498 echo '</div>';
499
500 self::after_do_function( __FUNCTION__ );
501
502 }
503
504 }
505
506 MywpControllerModuleAdminGeneral::init();
507
508 endif;
509