-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpat.php
More file actions
3770 lines (2630 loc) · 154 KB
/
wpat.php
File metadata and controls
3770 lines (2630 loc) · 154 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php /*
Plugin Name: WPAT
Plugin URI: https://cleancoded.com/wpat
Description: A clean coded WordPress admin theme
Version: 1.9
Author: CLEANCODED
Author URI: https://cleancoded.com
Text Domain: wpat
Domain Path: /languages
*/
/*****************************************************************/
/* CREATE PLUGIN PATHS */
/*****************************************************************/
/* NOTE: By adding a custom WP filter, this plugin can be called from the theme folder without installing it manually */
if ( ! function_exists( 'wpat_path' ) ) :
function wpat_path( $path ) {
if( has_filter( 'wpat_path' ) ) return apply_filters( 'wpat_path', $path ); // get custom filter path
else return plugins_url( $path , __FILE__ ); // get plugin path
}
endif;
if ( ! function_exists( 'wpat_dir' ) ) :
function wpat_dir( $path ) {
if( has_filter( 'wpat_dir' ) ) return apply_filters( 'wpat_dir', $path ); // get custom filter dir path
else return plugin_dir_path( __FILE__ ) . $path; // get plugin dir path
}
endif;
/*****************************************************************/
/* CREATE THE WPAT PLUGIN */
/*****************************************************************/
if( ! class_exists('WPAT_Options') ) :
class WPAT_Options {
/*****************************************************************/
/* ATTRIBUTES */
/*****************************************************************/
// Refers to a single instance of this class.
private static $instance = null;
// Saved options
public $options;
/*****************************************************************/
/* CONSTRUCTOR */
/*****************************************************************/
// Creates or returns an instance of this class.
public static function get_instance() {
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
} // end get_instance;
/*****************************************************************/
/* INITIALIZES THE WPAT PLUGIN */
/*****************************************************************/
public function __construct() {
if( is_admin() ) {
require_once( ABSPATH . 'wp-admin/includes/screen.php' );
// Add the page to the admin menu
add_action( 'admin_menu', array( &$this, 'wpat_add_page' ) );
// Register settings options
add_action( 'admin_init', array( &$this, 'wpat_register_settings') );
// Register page options
add_action( 'admin_init', array( &$this, 'wpat_register_page_options') );
// Register plugin page scripts
add_action( 'admin_enqueue_scripts', array( $this, 'wpat_load_plugin_page_specific_scripts') );
// Register global javascript and stylesheets
add_action( 'admin_enqueue_scripts', array( $this, 'wpat_enqueue_admin_js' ) );
// Register generate js / css files
add_action( 'admin_init', array( $this, 'wpat_generate_custom_css_js' ) );
// Check for undefined option keys
add_action( 'admin_init', array( $this, 'wpat_check_for_undefined_options' ) );
}
// Get registered options
if( is_multisite() ) {
$this->options = get_blog_option( get_current_blog_id(), 'wpat_settings_options', array() );
} else {
$this->options = get_option( 'wpat_settings_options' );
}
// Set all option field names
$this->option_fields = array(
'user_box' => esc_html__( 'User Box', 'wpat' ),
'company_box' => esc_html__( 'Company Box', 'wpat' ),
'company_box_logo' => esc_html__( 'Company Box Logo', 'wpat' ),
'company_box_logo_size' => esc_html__( 'Company Box Logo Size', 'wpat' ),
'thumbnail' => esc_html__( 'Thumbnails', 'wpat' ),
'post_page_id' => esc_html__( 'Post/Page IDs', 'wpat' ),
'hide_help' => esc_html__( 'Contextual Help', 'wpat' ),
'hide_screen_option' => esc_html__( 'Screen Options', 'wpat' ),
'left_menu_width' => esc_html__( 'Left Menu Width', 'wpat' ),
'left_menu_expand' => esc_html__( 'Left Menu Expandable', 'wpat' ),
'spacing' => esc_html__( 'Spacing', 'wpat' ),
'spacing_max_width' => esc_html__( 'Spacing Max Width', 'wpat' ),
'credits' => esc_html__( 'Credits', 'wpat' ),
'google_webfont' => esc_html__( 'Custom Web Font', 'wpat' ),
'google_webfont_weight' => esc_html__( 'Custom Web Font Weight', 'wpat' ),
'toolbar' => esc_html__( 'Toolbar', 'wpat' ),
'hide_adminbar_comments' => esc_html__( 'Toolbar Comments Menu', 'wpat' ),
'hide_adminbar_new' => esc_html__( 'Toolbar New Content Menu', 'wpat' ),
'hide_adminbar_customize' => esc_html__( 'Toolbar Customize Link', 'wpat' ),
'hide_adminbar_search' => esc_html__( 'Toolbar Search', 'wpat' ),
'toolbar_wp_icon' => esc_html__( 'Toolbar WP Icon', 'wpat' ),
'toolbar_icon' => esc_html__( 'Custom Toolbar Icon', 'wpat' ),
'theme_color' => esc_html__( 'Theme Color', 'wpat' ),
'theme_background' => esc_html__( 'Background Gradient Start Color', 'wpat' ),
'theme_background_end' => esc_html__( 'Background Gradient End Color', 'wpat' ),
'login_disable' => esc_html__( 'Customized Login Page', 'wpat' ),
'login_title' => esc_html__( 'Login Title', 'wpat' ),
'logo_upload' => esc_html__( 'Login Logo', 'wpat' ),
'logo_size' => esc_html__( 'Login Logo Size', 'wpat' ),
'login_bg' => esc_html__( 'Login Background Image', 'wpat' ),
'memory_usage' => esc_html__( 'Memory Usage', 'wpat' ),
'memory_limit' => esc_html__( 'WP Memory Limit', 'wpat' ),
'memory_available' => esc_html__( 'Memory Available', 'wpat' ),
'php_version' => esc_html__( 'PHP Version', 'wpat' ),
'ip_address' => esc_html__( 'IP Address', 'wpat' ),
'wp_version' => esc_html__( 'WP Version', 'wpat' ),
'css_admin' => esc_html__( 'WP Admin CSS', 'wpat' ),
'css_login' => esc_html__( 'WP Login CSS', 'wpat' ),
'wp_svg' => esc_html__( 'SVG Support', 'wpat' ),
'wp_ico' => esc_html__( 'ICO Support', 'wpat' ),
'disable_page_system' => esc_html__( 'WPAT System Info Page', 'wpat' ),
'disable_page_export' => esc_html__( 'WPAT Im- / Export Page', 'wpat' ),
'disable_page_ms' => esc_html__( 'WPAT Multisite Sync Page', 'wpat' ),
'disable_theme_options' => esc_html__( 'Network Theme Options', 'wpat' ),
'wp_version_tag' => esc_html__( 'WP Version Meta-Tag', 'wpat' ),
'wp_emoji' => esc_html__( 'WP Emoji', 'wpat' ),
'wp_feed_links' => esc_html__( 'WP RSS Feed', 'wpat' ),
'wp_rsd_link' => esc_html__( 'WP RSD', 'wpat' ),
'wp_wlwmanifest' => esc_html__( 'WP Wlwmanifest', 'wpat' ),
'wp_shortlink' => esc_html__( 'WP Shortlink', 'wpat' ),
'wp_rest_api' => esc_html__( 'WP REST API', 'wpat' ),
'wp_oembed' => esc_html__( 'WP oEmbed', 'wpat' ),
'wp_xml_rpc' => esc_html__( 'WP XML-RPC / X-Pingback', 'wpat' ),
'wp_heartbeat' => esc_html__( 'WP Heartbeat', 'wpat' ),
'wp_rel_link' => esc_html__( 'WP Rel Links', 'wpat' ),
'wp_self_pingback' => esc_html__( 'WP Self Pingbacks', 'wpat' ),
'mb_custom_fields' => esc_html__( 'Custom Fields Meta Box', 'wpat' ),
'mb_commentstatus' => esc_html__( 'Comments Status Meta Box', 'wpat' ),
'mb_comments' => esc_html__( 'Comments Meta Box', 'wpat' ),
'mb_author' => esc_html__( 'Author Meta Box', 'wpat' ),
'mb_category' => esc_html__( 'Categories Meta Box', 'wpat' ),
'mb_format' => esc_html__( 'Post Format Meta Box', 'wpat' ),
'mb_pageparent' => esc_html__( 'Page Parent Meta Box', 'wpat' ),
'mb_postexcerpt' => esc_html__( 'Post Excerpt Meta Box', 'wpat' ),
'mb_postimage' => esc_html__( 'Post Image Meta Box', 'wpat' ),
'mb_revisions' => esc_html__( 'Revisions Meta Box', 'wpat' ),
'mb_slug' => esc_html__( 'Slug Meta Box', 'wpat' ),
'mb_tags' => esc_html__( 'Tags Meta Box', 'wpat' ),
'mb_trackbacks' => esc_html__( 'Trackbacks Meta Box', 'wpat' ),
'dbw_quick_press' => esc_html__( 'Quick Draft Widget', 'wpat' ),
'dbw_right_now' => esc_html__( 'At the Glance Widget', 'wpat' ),
'dbw_activity' => esc_html__( 'Activity Widget', 'wpat' ),
'dbw_primary' => esc_html__( 'WP Events & News Widget', 'wpat' ),
'dbw_welcome' => esc_html__( 'Welcome Widget', 'wpat' ),
'dbw_wpat_user_log' => esc_html__( 'WPAT User Activities Widget', 'wpat' ),
'dbw_wpat_sys_info' => esc_html__( 'WPAT System Info Widget', 'wpat' ),
'dbw_wpat_count_post' => esc_html__( 'WPAT Post Count Widget', 'wpat' ),
'dbw_wpat_count_page' => esc_html__( 'WPAT Page Count Widget', 'wpat' ),
'dbw_wpat_count_comment' => esc_html__( 'WPAT Comment Count Widget', 'wpat' ),
'dbw_wpat_recent_post' => esc_html__( 'WPAT Recent Posts Widget', 'wpat' ),
'dbw_wpat_recent_page' => esc_html__( 'WPAT Recent Pages Widget', 'wpat' ),
'dbw_wpat_recent_comment' => esc_html__( 'WPAT Recent Comments Widget', 'wpat' ),
'dbw_wpat_memory' => esc_html__( 'WPAT Memory Usage Widget', 'wpat' ),
'wt_pages' => esc_html__( 'Pages Widget', 'wpat' ),
'wt_calendar' => esc_html__( 'Calendar Widget', 'wpat' ),
'wt_archives' => esc_html__( 'Archives Widget', 'wpat' ),
'wt_meta' => esc_html__( 'Meta Widget', 'wpat' ),
'wt_search' => esc_html__( 'Search Widget', 'wpat' ),
'wt_text' => esc_html__( 'Text Widget', 'wpat' ),
'wt_categories' => esc_html__( 'Categories Widget', 'wpat' ),
'wt_recent_posts' => esc_html__( 'Recent Posts Widget', 'wpat' ),
'wt_recent_comments' => esc_html__( 'Recent Comments Widget', 'wpat' ),
'wt_rss' => esc_html__( 'RSS Widget', 'wpat' ),
'wt_tag_cloud' => esc_html__( 'Tag Cloud Widget', 'wpat' ),
'wt_nav' => esc_html__( 'Navigation Menu Widget', 'wpat' ),
'wt_image' => esc_html__( 'Image Widget', 'wpat' ),
'wt_audio' => esc_html__( 'Audio Widget', 'wpat' ),
'wt_video' => esc_html__( 'Video Widget', 'wpat' ),
'wt_gallery' => esc_html__( 'Gallery Widget', 'wpat' ),
'wt_html' => esc_html__( 'Custom HTML Widget', 'wpat' ),
'wp_header_code' => esc_html__( 'Header Code', 'wpat' ),
'wp_footer_code' => esc_html__( 'Footer Code', 'wpat' ),
'meta_referrer_policy' => esc_html__( 'Meta Referrer Policy', 'wpat' ),
);
// Exception fields are not restorable
$css_admin = isset( $this->options['css_admin'] ) ? $this->options['css_admin'] : null;
$css_login = isset( $this->options['css_login'] ) ? $this->options['css_login'] : null;
$wp_header_code = isset( $this->options['wp_header_code'] ) ? $this->options['wp_header_code'] : null;
$wp_footer_code = isset( $this->options['wp_footer_code'] ) ? $this->options['wp_footer_code'] : null;
// Define pre-option values (used for restore options)
$this->pre_options = array(
'user_box' => false,
'company_box' => false,
'company_box_logo' => false,
'company_box_logo_size' => '140',
'thumbnail' => false,
'post_page_id' => false,
'hide_help' => false,
'hide_screen_option' => false,
'left_menu_width' => '200',
'left_menu_expand' => false,
'spacing' => false,
'spacing_max_width' => '2000',
'credits' => false,
'google_webfont' => false,
'google_webfont_weight' => false,
'toolbar' => false,
'hide_adminbar_comments' => false,
'hide_adminbar_new' => false,
'hide_adminbar_customize' => false,
'hide_adminbar_search' => false,
'toolbar_wp_icon' => false,
'toolbar_icon' => false,
'theme_color' => false,
'theme_background' => false,
'theme_background_end' => false,
'login_disable' => false,
'login_title' => esc_html__( 'Welcome Back.', 'wpat' ),
'logo_upload' => false,
'logo_size' => '200',
'login_bg' => false,
'memory_usage' => false,
'memory_limit' => false,
'memory_available' => false,
'php_version' => false,
'ip_address' => false,
'wp_version' => false,
'css_admin' => esc_html( $css_admin ),
'css_login' => esc_html( $css_login ),
'wp_svg' => false,
'wp_ico' => false,
'disable_page_system' => false,
'disable_page_export' => false,
'disable_page_ms' => false,
'disable_theme_options' => false,
'wp_version_tag' => false,
'wp_emoji' => false,
'wp_feed_links' => false,
'wp_rsd_link' => false,
'wp_wlwmanifest' => false,
'wp_shortlink' => false,
'wp_rest_api' => false,
'wp_oembed' => false,
'wp_xml_rpc' => false,
'wp_heartbeat' => false,
'wp_rel_link' => false,
'wp_self_pingback' => false,
'mb_custom_fields' => false,
'mb_commentstatus' => false,
'mb_comments' => false,
'mb_author' => false,
'mb_category' => false,
'mb_format' => false,
'mb_pageparent' => false,
'mb_postexcerpt' => false,
'mb_postimage' => false,
'mb_revisions' => false,
'mb_slug' => false,
'mb_tags' => false,
'mb_trackbacks' => false,
'dbw_quick_press' => false,
'dbw_right_now' => false,
'dbw_activity' => false,
'dbw_primary' => false,
'dbw_welcome' => false,
'dbw_wpat_user_log' => false,
'dbw_wpat_sys_info' => false,
'dbw_wpat_count_post' => false,
'dbw_wpat_count_page' => false,
'dbw_wpat_count_comment' => false,
'dbw_wpat_recent_post' => false,
'dbw_wpat_recent_page' => false,
'dbw_wpat_recent_comment' => false,
'dbw_wpat_memory' => false,
'wt_pages' => false,
'wt_calendar' => false,
'wt_archives' => false,
'wt_meta' => false,
'wt_search' => false,
'wt_text' => false,
'wt_categories' => false,
'wt_recent_posts' => false,
'wt_recent_comments' => false,
'wt_rss' => false,
'wt_tag_cloud' => false,
'wt_nav' => false,
'wt_image' => false,
'wt_audio' => false,
'wt_video' => false,
'wt_gallery' => false,
'wt_html' => false,
'wp_header_code' => esc_html( $wp_header_code ),
'wp_footer_code' => esc_html( $wp_footer_code ),
'meta_referrer_policy' => 'none',
);
$this->plugin_pages_option_fields = array(
'disable_page_system',
'disable_page_export',
'disable_page_ms',
);
$this->optimization_option_fields = array(
array(
'wp_version_tag',
esc_html__( 'Remove the WordPress Version Meta-Tag from wp head.', 'wpat' ),
esc_html__( 'Show the version number of your currently installed WordPress in the source code.', 'wpat' ),
),
array(
'wp_emoji',
esc_html__( 'Remove the WordPress Emoticons from your source code.', 'wpat' ),
esc_html__( 'Display a textual portrayals like ";-)" as a emoticon icon.', 'wpat' ),
),
array(
'wp_feed_links',
esc_html__( 'Disable the RSS feed functionality and remove the WordPress page and comments RSS feed links from wp head.', 'wpat' ),
esc_html__( 'RSS (Really Simple Syndication) is a type of web feed which allows users to access updates to online content in a standardized, computer-readable format.', 'wpat' ),
),
array(
'wp_rsd_link',
esc_html__( 'Remove the RSD link from wp head.', 'wpat' ),
esc_html__( 'Really Simple Discovery (RSD) is an XML format and a publishing convention for making services exposed by a blog, or other web software, discoverable by client software.', 'wpat' ),
),
array(
'wp_wlwmanifest',
esc_html__( 'Remove the Wlwmanifest link from wp head.', 'wpat' ),
esc_html__( 'Needed to enable tagging support for Windows Live Writer.', 'wpat' ),
),
array(
'wp_shortlink',
esc_html__( 'Remove the shortlink link from wp head.', 'wpat' ),
esc_html__( 'Shortlink is a shorten version of a web page’s URL.', 'wpat' ),
),
array(
'wp_rest_api',
esc_html__( 'Disable the REST API and remove the wp json link from wp head.', 'wpat' ),
esc_html__( 'The API makes it super easy to retrieve data using GET requests, which is useful for those building apps with WordPress.', 'wpat' ),
),
array(
'wp_oembed',
esc_html__( 'Disable wp embed and remove the oEmbed links from wp head.', 'wpat' ),
esc_html__( 'oEmbed feature which allows others to embed your WordPress posts into their own site by adding the post URL.', 'wpat' ),
),
array(
'wp_xml_rpc',
esc_html__( 'Disable remote access.', 'wpat' ),
esc_html__( 'XML-RPC is a remote procedure call which uses XML to encode its calls and HTTP as a transport mechanism. If you want to access and publish to your blog remotely, then you need XML-RPC enabled. XML-RPC protocol is used by WordPress as API for Pingbacks and third-party applications, such as mobile apps, inter-blog communication and popular plugins like JetPack.', 'wpat' ),
),
array(
'wp_heartbeat',
esc_html__( 'Stop the heartbeat updates.', 'wpat' ),
esc_html__( 'The Heartbeat API is a simple server polling API built in to WordPress, allowing near-real-time frontend updates. The heartbeat API allows for regular communication between the users browser and the server. One of the original motivations was to allow for locking posts and warning users when more than one user is attempting to edit a post, or warning the user when their log-in has expired.', 'wpat' ),
),
array(
'wp_rel_link',
esc_html__( 'Remove the post rel index / start / parent / prev / next links from wp head.', 'wpat' ),
esc_html__( 'This feature display the URL of the index, start, parent, previous and next post in the source code.', 'wpat' ),
),
array(
'wp_self_pingback',
esc_html__( 'Disable WordPress self pingbacks / trackbacks.', 'wpat' ),
esc_html__( 'This will allow you to disable self-pingbacks (messages and comments), which are linking back to your own blog.', 'wpat' ),
),
);
$this->meta_box_option_fields = array(
array(
'mb_custom_fields',
esc_html__( 'Remove the Custom Fields Box for posts and pages.', 'wpat' ),
'',
),
array(
'mb_commentstatus',
esc_html__( 'Remove the Discussion Box for posts and pages.', 'wpat' ),
'',
),
array(
'mb_comments',
esc_html__( 'Remove the Comments Box for posts and pages.', 'wpat' ),
'',
),
array(
'mb_author',
esc_html__( 'Remove the Author Box for posts and pages.', 'wpat' ),
'',
),
array(
'mb_category',
esc_html__( 'Remove the Category Box for posts.', 'wpat' ),
'',
),
array(
'mb_format',
esc_html__( 'Remove the Post Format Box for posts.', 'wpat' ),
'',
),
array(
'mb_pageparent',
esc_html__( 'Remove the Page Attributes Box for pages.', 'wpat' ),
'',
),
array(
'mb_postexcerpt',
esc_html__( 'Remove the Excerpt Box for posts.', 'wpat' ),
'',
),
array(
'mb_postimage',
esc_html__( 'Remove the Featured Image Box for posts and pages.', 'wpat' ),
'',
),
array(
'mb_revisions',
esc_html__( 'Remove the Revisions Box for posts and pages.', 'wpat' ),
'',
),
array(
'mb_slug',
esc_html__( 'Remove the Slug Box for posts and pages.', 'wpat' ),
esc_html__( 'Caution: Disabling the slug box does not allow you to customize the post or page URL.', 'wpat' ),
),
array(
'mb_tags',
esc_html__( 'Remove the Tags Box for posts.', 'wpat' ),
'',
),
array(
'mb_trackbacks',
esc_html__( 'Remove the Send Trackbacks Box for posts and pages.', 'wpat' ),
'',
),
);
$this->db_widget_option_fields = array(
'dbw_quick_press',
'dbw_right_now',
'dbw_activity',
'dbw_primary',
'dbw_welcome',
'dbw_wpat_user_log',
'dbw_wpat_sys_info',
'dbw_wpat_count_post',
'dbw_wpat_count_page',
'dbw_wpat_count_comment',
'dbw_wpat_recent_post',
'dbw_wpat_recent_page',
'dbw_wpat_recent_comment',
'dbw_wpat_memory',
);
$this->widget_option_fields = array(
'wt_pages',
'wt_calendar',
'wt_archives',
'wt_meta',
'wt_search',
'wt_text',
'wt_categories',
'wt_recent_posts',
'wt_recent_comments',
'wt_rss',
'wt_tag_cloud',
'wt_nav',
'wt_image',
'wt_audio',
'wt_video',
'wt_gallery',
'wt_html',
);
$this->frontend_option_fields = array(
array(
'wp_header_code',
esc_html__( 'Add custom code to the frontend header.', 'wpat' ),
esc_html__( 'Will be inserted into the wp_head hook.', 'wpat' ),
),
array(
'wp_footer_code',
esc_html__( 'Add custom code to the frontend footer.', 'wpat' ),
esc_html__( 'Will be inserted into the wp_footer hook.', 'wpat' ),
),
array(
'meta_referrer_policy',
esc_html__( 'Add the meta referrer tag and select your value.', 'wpat' ),
esc_html__( 'If you use SSL for your website, analytics tools like Google Analytics can not see the referrer by default. For example, if you select "Origin", your referrer will be visible again.', 'wpat' ),
),
);
$this->option_heads = array(
'head_theme' => esc_html__( 'Theme Options', 'wpat' ),
'head_toolbar' => esc_html__( 'Toolbar', 'wpat' ),
'head_color' => esc_html__( 'Colors', 'wpat' ),
'head_login' => esc_html__( 'Login Page', 'wpat' ),
'head_footer' => esc_html__( 'Footer', 'wpat' ),
'head_css' => esc_html__( 'Custom CSS', 'wpat' ),
'head_media' => esc_html__( 'Media', 'wpat' ),
'head_pages' => esc_html__( 'Pages', 'wpat' ),
'head_ms' => esc_html__( 'Multisite', 'wpat' ),
'head_optimize' => esc_html__( 'Optimization & Security', 'wpat' ),
'head_metabox' => esc_html__( 'Meta Boxes', 'wpat' ),
'head_dashboard' => esc_html__( 'Dashboard Widgets', 'wpat' ),
'head_widget' => esc_html__( 'Widgets', 'wpat' ),
'head_frontend' => esc_html__( 'Frontend', 'wpat' ),
);
// Load textdomain for i18n
load_plugin_textdomain( 'wpat', null, basename(dirname( __FILE__ )) . '/languages/' );
}
/*****************************************************************/
/* ADD A WPAT PLUGIN OPTIONS PAGE */
/*****************************************************************/
public function wpat_add_page() {
// $page_title, $menu_title, $capability, $menu_slug, $callback_function
add_submenu_page( 'tools.php', esc_html__( 'WPAT', 'wpat' ), esc_html__( 'WPAT Options', 'wpat' ), 'manage_options', 'wpat', array( $this, 'wpat_display_page' ) );
}
/*****************************************************************/
/* REGISTER THE WPAT PLUGIN SETTINGS/OPTIONS */
/*****************************************************************/
public function wpat_register_settings() {
// option group, option name, sanitize
register_setting( '__FILE__', 'wpat_settings_options', array( $this, 'wpat_validate_options' ) );
}
/*****************************************************************/
/* DISPLAY THE WPAT PLUGIN OPTIONS PAGE */
/*****************************************************************/
public function wpat_display_page() { ?>
<div class="wrap wpat">
<h1><?php echo esc_html__( 'WPAT - Options', 'wpat' ); ?><?php if ( is_multisite() ) { ?><span style="color:#8b959e"> <?php echo ' | ' . esc_html__( 'Current Blog ID', 'wpat' ) . ': '. get_current_blog_id(); ?></span><?php } ?></h1>
<p><?php esc_html_e( 'Speed up and modify your WordPress backend like a charm. This plugin is the central place to take WordPress design to the next level.', 'wpat' ); ?></p>
<div class="wpat-page-menu">
<ul>
<li><a href="#index_theme"><?php echo $this->option_heads['head_theme']; ?></a></li>
<li><a href="#index_toolbar"><?php echo $this->option_heads['head_toolbar']; ?></a></li>
<li><a href="#index_color"><?php echo $this->option_heads['head_color']; ?></a></li>
<li><a href="#index_login"><?php echo $this->option_heads['head_login']; ?></a></li>
<li><a href="#index_footer"><?php echo $this->option_heads['head_footer']; ?></a></li>
<li><a href="#index_css"><?php echo $this->option_heads['head_css']; ?></a></li>
<li><a href="#index_media"><?php echo $this->option_heads['head_media']; ?></a></li>
<li><a href="#index_page"><?php echo $this->option_heads['head_pages']; ?></a></li>
<li><a href="#index_ms"><?php echo $this->option_heads['head_ms']; ?></a></li>
<li><a href="#index_optimize"><?php echo $this->option_heads['head_optimize']; ?></a></li>
<li><a href="#index_metabox"><?php echo $this->option_heads['head_metabox']; ?></a></li>
<li><a href="#index_dashboard"><?php echo $this->option_heads['head_dashboard']; ?></a></li>
<li><a href="#index_widget"><?php echo $this->option_heads['head_widget']; ?></a></li>
<li><a href="#index_frontend"><?php echo $this->option_heads['head_frontend']; ?></a></li>
</ul>
</div>
<form action="options.php" method="post" enctype="multipart/form-data">
<?php if( is_multisite() ) {
$main_blog_id = 1;
$options = get_blog_option( $main_blog_id, 'wpat_settings_options', array() );
} else {
$options = get_option( 'wpat_settings_options' );
}
/*
// print options check
echo '<pre>';
print_r($this->options);
echo '</pre>';
*/
// error message output
settings_errors('wpat_settings_options');
// fields output
settings_fields('__FILE__');
do_settings_sections('__FILE__');
echo '<table class="form-table"><tbody><tr><th scope="row"></th><td><p class="description">';
// manage save button visibility
if( $options['disable_theme_options'] == false || $options['disable_theme_options'] == true && get_current_blog_id() == 1 ) {
submit_button( esc_html__( 'Save Changes', 'wpat' ), 'button button-primary', 'save', false );
} else {
echo '<button class="button" disabled value="">' . esc_html__( 'You have no permissions to change this options!', 'wpat' ) . '</button>';
}
// manage restore button visibility
if( $options['disable_theme_options'] == false || $options['disable_theme_options'] == true && get_current_blog_id() == 1 ) {
submit_button( esc_html__( 'Restore all', 'wpat' ), 'button restore', 'reset', false );
}
echo '</p></td></tr></tbody></table>'; ?>
</form>
</div>
<?php }
/*****************************************************************/
/* REGISTER THE WPAT PLUGIN ADMIN PAGE OPTIONS */
/*****************************************************************/
public function wpat_register_page_options() {
// Add Section for option fields
add_settings_section( 'admin_theme_section', '<span id="index_theme" class="wpat-page-index"></span>' . $this->option_heads['head_theme'], array( $this, 'wpat_display_section' ), '__FILE__' ); // Theme Options
add_settings_field( 'admin_theme_spacing', $this->option_fields['spacing'], array( $this, 'admin_theme_spacing_settings' ), '__FILE__', 'admin_theme_section' ); // Add Spacing Option
add_settings_field( 'admin_theme_user_box', $this->option_fields['user_box'], array( $this, 'admin_theme_user_box_settings' ), '__FILE__', 'admin_theme_section' ); // Add User Box Option
add_settings_field( 'admin_theme_company_box', $this->option_fields['company_box'], array( $this, 'admin_theme_company_box_settings' ), '__FILE__', 'admin_theme_section' ); // Add Company Box Option
add_settings_field( 'admin_theme_thumbnail', $this->option_fields['thumbnail'], array( $this, 'admin_theme_thumbnail_settings' ), '__FILE__', 'admin_theme_section' ); // Add Thumbnail Option
add_settings_field( 'admin_theme_post_page_id', $this->option_fields['post_page_id'], array( $this, 'admin_theme_post_page_id_settings' ), '__FILE__', 'admin_theme_section' ); // Add Post/Page ID Option
add_settings_field( 'admin_theme_hide_help', $this->option_fields['hide_help'], array( $this, 'admin_theme_hide_help_settings' ), '__FILE__', 'admin_theme_section' ); // Add Hide the Contextual Help Option
add_settings_field( 'admin_theme_hide_screen_option', $this->option_fields['hide_screen_option'], array( $this, 'admin_theme_hide_screen_option_settings' ), '__FILE__', 'admin_theme_section' ); // Add Hide the Screen Options
add_settings_field( 'admin_theme_left_menu_width', $this->option_fields['left_menu_width'], array( $this, 'admin_theme_left_menu_width_settings' ), '__FILE__', 'admin_theme_section' ); // Add Left Menu Width Option
add_settings_field( 'admin_theme_left_menu_expand', $this->option_fields['left_menu_expand'], array( $this, 'admin_theme_left_menu_expand_settings' ), '__FILE__', 'admin_theme_section' ); // Add Left expandable Menu Option
add_settings_field( 'admin_theme_google_webfont', $this->option_fields['google_webfont'], array( $this, 'admin_theme_google_webfont_settings' ), '__FILE__', 'admin_theme_section' ); // Add Google Webfont Option
// Add Section for Toolbar
add_settings_section( 'admin_theme_section_toolbar', '<span id="index_toolbar" class="wpat-page-index"></span>' . $this->option_heads['head_toolbar'], array( $this, 'wpat_display_section_toolbar' ), '__FILE__' );
add_settings_field( 'admin_theme_toolbar', $this->option_fields['toolbar'], array( $this, 'admin_theme_toolbar_settings' ), '__FILE__', 'admin_theme_section_toolbar' ); // Add Hide Toolbar Option
add_settings_field( 'admin_theme_hide_adminbar_comments', $this->option_fields['hide_adminbar_comments'], array( $this, 'admin_theme_hide_adminbar_comments_settings' ), '__FILE__', 'admin_theme_section_toolbar' ); // Add Hide Toolbar Comments Menu
add_settings_field( 'admin_theme_hide_adminbar_new', $this->option_fields['hide_adminbar_new'], array( $this, 'admin_theme_hide_adminbar_new_settings' ), '__FILE__', 'admin_theme_section_toolbar' ); // Add Hide Toolbar New Content Menu
add_settings_field( 'admin_theme_hide_adminbar_customize', $this->option_fields['hide_adminbar_customize'], array( $this, 'admin_theme_hide_adminbar_customize_settings' ), '__FILE__', 'admin_theme_section_toolbar' ); // Add Hide Toolbar Customize Link
add_settings_field( 'admin_theme_hide_adminbar_search', $this->option_fields['hide_adminbar_search'], array( $this, 'admin_theme_hide_adminbar_search_settings' ), '__FILE__', 'admin_theme_section_toolbar' ); // Add Hide Toolbar Search
add_settings_field( 'admin_theme_toolbar_wp_icon', $this->option_fields['toolbar_wp_icon'], array( $this, 'admin_theme_toolbar_wp_icon_settings' ), '__FILE__', 'admin_theme_section_toolbar' ); // Add Hide Toolbar WP Icon
add_settings_field( 'admin_theme_toolbar_icon', $this->option_fields['toolbar_icon'], array( $this, 'admin_theme_toolbar_icon_settings' ), '__FILE__', 'admin_theme_section_toolbar' ); // Add custom Toolbar Icon
// Add Section for Colors Option
add_settings_section( 'admin_theme_section_color', '<span id="index_color" class="wpat-page-index"></span>' . $this->option_heads['head_color'], array( $this, 'wpat_display_section_colors' ), '__FILE__' );
add_settings_field( 'admin_theme_color', $this->option_fields['theme_color'], array( $this, 'admin_theme_color_settings' ), '__FILE__', 'admin_theme_section_color' ); // Add custom Theme Color Field
add_settings_field( 'admin_theme_background', esc_html__( 'Background Gradient Color', 'wpat' ), array( $this, 'admin_theme_background_settings' ), '__FILE__', 'admin_theme_section_color' ); // Add custom Theme Background Gradient Color Field
// Add Section for Login Option
add_settings_section( 'admin_theme_section_login', '<span id="index_login" class="wpat-page-index"></span>' . $this->option_heads['head_login'], array( $this, 'wpat_display_section_login' ), '__FILE__' );
add_settings_field( 'admin_theme_login_disable', $this->option_fields['login_disable'], array( $this, 'admin_theme_login_disable_settings' ), '__FILE__', 'admin_theme_section_login' ); // Add Login Disable Option
add_settings_field( 'admin_theme_login_title', $this->option_fields['login_title'], array( $this, 'admin_theme_login_title_settings' ), '__FILE__', 'admin_theme_section_login' ); // Add Title Field
add_settings_field( 'admin_theme_logo_upload', $this->option_fields['logo_upload'], array( $this, 'admin_theme_logo_upload_settings' ), '__FILE__', 'admin_theme_section_login' ); // Add Logo Option
add_settings_field( 'admin_theme_login_bg', $this->option_fields['login_bg'], array( $this, 'admin_theme_login_bg_settings' ), '__FILE__', 'admin_theme_section_login' ); // Add Login BG Image Option
// Add Section for Footer Information Option
add_settings_section( 'admin_theme_section_footer', '<span id="index_footer" class="wpat-page-index"></span>' . $this->option_heads['head_footer'], array( $this, 'wpat_display_section_footer' ), '__FILE__' );
add_settings_field( 'admin_theme_credits', $this->option_fields['credits'], array( $this, 'admin_theme_credits_settings' ), '__FILE__', 'admin_theme_section_footer' ); // Add Credits Option
add_settings_field( 'admin_theme_memory_usage', $this->option_fields['memory_usage'], array( $this, 'admin_theme_memory_usage_settings' ), '__FILE__', 'admin_theme_section_footer' ); // Add Memory Usage Option
add_settings_field( 'admin_theme_memory_limit', $this->option_fields['memory_limit'], array( $this, 'admin_theme_memory_limit_settings' ), '__FILE__', 'admin_theme_section_footer' ); // Add WP Memory Limit Option
add_settings_field( 'admin_theme_memory_available', $this->option_fields['memory_available'], array( $this, 'admin_theme_memory_available_settings' ), '__FILE__', 'admin_theme_section_footer' ); // Add Memory Available Option
add_settings_field( 'admin_theme_php_version', $this->option_fields['php_version'], array( $this, 'admin_theme_php_version_settings' ), '__FILE__', 'admin_theme_section_footer' ); // Add PHP Version Option
add_settings_field( 'admin_theme_ip_address', $this->option_fields['ip_address'], array( $this, 'admin_theme_ip_address_settings' ), '__FILE__', 'admin_theme_section_footer' ); // Add IP Address Option
add_settings_field( 'admin_theme_wp_version', $this->option_fields['wp_version'], array( $this, 'admin_theme_wp_version_settings' ), '__FILE__', 'admin_theme_section_footer' ); // Add WP Version Option
// Add Section for Custom CSS
add_settings_section( 'admin_theme_section_css', '<span id="index_css" class="wpat-page-index"></span>' . $this->option_heads['head_css'], array( $this, 'wpat_display_section_css' ), '__FILE__' );
add_settings_field( 'admin_theme_css_admin', $this->option_fields['css_admin'], array( $this, 'admin_theme_css_admin_settings' ), '__FILE__', 'admin_theme_section_css' ); // Add Custom CSS for WPAT
add_settings_field( 'admin_theme_css_login', $this->option_fields['css_login'], array( $this, 'admin_theme_css_login_settings' ), '__FILE__', 'admin_theme_section_css' ); // Add Custom CSS for WP Login
// Add Section for Media Support
add_settings_section( 'admin_theme_section_media', '<span id="index_media" class="wpat-page-index"></span>' . $this->option_heads['head_media'], array( $this, 'wpat_display_section_media' ), '__FILE__' );
add_settings_field( 'admin_theme_wp_svg', $this->option_fields['wp_svg'], array( $this, 'admin_theme_wp_svg_settings' ), '__FILE__', 'admin_theme_section_media' ); // Add SVG Support
add_settings_field( 'admin_theme_wp_ico', $this->option_fields['wp_ico'], array( $this, 'admin_theme_wp_ico_settings' ), '__FILE__', 'admin_theme_section_media' ); // Add ICO Support
// Add Section for Plugin Pages
add_settings_section( 'admin_theme_section_plugin_pages', '<span id="index_page" class="wpat-page-index"></span>' . $this->option_heads['head_pages'], array( $this, 'wpat_display_section_plugin_pages' ), '__FILE__' );
add_settings_field( 'admin_theme_disable_page_system', $this->option_fields['disable_page_system'], array( $this, 'admin_theme_disable_plugin_pages_settings' ), '__FILE__', 'admin_theme_section_plugin_pages' ); // Add Disable Plugin System Page
add_settings_field( 'admin_theme_disable_page_export', $this->option_fields['disable_page_export'], array( $this, 'admin_theme_disable_plugin_pages_settings' ), '__FILE__', 'admin_theme_section_plugin_pages' ); // Add Disable Plugin Import/Export Page
add_settings_field( 'admin_theme_disable_page_ms', $this->option_fields['disable_page_ms'], array( $this, 'admin_theme_disable_plugin_pages_settings' ), '__FILE__', 'admin_theme_section_plugin_pages' ); // Add Disable Plugin Multisite Sync Page
// Add Section for Multisite Support
add_settings_section( 'admin_theme_section_multisite', '<span id="index_ms" class="wpat-page-index"></span>' . $this->option_heads['head_ms'], array( $this, 'wpat_display_section_multisite' ), '__FILE__' );
add_settings_field( 'admin_theme_disable_theme_options', $this->option_fields['disable_theme_options'], array( $this, 'admin_theme_disable_theme_options_settings' ), '__FILE__', 'admin_theme_section_multisite' ); // Add Disable Theme Options
// Add Section for Optimization
add_settings_section( 'admin_theme_section_optimization', '<span id="index_optimize" class="wpat-page-index"></span>' . $this->option_heads['head_optimize'], array( $this, 'wpat_display_section_optimization' ), '__FILE__' );
add_settings_field( 'admin_theme_wp_version_tag', $this->option_fields['wp_version_tag'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP Version Tag
add_settings_field( 'admin_theme_wp_emoji', $this->option_fields['wp_emoji'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP Emoticons
add_settings_field( 'admin_theme_wp_feed_links', $this->option_fields['wp_feed_links'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP Feed Links
add_settings_field( 'admin_theme_wp_rsd_link', $this->option_fields['wp_rsd_link'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP RSD Link
add_settings_field( 'admin_theme_wp_wlwmanifest', $this->option_fields['wp_wlwmanifest'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP Wlwmanifest
add_settings_field( 'admin_theme_wp_shortlink', $this->option_fields['wp_shortlink'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP Shortlink
add_settings_field( 'admin_theme_wp_rest_api', $this->option_fields['wp_rest_api'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP Rest API
add_settings_field( 'admin_theme_wp_oembed', $this->option_fields['wp_oembed'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP oEmbed
add_settings_field( 'admin_theme_wp_xml_rpc', $this->option_fields['wp_xml_rpc'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP XML RPC
add_settings_field( 'admin_theme_wp_heartbeat', $this->option_fields['wp_heartbeat'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP Heartbeat
add_settings_field( 'admin_theme_wp_rel_link', $this->option_fields['wp_rel_link'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Remove WP Rel Link
add_settings_field( 'admin_theme_wp_self_pingback', $this->option_fields['wp_self_pingback'], array( $this, 'admin_theme_wp_optimization_settings' ), '__FILE__', 'admin_theme_section_optimization' ); // Add Disable Self Pingbacks Link
// Add Section for Meta Boxes
add_settings_section( 'admin_theme_section_meta_boxes', '<span id="index_metabox" class="wpat-page-index"></span>' . $this->option_heads['head_metabox'], array( $this, 'wpat_display_section_meta_boxes' ), '__FILE__' );
add_settings_field( 'admin_theme_mb_custom_fields', $this->option_fields['mb_custom_fields'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Custom Field Meta Box
add_settings_field( 'admin_theme_mb_commentstatus', $this->option_fields['mb_commentstatus'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Comments Status Meta Box
add_settings_field( 'admin_theme_mb_comments', $this->option_fields['mb_comments'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Comments Meta Box
add_settings_field( 'admin_theme_mb_author', $this->option_fields['mb_author'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Author Meta Box
add_settings_field( 'admin_theme_mb_category', $this->option_fields['mb_category'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Category Meta Box
add_settings_field( 'admin_theme_mb_format', $this->option_fields['mb_format'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Post Format Meta Box
add_settings_field( 'admin_theme_mb_pageparent', $this->option_fields['mb_pageparent'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Page Parent Meta Box
add_settings_field( 'admin_theme_mb_postexcerpt', $this->option_fields['mb_postexcerpt'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Post Excerpt Meta Box
add_settings_field( 'admin_theme_mb_postimage', $this->option_fields['mb_postimage'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Post Image Meta Box
add_settings_field( 'admin_theme_mb_revisions', $this->option_fields['mb_revisions'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Revisions Meta Box
add_settings_field( 'admin_theme_mb_slug', $this->option_fields['mb_slug'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Slug Meta Box
add_settings_field( 'admin_theme_mb_tags', $this->option_fields['mb_tags'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Tags Meta Box
add_settings_field( 'admin_theme_mb_trackbacks', $this->option_fields['mb_trackbacks'], array( $this, 'admin_theme_meta_box_settings' ), '__FILE__', 'admin_theme_section_meta_boxes' ); // Add Remove Trackbacks Meta Box
// Add Section for Dashboard Widgets
add_settings_section( 'admin_theme_section_db_widgets', '<span id="index_dashboard" class="wpat-page-index"></span>' . $this->option_heads['head_dashboard'], array( $this, 'wpat_display_section_db_widgets' ), '__FILE__' );
add_settings_field( 'admin_theme_dbw_quick_press', $this->option_fields['dbw_quick_press'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove Quick Draft Widget
add_settings_field( 'admin_theme_dbw_right_now', $this->option_fields['dbw_right_now'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove At the Glance Widget
add_settings_field( 'admin_theme_dbw_activity', $this->option_fields['dbw_activity'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove Activity Widget
add_settings_field( 'admin_theme_dbw_primary', $this->option_fields['dbw_primary'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WP Events & News Widget
add_settings_field( 'admin_theme_dbw_welcome', $this->option_fields['dbw_welcome'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove Welcome Widget
add_settings_field( 'admin_theme_dbw_wpat_user_log', $this->option_fields['dbw_wpat_user_log'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WPAT User Activities Widget
add_settings_field( 'admin_theme_dbw_wpat_sys_info', $this->option_fields['dbw_wpat_sys_info'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WPAT System info Widget
add_settings_field( 'admin_theme_dbw_wpat_count_post', $this->option_fields['dbw_wpat_count_post'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WPAT Posts Count Widget
add_settings_field( 'admin_theme_dbw_wpat_count_page', $this->option_fields['dbw_wpat_count_page'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WPAT Pages Count Widget
add_settings_field( 'admin_theme_dbw_wpat_count_comment', $this->option_fields['dbw_wpat_count_comment'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WPAT Comments Count Widget
add_settings_field( 'admin_theme_dbw_wpat_recent_post', $this->option_fields['dbw_wpat_recent_post'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WPAT Recent Posts Widget
add_settings_field( 'admin_theme_dbw_wpat_recent_page', $this->option_fields['dbw_wpat_recent_page'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WPAT Recent Pages Widget
add_settings_field( 'admin_theme_dbw_wpat_recent_comment', $this->option_fields['dbw_wpat_recent_comment'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WPAT Recent Comments Widget
add_settings_field( 'admin_theme_dbw_wpat_memory', $this->option_fields['dbw_wpat_memory'], array( $this, 'admin_theme_db_widgets_settings' ), '__FILE__', 'admin_theme_section_db_widgets' ); // Add Remove WPAT Memory Usage Widget
// Add Section for Widgets
add_settings_section( 'admin_theme_section_widgets', '<span id="index_widget" class="wpat-page-index"></span>' . $this->option_heads['head_widget'], array( $this, 'wpat_display_section_widgets' ), '__FILE__' );
add_settings_field( 'admin_theme_wt_pages', $this->option_fields['wt_pages'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Pages Widget
add_settings_field( 'admin_theme_wt_archives', $this->option_fields['wt_archives'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Calendar Widget
add_settings_field( 'admin_theme_wt_calendar', $this->option_fields['wt_calendar'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Archives Widget
add_settings_field( 'admin_theme_wt_meta', $this->option_fields['wt_meta'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Meta Widget
add_settings_field( 'admin_theme_wt_search', $this->option_fields['wt_search'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Search Widget
add_settings_field( 'admin_theme_wt_text', $this->option_fields['wt_text'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Text Widget
add_settings_field( 'admin_theme_wt_categories', $this->option_fields['wt_categories'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Categories Widget
add_settings_field( 'admin_theme_wt_recent_posts', $this->option_fields['wt_recent_posts'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Recent Posts Widget
add_settings_field( 'admin_theme_wt_recent_comments', $this->option_fields['wt_recent_comments'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Recent Comments Widget
add_settings_field( 'admin_theme_wt_rss', $this->option_fields['wt_rss'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove RSS Widget
add_settings_field( 'admin_theme_wt_tag_cloud', $this->option_fields['wt_tag_cloud'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Tag Cloud Widget
add_settings_field( 'admin_theme_wt_nav', $this->option_fields['wt_nav'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Navigation Menu Widget
add_settings_field( 'admin_theme_wt_image', $this->option_fields['wt_image'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Image Widget
add_settings_field( 'admin_theme_wt_audio', $this->option_fields['wt_audio'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Audio Widget
add_settings_field( 'admin_theme_wt_video', $this->option_fields['wt_video'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Video Widget
add_settings_field( 'admin_theme_wt_gallery', $this->option_fields['wt_gallery'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Gallery Widget
add_settings_field( 'admin_theme_wt_html', $this->option_fields['wt_html'], array( $this, 'admin_theme_widgets_settings' ), '__FILE__', 'admin_theme_section_widgets' ); // Add Remove Custom HTML Widget
// Add Section for Frontend
add_settings_section( 'admin_theme_section_frontend', '<span id="index_frontend" class="wpat-page-index"></span>' . $this->option_heads['head_frontend'], array( $this, 'wpat_display_section_frontend' ), '__FILE__' );
add_settings_field( 'admin_theme_wp_header_code', $this->option_fields['wp_header_code'], array( $this, 'admin_theme_frontend_settings' ), '__FILE__', 'admin_theme_section_frontend' ); // Add Header Code
add_settings_field( 'admin_theme_wp_footer_code', $this->option_fields['wp_footer_code'], array( $this, 'admin_theme_frontend_settings' ), '__FILE__', 'admin_theme_section_frontend' ); // Add Footer Code
add_settings_field( 'admin_theme_meta_referrer_policy', $this->option_fields['meta_referrer_policy'], array( $this, 'admin_theme_frontend_settings' ), '__FILE__', 'admin_theme_section_frontend' ); // Add Meta Policy
}
/*****************************************************************/
/* ADD JS FOR WPAT PLUGIN OPTIONS PAGE */
/*****************************************************************/
function wpat_load_plugin_page_specific_scripts( $hook ) {
// method to get the page hook
// wp_die($hook);
// Load only on admin_toplevel_page?page=mypluginname
if( $hook != 'tools_page_wpat' ) {
return;
}
// Add color picker css
wp_enqueue_style( 'wp-color-picker' );
// Add media upload js
wp_enqueue_media();
// Add plugin js
wp_enqueue_script( 'wp_admin_script_plugin', wpat_path( 'js/jquery.plugin.js' ), array( 'jquery', 'wp-color-picker' ), null, true );
}
/*****************************************************************/
/* ADD GLOBAL JS / CSS */
/*****************************************************************/
public function wpat_enqueue_admin_js() {
// Add admin style css
wp_enqueue_style( 'wp_admin_style_custom', wpat_path( 'style.css' ), array(), filemtime( wpat_dir( 'style.css' ) ), 'all' );
// Add admin rtl style css
if( is_rtl() ) {
wp_enqueue_style( 'wp_admin_style_rtl', wpat_path( 'css/rtl-style.css' ), array(), filemtime( wpat_dir( 'css/rtl-style.css' ) ), 'all' );
}
// Add admin colors css
wp_enqueue_style( 'wp_admin_style_color', wpat_path( 'css/colors.css' ), array(), filemtime( wpat_dir( 'css/colors.css' ) ), 'all' );
// Add admin js
wp_enqueue_script( 'wp_admin_script_custom', wpat_path( 'js/jquery.custom.js' ), array( 'jquery' ), null, true );
// Avoiding flickering to reorder the first menu item (User Box) for left toolbar
$custom_css = "#adminmenu li:first-child { display:none }";
wp_add_inline_style( 'wp_admin_style_custom', $custom_css );
}
/*****************************************************************/
/* GENERATE WPAT PLUGIN CUSTOM CSS / JS FILE */
/*****************************************************************/
public function wpat_generate_custom_css_js() {
global $wp_filesystem;
WP_Filesystem(); // Initial WP file system
ob_start();
require_once( wpat_dir('css/colors.php') );
$css = ob_get_clean();
$wp_filesystem->put_contents( wpat_dir('css/colors.css'), $css, 0644 );
ob_start();
require_once( wpat_dir('css/login.php') );
$css = ob_get_clean();
$wp_filesystem->put_contents( wpat_dir('css/login.css'), $css, 0644 );
ob_start();
require_once( wpat_dir('css/frontend.php') );
$css = ob_get_clean();
$wp_filesystem->put_contents( wpat_dir('css/frontend.css'), $css, 0644 );
}
/*****************************************************************/
/* VALIDATE ALL WPAT PLUGIN OPTION FIELDS */
/*****************************************************************/
public function wpat_validate_options( $fields ) {
$valid_fields = array();
// validate the following fields
$get_all_fields = $this->option_fields;
foreach( $get_all_fields as $key => $value ) {
$field_type = trim( $fields[ $key ] );
// extra check for color fields
if( $key == 'theme_color' || $key == 'theme_background' || $key == 'theme_background_end' ) {
// check color is empty (or cleared by user)
if( $field_type == false ) {
// empty value
$valid_fields[ $key ] = '';
// check if is a valid hex color
} elseif( false == $this->wpat_check_color( $field_type ) ) {
if( $key == 'theme_color' ) {
$valid_fields[ $key ] = $this->options['theme_color'];
} elseif( $key == 'theme_background' ) {
$valid_fields[ $key ] = $this->options['theme_background'];
} else {
$valid_fields[ $key ] = $this->options['theme_background_end'];
}
// Invalid color notice
if( ! empty( $field_type ) ) {
add_settings_error('wpat_settings_options', 'save_updated', esc_html__( 'Invalid Color for', 'wpat' ) . ' ' . $value . '! ' . esc_html__( 'Old values has been restored,', 'wpat' ), 'error' );
}
// get validated new hex code
} else {
$valid_fields[ $key ] = $field_type;
}
} else {
// validate all other fields
if( $key == 'wp_header_code' || $key == 'wp_footer_code' ) {
$valid_fields[ $key ] = $field_type;
} else {
$valid_fields[ $key ] = strip_tags( stripslashes( $field_type ) );
}
}
// get specific update notice
if( $valid_fields[ $key ] == $this->options[ $key ] ) {
// specific field has been not updated (new value == old value)
//add_settings_error('wpat_settings_options', 'save_updated', esc_html__( 'nichts geändert', 'wpat' ), 'error' );
} else {
// specific field has been updated
if( $field_type == $valid_fields[ $key ] ) {
add_settings_error('wpat_settings_options', 'save_updated', $value . ' ' . esc_html__( 'has been updated.', 'wpat' ), 'updated' );
}
}
}
// Reset all fields to default theme options
if( isset( $_POST['reset'] ) ) {
add_settings_error('wpat_settings_options', 'reset_error', esc_html__( 'All fields has been restored.', 'wpat' ), 'updated' );
// Restore all options to pre defined values
return $this->pre_options;
}
add_settings_error('wpat_settings_options', 'save_updated', esc_html__('Settings saved.', 'wpat'), 'updated' );
// Validate all
return apply_filters( 'wpat_validate_options', $valid_fields, $fields);
}
/*****************************************************************/
/* VALIDATE HEX CODE */
/*****************************************************************/
// Function that will check if value is a valid HEX color.
public function wpat_check_color( $value ) {
if( preg_match( '/^#[a-f0-9]{6}$/i', $value ) ) { // if user insert a HEX color with #
return true;
}
return false;
}
/*****************************************************************/
/* PRE-DEFINE OF UNDEFINED INDEX */
/*****************************************************************/
public function wpat_check_for_undefined_options() {