This repository has been archived by the owner on Nov 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
rtp-admin-functions.php
1290 lines (1189 loc) · 63.6 KB
/
rtp-admin-functions.php
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
/**
* rtPanel Admin Functions
*
* @package rtPanel
*
* @since rtPanel 2.0
*/
global $rtp_general, $rtp_post_comments, $rtp_hooks, $rtp_version;
/**
* Data validation for rtPanel General Options
*
* @uses $rtp_general array
* @return Array
*
* @since rtPanel 2.0
*/
function rtp_general_validate($input) {
global $rtp_general;
require_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php' );
require_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php' );
@$file_object = new WP_Filesystem_Direct;
$default = rtp_theme_setup_values();
if (isset($_POST['rtp_submit'])) {
add_filter( 'intermediate_image_sizes_advanced', 'rtp_create_favicon' );
if ( 'image' == $input['logo_use'] && !empty($_FILES) && isset($_FILES['html-upload-logo']) && $_FILES['html-upload-logo']['size']) {
if (substr($_FILES['html-upload-logo']['type'], 0, 5) == 'image' ) {
$id = media_handle_upload( 'html-upload-logo', 0);
if (is_wp_error($id)) {
if (!empty($id->errors['upload_error']))
$logo_errors = $id->errors['upload_error'];
if (!empty($logo_errors)) {
foreach ($logo_errors as $logo_error) {
add_settings_error( 'html-upload-logo', 'html-upload-logo', $logo_error, 'error' );
}
}
} else {
$img_src = wp_get_attachment_image_src($id, 'full', true);
$input['logo_upload'] = $img_src[0];
$input['logo_id'] = $id;
$input['logo_width'] = $img_src[1];
$input['logo_height'] = $img_src[2];
add_settings_error( 'html-upload-logo', 'html-upload-logo', __( 'Logo & Favicon Settings Updated', 'rtPanel' ), 'updated' );
}
} else {
add_settings_error( 'html-upload-logo', 'html-upload-logo', __( 'Please upload a valid image file.', 'rtPanel' ), 'error' );
}
}
if ( 'image' == $input['favicon_use'] && !empty($_FILES) && isset($_FILES['html-upload-fav']) && $_FILES['html-upload-fav']['size']) {
// Upload File button was clicked
if (substr($_FILES['html-upload-fav']['type'], 0, 5) == 'image' ) {
$id = media_handle_upload( 'html-upload-fav', 0);
if (is_wp_error($id)) {
if (!empty($id->errors['upload_error']))
$fav_errors = $id->errors['upload_error'];
if (!empty($fav_errors)) {
foreach ($fav_errors as $fav_error) {
add_settings_error( 'html-upload-fav', 'html-upload-fav', $fav_error, 'error' );
}
}
} else {
$img_src = wp_get_attachment_image_src($id, 'favicon', true);
$input['favicon_upload'] = $img_src[0];
$input['favicon_id'] = $id;
add_settings_error( 'html-upload-fav', 'html-upload-fav', __( 'Logo & Favicon Settings Updated', 'rtPanel' ), 'updated' );
}
} else {
add_settings_error( 'html-upload-fav', 'html-upload-fav', __( 'Please upload a valid image file.', 'rtPanel' ), 'error' );
}
} elseif ( 'logo' == $input['favicon_use']) {
if (RTP_IMG_FOLDER_URL . '/rtp-logo.png' == $input['logo_upload']) {
$input['favicon_upload'] = RTP_IMG_FOLDER_URL . '/favicon.ico';
$input['favicon_id'] = 0;
} else {
$img_src = wp_get_attachment_image_src($input['logo_id'], 'favicon', true);
$input['favicon_upload'] = $img_src[0];
$input['favicon_id'] = $input['logo_id'];
}
}
remove_filter( 'intermediate_image_sizes_advanced', 'rtp_create_favicon' );
if ( 'image' != $input['logo_use']) {
$input['login_head'] = $rtp_general['login_head'];
}
if (!empty($input['search_code'])) {
if (!preg_match( '/customSearchControl.draw\(\'cse\'(.*)\)\;/i', $input['search_code']) && !preg_match( '/\<gcse:(searchresults-only|searchresults|search).*\>\<\/gcse:(searchresults-only|searchresults|search)\>/i', $input['search_code'])) {
$input['search_code'] = $rtp_general['search_code'];
add_settings_error( 'search_code', 'invalid_search_code', __( 'Google Search Code Error : While generating the code the layout option should either be "full-width" or "compact". The changes made have been reverted.', 'rtPanel' ));
} elseif ($input['search_code'] != $rtp_general['search_code']) {
add_settings_error( 'search_code', 'valid_search_code', __( 'Google Custom Search Integration has been updated.', 'rtPanel' ), 'updated' );
}
}
if (isset($_POST['rtsocial-activate']) && ( $_POST['rtsocial-activate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_rtsocial_activate'];
if (!wp_verify_nonce($nonce, RTP_SOCIAL . '-activate' )) {
add_settings_error( 'activate-plugin', 'failure_plugin_activation', __( 'You do not have sufficient permissions to activate this plugin.', 'rtPanel' ));
} else {
activate_plugin(RTP_SOCIAL);
add_settings_error( 'activate-plugin', 'plugin_activation', __( 'rtSocial has been Activated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['rtsocial-deactivate']) && ( $_POST['rtsocial-deactivate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_rtsocial_deactivate'];
if (!wp_verify_nonce($nonce, RTP_SOCIAL . '-deactivate' )) {
add_settings_error( 'deactivate-plugin', 'failure_plugin_deactivation', __( 'You do not have sufficient permissions to deactivate this plugin.', 'rtPanel' ));
} else {
deactivate_plugins(array(RTP_SOCIAL));
add_settings_error( 'deactivate-plugin', 'plugin_activation', __( 'rtSocial has been Deactivated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['rtsocial-delete']) && ( $_POST['rtsocial-delete'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_rtsocial_delete'];
if (!wp_verify_nonce($nonce, RTP_SOCIAL . '-delete' )) {
add_settings_error( 'delete-plugin', 'failure_plugin_deletion', __( 'You do not have sufficient permissions to delete this plugin.', 'rtPanel' ));
} else {
delete_plugins(array(RTP_SOCIAL));
add_settings_error( 'delete-plugin', 'plugin_deletion', __( 'rtSocial has been Deleted.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['rtp-hooks-editor-activate']) && ( $_POST['rtp-hooks-editor-activate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_rtp_hooks_editor_activate'];
if (!wp_verify_nonce($nonce, RTP_HOOKS_EDITOR . '-activate' )) {
add_settings_error( 'activate-plugin', 'failure_plugin_activation', __( 'You do not have sufficient permissions to activate this plugin.', 'rtPanel' ));
} else {
activate_plugin(RTP_HOOKS_EDITOR);
add_settings_error( 'activate-plugin', 'plugin_activation', __( 'rtPanel Hooks Editor Plugin has been Activated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['rtp-hooks-editor-deactivate']) && ( $_POST['rtp-hooks-editor-deactivate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_rtp_hooks_editor_deactivate'];
if (!wp_verify_nonce($nonce, RTP_HOOKS_EDITOR . '-deactivate' )) {
add_settings_error( 'deactivate-plugin', 'failure_plugin_deactivation', __( 'You do not have sufficient permissions to deactivate this plugin.', 'rtPanel' ));
} else {
deactivate_plugins(array(RTP_HOOKS_EDITOR));
add_settings_error( 'deactivate-plugin', 'plugin_activation', __( 'rtPanel Hooks Editor Plugin has been Deactivated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['rtp-hooks-editor-delete']) && ( $_POST['rtp-hooks-editor-delete'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_rtp_hooks_editor_delete'];
if (!wp_verify_nonce($nonce, RTP_HOOKS_EDITOR . '-delete' )) {
add_settings_error( 'delete-plugin', 'failure_plugin_deletion', __( 'You do not have sufficient permissions to delete this plugin.', 'rtPanel' ));
} else {
delete_plugins(array(RTP_HOOKS_EDITOR));
add_settings_error( 'delete-plugin', 'plugin_deletion', __( 'rtPanel Hooks Editor Plugin has been Deleted.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['subscribe-activate']) && ( $_POST['subscribe-activate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_subscribe_activate'];
if (!wp_verify_nonce($nonce, RTP_SUBSCRIBE_TO_COMMENTS . '-activate' )) {
add_settings_error( 'activate-plugin', 'failure_plugin_activation', __( 'You do not have sufficient permissions to activate this plugin.', 'rtPanel' ));
} else {
activate_plugin(RTP_SUBSCRIBE_TO_COMMENTS);
add_settings_error( 'activate-plugin', 'plugin_activation', __( 'Subscribe to Comments Plugin has been Activated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['subscribe-deactivate']) && ( $_POST['subscribe-deactivate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_subscribe_deactivate'];
if (!wp_verify_nonce($nonce, RTP_SUBSCRIBE_TO_COMMENTS . '-deactivate' )) {
add_settings_error( 'deactivate-plugin', 'failure_plugin_deactivation', __( 'You do not have sufficient permissions to deactivate this plugin.', 'rtPanel' ));
} else {
deactivate_plugins(array(RTP_SUBSCRIBE_TO_COMMENTS));
add_settings_error( 'deactivate-plugin', 'plugin_activation', __( 'Subscribe to Comments Plugin has been Deactivated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['subscribe-delete']) && ( $_POST['subscribe-delete'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_subscribe_delete'];
if (!wp_verify_nonce($nonce, RTP_SUBSCRIBE_TO_COMMENTS . '-delete' )) {
add_settings_error( 'delete-plugin', 'failure_plugin_deletion', __( 'You do not have sufficient permissions to delete this plugin.', 'rtPanel' ));
} else {
delete_plugins(array(RTP_SUBSCRIBE_TO_COMMENTS));
add_settings_error( 'delete-plugin', 'plugin_deletion', __( 'Subscribe to Comments Plugin has been Deleted.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['yoast_seo-activate']) && ( $_POST['yoast_seo-activate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_yoast_seo_activate'];
if (!wp_verify_nonce($nonce, RTP_YOAST_SEO . '-activate' )) {
add_settings_error( 'activate-plugin', 'failure_plugin_activation', __( 'You do not have sufficient permissions to activate this plugin.', 'rtPanel' ));
} else {
activate_plugin(RTP_YOAST_SEO);
add_settings_error( 'activate-plugin', 'plugin_activation', __( 'Yoast WordPress SEO Plugin has been Activated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['yoast_seo-deactivate']) && ( $_POST['yoast_seo-deactivate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_yoast_seo_deactivate'];
if (!wp_verify_nonce($nonce, RTP_YOAST_SEO . '-deactivate' )) {
add_settings_error( 'deactivate-plugin', 'failure_plugin_deactivation', __( 'You do not have sufficient permissions to deactivate this plugin.', 'rtPanel' ));
} else {
deactivate_plugins(array(RTP_YOAST_SEO));
add_settings_error( 'deactivate-plugin', 'plugin_deactivation', __( 'Yoast WordPress SEO Plugin has been Deactivated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['yoast_seo-delete']) && ( $_POST['yoast_seo-delete'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_yoast_seo_delete'];
if (!wp_verify_nonce($nonce, RTP_YOAST_SEO . '-delete' )) {
add_settings_error( 'delete-plugin', 'failure_plugin_deletion', __( 'You do not have sufficient permissions to delete this plugin.', 'rtPanel' ));
} else {
delete_plugins(array(RTP_YOAST_SEO));
add_settings_error( 'delete-plugin', 'plugin_deletion', __( 'Yoast WordPress SEO Plugin has been Deleted.', 'rtPanel' ), 'updated' );
}
}elseif (isset($_POST['rtmedia-activate']) && ( $_POST['rtmedia-activate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_rtmedia_activate'];
if (!wp_verify_nonce($nonce, RTP_MEDIA . '-activate' )) {
add_settings_error( 'activate-plugin', 'failure_plugin_activation', __( 'You do not have sufficient permissions to activate this plugin.', 'rtPanel' ));
} else {
activate_plugin(RTP_MEDIA);
add_settings_error( 'activate-plugin', 'plugin_activation', __( 'rtMedia for WordPress, BuddyPress and bbPress Plugin has been Activated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['rtmedia-deactivate']) && ( $_POST['rtmedia-deactivate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_rtmedia_deactivate'];
if (!wp_verify_nonce($nonce, RTP_MEDIA . '-deactivate' )) {
add_settings_error( 'deactivate-plugin', 'failure_plugin_deactivation', __( 'You do not have sufficient permissions to deactivate this plugin.', 'rtPanel' ));
} else {
deactivate_plugins(array(RTP_MEDIA));
add_settings_error( 'deactivate-plugin', 'plugin_deactivation', __( 'rtMedia for WordPress, BuddyPress and bbPress Plugin has been Deactivated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['rtmedia-delete']) && ( $_POST['rtmedia-delete'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_rtmedia_delete'];
if (!wp_verify_nonce($nonce, RTP_MEDIA . '-delete' )) {
add_settings_error( 'delete-plugin', 'failure_plugin_deletion', __( 'You do not have sufficient permissions to delete this plugin.', 'rtPanel' ));
} else {
delete_plugins(array(RTP_MEDIA));
add_settings_error( 'delete-plugin', 'plugin_deletion', __( 'rtMedia for WordPress, BuddyPress and bbPress Plugin has been Deleted.', 'rtPanel' ), 'updated' );
}
}elseif (isset($_POST['regenerate-activate']) && ( $_POST['regenerate-activate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_regenerate_activate'];
if (!wp_verify_nonce($nonce, RTP_REGENERATE_THUMBNAILS . '-activate' )) {
add_settings_error( 'activate-plugin', 'failure_plugin_activation', __( 'You do not have sufficient permissions to activate this plugin.', 'rtPanel' ));
} else {
activate_plugin(RTP_REGENERATE_THUMBNAILS);
add_settings_error( 'activate-plugin', 'plugin_activation', __( 'Regenerate Thumbnails Plugin has been Activated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['regenerate-deactivate']) && ( $_POST['regenerate-deactivate'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_regenerate_deactivate'];
if (!wp_verify_nonce($nonce, RTP_REGENERATE_THUMBNAILS . '-deactivate' )) {
add_settings_error( 'deactivate-plugin', 'failure_plugin_deactivation', __( 'You do not have sufficient permissions to deactivate this plugin.', 'rtPanel' ));
} else {
deactivate_plugins(array(RTP_REGENERATE_THUMBNAILS));
add_settings_error( 'deactivate-plugin', 'plugin_deactivation', __( 'Regenerate Thumbnails Plugin has been Deactivated.', 'rtPanel' ), 'updated' );
}
} elseif (isset($_POST['regenerate-delete']) && ( $_POST['regenerate-delete'] == 1 )) {
$nonce = $_REQUEST['_wpnonce_regenerate_delete'];
if (!wp_verify_nonce($nonce, RTP_REGENERATE_THUMBNAILS . '-delete' )) {
add_settings_error( 'delete-plugin', 'failure_plugin_deletion', __( 'You do not have sufficient permissions to delete this plugin.', 'rtPanel' ));
} else {
delete_plugins(array(RTP_REGENERATE_THUMBNAILS));
add_settings_error( 'delete-plugin', 'plugin_deletion', __( 'Regenerate Thumbnails Plugin has been Deleted.', 'rtPanel' ), 'updated' );
}
}
} elseif (isset($_POST['rtp_logo_favicon_reset'])) {
$options = maybe_unserialize($rtp_general);
unset($input);
foreach ($options as $option => $value)
$input[$option] = $value;
$input['logo_use'] = $default[0]['logo_use'];
$input['logo_upload'] = $default[0]['logo_upload'];
$input['logo_id'] = $default[0]['logo_id'];
$input['logo_width'] = $default[0]['logo_width'];
$input['logo_height'] = $default[0]['logo_height'];
$input['login_head'] = $default[0]['login_head'];
$input['favicon_use'] = $default[0]['favicon_use'];
$input['favicon_upload'] = $default[0]['favicon_upload'];
$input['favicon_id'] = $default[0]['favicon_id'];
add_settings_error( 'logo_favicon_settings', 'logo_favicon_reset', __( 'The Logo Settings have been restored to Default.', 'rtPanel' ), 'updated' );
} elseif (isset($_POST['rtp_google_reset'])) {
$options = maybe_unserialize($rtp_general);
unset($input);
foreach ($options as $option => $value)
$input[$option] = $value;
$input['search_code'] = $default[0]['search_code'];
$input['search_layout'] = $default[0]['search_layout'];
add_settings_error( 'search_code', 'reset_search_code', __( 'The Google Custom Search Integration has been restored to Default.', 'rtPanel' ), 'updated' );
} elseif (isset($_POST['rtp_sidebar_reset'])) {
$options = maybe_unserialize($rtp_general);
unset($input);
foreach ($options as $option => $value)
$input[$option] = $value;
$input['footer_sidebar'] = $default[0]['footer_sidebar'];
$input['buddypress_sidebar'] = $default[0]['buddypress_sidebar'];
$input['bbpress_sidebar'] = $default[0]['bbpress_sidebar'];
add_settings_error( 'sidebar', 'reset_sidebar', __( 'The Sidebar Settings have been restored to Default.', 'rtPanel' ), 'updated' );
} elseif (isset($_POST['rtp_custom_styles_reset'])) {
$options = maybe_unserialize($rtp_general);
unset($input);
foreach ($options as $option => $value)
$input[$option] = $value;
$input['custom_styles'] = $default[0]['custom_styles'];
add_settings_error( 'custom_styles', 'reset_custom_styles', __( 'Custom Styles has been restored to Default.', 'rtPanel' ), 'updated' );
} elseif (isset($_POST['rtp_export'])) {
rtp_export();
die();
} elseif (isset($_POST['rtp_import'])) {
$general = rtp_import($_FILES['rtp_import']);
if ($general && $general != 'ext' ) {
unset($input);
$input = maybe_unserialize($general);
add_settings_error( 'rtp_import', 'import', __( 'rtPanel Options have been imported successfully', 'rtPanel' ), 'updated' );
} elseif ($general == 'ext' ) {
add_settings_error( 'rtp_import', 'no_import', __( 'Not a valid RTP file', 'rtPanel' ));
} else {
add_settings_error( 'rtp_import', 'no_import', __( 'The file is corrupt. There was an error while importing. Please Try Again', 'rtPanel' ));
}
} elseif (isset($_POST['rtp_reset'])) {
$input = $default[0];
add_settings_error( 'rtp_general', 'reset_general_options', __( 'All the rtPanel General Settings have been restored to default.', 'rtPanel' ), 'updated' );
}
return $input; // Return validated input.
}
/**
* Data validation for rtPanel Post & Comments Options
*
* @uses $rtp_post_comments array
* @param array $input all post & comments options inputs.
* @return Array
*
* @since rtPanel 2.0
*/
function rtp_post_comments_validate($input) {
global $rtp_post_comments;
$default = rtp_theme_setup_values();
if (isset($_POST['rtp_submit'])) {
$input['notices'] = $rtp_post_comments['notices'];
if ($input['summary_show']) {
$updated = 0;
if (trim($input['read_text']) != $rtp_post_comments['read_text']) {
$input['read_text'] = trim($input['read_text']);
$updated++;
}
if (!preg_match( '/^[0-9]{1,3}$/i', $input['word_limit'])) {
$input['word_limit'] = $rtp_post_comments['word_limit'];
add_settings_error( 'word_limit', 'invalid_word_limit', __( 'The Word Limit provided is invalid. Please provide a proper value.', 'rtPanel' ));
} elseif (trim($input['word_limit']) != $rtp_post_comments['word_limit']) {
$updated++;
}
if ($updated) {
add_settings_error( 'post_summary_settings', 'post_summary_settings', __( 'The Post Summary Settings have been updated.', 'rtPanel' ), 'updated' );
}
if ($input['thumbnail_show']) {
$updated = 0;
if (!preg_match( '/^[0-9]{1,3}$/i', $input['thumbnail_width'])) {
$input['thumbnail_width'] = get_option( 'thumbnail_size_w' );
add_settings_error( 'thumbnail_width', 'invalid_thumbnail_width', __( 'The Thumbnail Width provided is invalid. Please provide a proper value.', 'rtPanel' ));
} elseif (get_option( 'thumbnail_size_w' ) != $input['thumbnail_width']) {
$input['notices'] = '1';
update_option( 'thumbnail_size_w', $input['thumbnail_width']);
$updated++;
}
if (!preg_match( '/^[0-9]{1,3}$/i', $input['thumbnail_height'])) {
$input['thumbnail_height'] = get_option( 'thumbnail_size_h' );
add_settings_error( 'thumbnail_height', 'invalid_thumbnail_height', __( 'The Thumbnail Height provided is invalid. Please provide a proper value.', 'rtPanel' ));
} elseif (get_option( 'thumbnail_size_h' ) != $input['thumbnail_height']) {
$input['notices'] = '1';
update_option( 'thumbnail_size_h', $input['thumbnail_height']);
$updated++;
}
if ($input['thumbnail_crop'] != get_option( 'thumbnail_crop' )) {
$input['notices'] = '1';
update_option( 'thumbnail_crop', $input['thumbnail_crop']);
$updated++;
}
if ($updated) {
add_settings_error( 'post_thumbnail_settings', 'post_thumbnail_settings', __( 'The Post Thumbnail Settings have been updated', 'rtPanel' ), 'updated' );
}
} else {
$input['thumbnail_position'] = $rtp_post_comments['thumbnail_position'];
$input['thumbnail_frame'] = $rtp_post_comments['thumbnail_frame'];
}
} else {
$input['thumbnail_show'] = $rtp_post_comments['thumbnail_show'];
$input['word_limit'] = $rtp_post_comments['word_limit'];
$input['read_text'] = $rtp_post_comments['read_text'];
$input['thumbnail_position'] = $rtp_post_comments['thumbnail_position'];
$input['thumbnail_frame'] = $rtp_post_comments['thumbnail_frame'];
}
if (!in_array($input['post_date_format_u'], array($rtp_post_comments['post_date_format_u'], 'F j, Y', 'Y/m/d', 'm/d/Y', 'd/m/Y' ))) {
$input['post_date_format_u'] = str_replace( '<', '', $input['post_date_format_u']);
$input['post_date_format_l'] = str_replace( '<', '', $input['post_date_format_l']);
$input['post_date_custom_format_u'] = str_replace( '<', '', $input['post_date_custom_format_u']);
$input['post_date_custom_format_l'] = str_replace( '<', '', $input['post_date_custom_format_l']);
}
if (!$input['post_date_u']) {
$input['post_date_format_u'] = $rtp_post_comments['post_date_format_u'];
$input['post_date_custom_format_u'] = $rtp_post_comments['post_date_custom_format_u'];
}
if (!$input['post_date_l']) {
$input['post_date_format_l'] = $rtp_post_comments['post_date_format_l'];
$input['post_date_custom_format_l'] = $rtp_post_comments['post_date_custom_format_l'];
}
if (!$input['post_author_u']) {
$input['author_count_u'] = $rtp_post_comments['author_count_u'];
$input['author_link_u'] = $rtp_post_comments['author_link_u'];
}
if (!$input['post_author_l']) {
$input['author_count_l'] = $rtp_post_comments['author_count_l'];
$input['author_link_l'] = $rtp_post_comments['author_link_l'];
}
if ($input['pagination_show']) {
$updated = 0;
if (trim($input['prev_text']) != $rtp_post_comments['prev_text']) {
$input['prev_text'] = trim($input['prev_text']);
$updated++;
}
if (trim($input['next_text']) != $rtp_post_comments['next_text']) {
$input['next_text'] = trim($input['next_text']);
$updated++;
}
if (!preg_match( '/^[0-9]{1,3}$/i', $input['end_size'])) {
$input['end_size'] = $rtp_post_comments['end_size'];
add_settings_error( 'end_size', 'invalid_end_size', __( 'The End Size provided is invalid. Please provide a proper value.', 'rtPanel' ));
}
if (!preg_match( '/^[0-9]{1,3}$/i', $input['mid_size'])) {
$input['mid_size'] = $rtp_post_comments['mid_size'];
add_settings_error( 'mid_size', 'invalid_mid_size', __( 'The Mid Size provided is invalid. Please provide a proper value.', 'rtPanel' ));
}
if ($updated) {
add_settings_error( 'pagination_settings', 'pagination_settings', __( 'The Pagination Settings have been updated.', 'rtPanel' ), 'updated' );
}
} else {
$input['prev_text'] = $rtp_post_comments['prev_text'];
$input['next_text'] = $rtp_post_comments['next_text'];
$input['end_size'] = $rtp_post_comments['end_size'];
$input['mid_size'] = $rtp_post_comments['mid_size'];
}
} elseif (isset($_POST['rtp_summary_reset'])) {
$options = maybe_unserialize($rtp_post_comments);
unset($input);
foreach ($options as $option => $value)
$input[$option] = $value;
$input['notices'] = $rtp_post_comments['notices'];
$input['summary_show'] = $default[1]['summary_show'];
$input['word_limit'] = $default[1]['word_limit'];
$input['read_text'] = $default[1]['read_text'];
add_settings_error( 'summary', 'reset_summary', __( 'The Post Summary Settings have been restored to default.', 'rtPanel' ), 'updated' );
} elseif (isset($_POST['rtp_thumbnail_reset'])) {
$options = maybe_unserialize($rtp_post_comments);
unset($input);
foreach ($options as $option => $value)
$input[$option] = $value;
$input['notices'] = $rtp_post_comments['notices'];
$input['thumbnail_show'] = $default[1]['thumbnail_show'];
$input['thumbnail_position'] = $default[1]['thumbnail_position'];
$input['thumbnail_frame'] = $default[1]['thumbnail_frame'];
add_settings_error( 'thumbnail', 'reset_thumbnail', __( 'The Post Thumbnail Settings have been restored to default.', 'rtPanel' ), 'updated' );
} elseif (isset($_POST['rtp_meta_reset'])) {
$options = maybe_unserialize($rtp_post_comments);
unset($input);
foreach ($options as $option => $value)
$input[$option] = $value;
$input['notices'] = $rtp_post_comments['notices'];
$input['post_date_u'] = $default[1]['post_date_u'];
$input['post_date_format_u'] = $default[1]['post_date_format_u'];
$input['post_date_custom_format_u'] = $default[1]['post_date_custom_format_u'];
$input['post_author_u'] = $default[1]['post_author_u'];
$input['author_count_u'] = $default[1]['author_count_u'];
$input['author_link_u'] = $default[1]['author_link_u'];
$input['post_category_u'] = $default[1]['post_category_u'];
$input['post_tags_u'] = $default[1]['post_tags_u'];
$input['post_date_l'] = $default[1]['post_date_l'];
$input['post_date_format_l'] = $default[1]['post_date_format_l'];
$input['post_date_custom_format_l'] = $default[1]['post_date_custom_format_l'];
$input['post_author_l'] = $default[1]['post_author_l'];
$input['author_count_l'] = $default[1]['author_count_l'];
$input['author_link_l'] = $default[1]['author_link_l'];
$input['post_category_l'] = $default[1]['post_category_l'];
$input['post_tags_l'] = $default[1]['post_tags_l'];
$args = array( '_builtin' => false);
$taxonomies = get_taxonomies($args, 'names' );
if (!empty($taxonomies)) {
foreach ($taxonomies as $taxonomy) {
$input['post_' . $taxonomy . '_u'] = '0';
$input['post_' . $taxonomy . '_l'] = '0';
}
}
add_settings_error( 'post_meta', 'reset_post_meta', __( 'The Post Meta Settings have been restored to default.', 'rtPanel' ), 'updated' );
} elseif (isset($_POST['rtp_pagination_reset'])) {
$options = maybe_unserialize($rtp_post_comments);
unset($input);
foreach ($options as $option => $value)
$input[$option] = $value;
$input['notices'] = $rtp_post_comments['notices'];
$input['pagination_show'] = $default[1]['pagination_show'];
$input['prev_text'] = $default[1]['prev_text'];
$input['next_text'] = $default[1]['next_text'];
$input['end_size'] = $default[1]['end_size'];
$input['mid_size'] = $default[1]['mid_size'];
add_settings_error( 'pagination', 'reset_pagination', __( 'The Pagination Settings have been restored to default.', 'rtPanel' ), 'updated' );
} elseif (isset($_POST['rtp_comment_reset'])) {
$options = maybe_unserialize($rtp_post_comments);
unset($input);
foreach ($options as $option => $value)
$input[$option] = $value;
$input['notices'] = $rtp_post_comments['notices'];
$input['compact_form'] = $default[1]['compact_form'];
$input['hide_labels'] = $default[1]['hide_labels'];
$input['comment_textarea'] = $default[1]['comment_textarea'];
$input['comment_separate'] = $default[1]['comment_separate'];
$input['gravatar_show'] = $default[1]['gravatar_show'];
add_settings_error( 'comment', 'reset_comment', __( 'The Comment Settings have been restored to default.', 'rtPanel' ), 'updated' );
} elseif (isset($_POST['rtp_reset'])) {
$input = $default[1];
$input['notices'] = $rtp_post_comments['notices'];
$args = array( '_builtin' => false);
$taxonomies = get_taxonomies($args, 'names' );
if (!empty($taxonomies)) {
foreach ($taxonomies as $taxonomy) {
$input['post_' . $taxonomy . '_u'] = '0';
$input['post_' . $taxonomy . '_l'] = '0';
}
}
add_settings_error( 'rtp_post_comments', 'reset_post_comments_options', __( 'All the rtPanel Post & Comments Settings have been restored to default.', 'rtPanel' ), 'updated' );
}
return $input; // return validated input
}
/**
* Setup Default Values for rtPanel
*
* This function sets up default values for 'rtPanel' and creates
* 2 options in the WordPress options table: 'rtp_general' &
* 'rtp_post_comments', where the values for the 'General' and
* 'Post & Comments' tabs are stored respectively
*
* @return array.
*
* @since rtPanel 2.0
*/
function rtp_theme_setup_values() {
global $rtp_general, $rtp_post_comments, $rtp_version;
$default_general = array(
'logo_use' => 'site_title',
'logo_upload' => RTP_IMG_FOLDER_URL . '/rtp-logo.png',
'logo_id' => 0,
'logo_width' => 224,
'logo_height' => 51,
'login_head' => '0',
'favicon_use' => 'disable',
'favicon_upload' => RTP_IMG_FOLDER_URL . '/favicon.ico',
'favicon_id' => 0,
'footer_sidebar' => '0',
'buddypress_sidebar' => 'default-sidebar',
'bbpress_sidebar' => 'default-sidebar',
'custom_styles' => '',
'search_code' => '',
'search_layout' => '1',
);
$default_post_comments = array(
'notices' => isset($rtp_post_comments['notices']) ? $rtp_post_comments['notices'] : 0,
'summary_show' => '1',
'word_limit' => 55,
'read_text' => __('Read More →', 'rtPanel'),
'thumbnail_show' => '1',
'thumbnail_position' => 'Right',
'thumbnail_width' => get_option( 'thumbnail_size_w' ),
'thumbnail_height' => get_option( 'thumbnail_size_h' ),
'thumbnail_crop' => get_option( 'thumbnail_crop' ),
'thumbnail_frame' => '0',
'post_date_u' => '1',
'post_date_format_u' => 'F j, Y',
'post_date_custom_format_u' => 'F j, Y',
'post_author_u' => '1',
'author_count_u' => '0',
'author_link_u' => '1',
'post_category_u' => '1',
'post_tags_u' => '0',
'post_date_l' => '0',
'post_date_format_l' => 'F j, Y',
'post_date_custom_format_l' => 'F j, Y',
'post_author_l' => '0',
'author_count_l' => '0',
'author_link_l' => '1',
'post_category_l' => '0',
'post_tags_l' => '0',
'pagination_show' => '1',
'prev_text' => '« Previous',
'next_text' => 'Next »',
'end_size' => '1',
'mid_size' => '2',
'compact_form' => '1',
'hide_labels' => '1',
'comment_textarea' => '0',
'comment_separate' => '1',
'attachment_comments' => '0',
'gravatar_show' => '1',
);
$args = array( '_builtin' => false);
$taxonomies = get_taxonomies($args, 'names' );
if (!empty($taxonomies)) {
foreach ($taxonomies as $taxonomy) {
$default_post_comments['post_' . $taxonomy . '_u'] = '0';
$default_post_comments['post_' . $taxonomy . '_l'] = '0';
}
}
if (!get_option( 'rtp_general' )) {
update_option( 'rtp_general', $default_general);
$blog_users = get_users();
foreach ($blog_users as $blog_user) {
$blog_user_id = $blog_user->ID;
if (!get_user_meta($blog_user_id, 'screen_layout_appearance_page_rtp_general' ))
update_user_meta($blog_user_id, 'screen_layout_appearance_page_rtp_general', 1, NULL);
}
}
if (!get_option( 'rtp_post_comments' )) {
update_option( 'rtp_post_comments', $default_post_comments);
$blog_users = get_users();
foreach ($blog_users as $blog_user) {
$blog_user_id = $blog_user->ID;
if (!get_user_meta($blog_user_id, 'screen_layout_appearance_page_rtp_post_comments' ))
update_user_meta($blog_user_id, 'screen_layout_appearance_page_rtp_post_comments', 1, NULL);
}
}
$rtp_version = rtp_export_version();
if (!get_option( 'rtp_version' ) || ( get_option( 'rtp_version' ) != $rtp_version )) {
update_option( 'rtp_version', $rtp_version);
$updated_general = wp_parse_args($rtp_general, $default_general);
$updated_post_comments = wp_parse_args($rtp_post_comments, $default_post_comments);
update_option( 'rtp_general', $updated_general);
update_option( 'rtp_post_comments', $updated_post_comments);
}
return array($default_general, $default_post_comments);
}
// Redirect to rtPanel on theme activation //
function rtp_theme_activation($themename, $theme = false) {
global $rtp_general;
$update = 0;
if (isset($rtp_general['logo_show']) && $rtp_general['logo_show']) {
$update++;
$rtp_general['logo_use'] = 'image';
unset($rtp_general['logo_show']);
} elseif (isset($rtp_general['logo_show'])) {
$update++;
$rtp_general['logo_use'] = 'site_title';
unset($rtp_general['logo_show']);
}
if (isset($rtp_general['use_logo']) && ( $rtp_general['logo_use'] == 'use_logo_url' )) {
$update++;
$rtp_general['logo_upload'] = $rtp_general['logo_url'];
$id = rtp_get_attachment_id_from_src($rtp_general['logo_upload'], true);
$img_dimensions = rtp_get_image_dimensions($rtp_general['logo_upload'], true, '', $id);
$rtp_general['logo_id'] = $id;
$rtp_general['logo_width'] = $img_dimensions['width'];
$rtp_general['logo_height'] = $img_dimensions['height'];
unset($rtp_general['use_logo']);
unset($rtp_general['logo_url']);
} elseif (isset($rtp_general['use_logo']) && ( $rtp_general['use_logo'] == 'use_logo_upload' )) {
$update++;
$id = rtp_get_attachment_id_from_src($rtp_general['logo_upload'], true);
$img_dimensions = rtp_get_image_dimensions($rtp_general['logo_upload'], true, '', $id);
$rtp_general['logo_id'] = $id;
$rtp_general['logo_width'] = $img_dimensions['width'];
$rtp_general['logo_height'] = $img_dimensions['height'];
unset($rtp_general['use_logo']);
}
if (isset($rtp_general['favicon_show']) && $rtp_general['favicon_show']) {
$update++;
$rtp_general['favicon_use'] = 'image';
unset($rtp_general['favicon_show']);
} elseif (isset($rtp_general['favicon_show'])) {
$update++;
$rtp_general['favicon_use'] = 'disable';
unset($rtp_general['favicon_show']);
}
if (isset($rtp_general['use_favicon']) && ( $rtp_general['use_favicon'] == 'use_favicon_url' )) {
$update++;
$rtp_general['favicon_upload'] = $rtp_general['favicon_url'];
$id = rtp_get_attachment_id_from_src($rtp_general['favicon_upload'], true);
$img_dimensions = rtp_get_image_dimensions($rtp_general['favicon_upload'], true, '', $id);
$rtp_general['favicon_id'] = $id;
unset($rtp_general['use_favicon']);
} elseif (isset($rtp_general['use_favicon']) && ( $rtp_general['use_favicon'] == 'use_favicon_upload' )) {
$update++;
$rtp_general['favicon_id'] = rtp_get_attachment_id_from_src($rtp_general['favicon_upload'], true);
unset($rtp_general['use_favicon']);
unset($rtp_general['favicon_url']);
}
if ($update) {
update_option( 'rtp_general', $rtp_general);
}
}
add_action( 'after_switch_theme', 'rtp_theme_activation', '', 2);
/* condition to check Admin Login Logo option */
if (isset($rtp_general['logo_use']) && isset($rtp_general['login_head']) && ( 'image' == $rtp_general['logo_use'] ) && $rtp_general['login_head']) {
add_action( 'login_head', 'rtp_custom_login_logo' );
add_filter( 'login_headerurl', 'rtp_login_site_url' );
}
/**
* Dislays custom logo on Login Page
*
* @uses $rtp_general array
*
* @since rtPanel 2.0
*/
function rtp_custom_login_logo() {
global $rtp_general;
$custom_logo = $rtp_general['logo_upload'];
if (isset($rtp_general['logo_width']) && !empty($rtp_general['logo_width']) && isset($rtp_general['logo_height']) && !empty($rtp_general['logo_height'])) {
$rtp_logo_width = $rtp_general['logo_width'];
$rtp_logo_height = $rtp_general['logo_height'];
} else {
$dimensions = rtp_get_image_dimensions($custom_logo, true);
if (isset($dimensions['width']) && isset($dimensions['height'])) {
$rtp_logo_width = $dimensions['width'];
$rtp_logo_height = $dimensions['height'];
} else {
$rtp_logo_width = $rtp_logo_height = 0;
}
}
$rtp_wp_loginbox_width = 312;
if ($rtp_logo_width > $rtp_wp_loginbox_width) {
$ratio = $rtp_logo_height / $rtp_logo_width;
$rtp_logo_height = ceil($ratio * $rtp_wp_loginbox_width);
$rtp_logo_width = $rtp_wp_loginbox_width;
$rtp_background_size = 'contain';
} else {
$rtp_background_size = 'auto';
}
echo '<style type="text/css">
.login h1 { margin-left: 8px; }
.login h1 a { background: url( ' . $custom_logo . ' ) no-repeat 50% 0;
background-size: ' . $rtp_background_size . ';';
if ($rtp_logo_width && $rtp_logo_height) {
echo 'height: ' . $rtp_logo_height . 'px;
width: ' . $rtp_logo_width . 'px; margin: 0 auto 15px; padding: 0; }';
}
echo '</style>';
}
/**
* Returns Home URL, to be used by custom logo
*
* @return string
*
* @since rtPanel 2.0
*/
function rtp_login_site_url() {
return home_url( '/' );
}
/**
* Default rtPanel admin sidebar with metabox styling
*
* @return rtPanel_admin_sidebar
*
* @since rtPanel 2.0
*/
function rtp_default_admin_sidebar() { ?>
<div class="postbox" id="social">
<div title="<?php _e( 'Click to toggle', 'rtPanel' ); ?>" class="handlediv"><br /></div>
<h3 class="hndle"><span><?php _e( 'Getting Social is Good', 'rtPanel' ); ?></span></h3>
<div class="inside" style="text-align: center;"><?php
printf( __( '<a href="%s" target="_blank" title="Like Us on Facebook" class="rtp-icon-facebook"></a>', 'rtPanel' ), 'https://www.facebook.com/rtCamp.solutions' );
printf( __( '<a href="%s" target="_blank" title="Follow Us on Twitter" class="rtp-icon-twitter"></a>', 'rtPanel' ), 'http://twitter.com/rtcamp' );
printf( __( '<a href="%s" target="_blank" title="Add to Circle" class="rtp-icon-gplus"></a>', 'rtPanel' ), 'https://plus.google.com/110214156830549460974/posts' );
printf( __( '<a href="%s" target="_blank" title="Subscribe to our feeds" class="rtp-icon-rss"></a>', 'rtPanel' ), 'http://rtcamp.com/feed/' ); ?>
</div>
</div>
<div class="postbox" id="donations">
<div title="<?php _e( 'Click to toggle', 'rtPanel' ); ?>" class="handlediv"><br /></div>
<h3 class="hndle"><span><?php _e( 'Promote, Donate, Share', 'rtPanel' ); ?>...</span></h3>
<div class="inside">
<p><?php printf( __( 'Buy coffee/beer for team behind <a href="%s" title="rtPanel">rtPanel</a>.', 'rtPanel' ), RTP_THEME_URL ); ?></p>
<div class="rt-paypal" style="text-align:center">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_donations" />
<input type="hidden" name="business" value="paypal@rtcamp.com" />
<input type="hidden" name="lc" value="US" />
<input type="hidden" name="item_name" value="rtPanel" />
<input type="hidden" name="no_note" value="0" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" name="submit" alt="<?php _e( 'PayPal - The safer, easier way to pay online!', 'rtPanel' ); ?>" />
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>
</div>
<div class="rt-social-share">
<div class="rt-twitter rtp-social-box">
<?php printf( __( '<a href="%s" class="twitter-share-button" data-text="I ♥ #rtPanel" data-url="%s" data-count="vertical" data-via="rtPanel">Tweet</a>', 'rtPanel' ), 'http://twitter.com/share', RTP_THEME_URL ); ?>
</div>
<div class="rt-facebook rtp-social-box">
<?php printf( __( '<a style="text-align: center;" name="fb_share" type="box_count" share_url="%s"></a>', '' ), 'http://rtpanel.com/' ); ?>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<div class="postbox" id="support">
<div title="<?php _e( 'Click to toggle', 'rtPanel' ); ?>" class="handlediv"><br /></div>
<h3 class="hndle"><span><?php _e( 'Free Support', 'rtPanel' ); ?></span></h3>
<div class="inside"><?php printf( __( 'If you are facing any problems while using rtPanel, or have good ideas for improvements, please discuss the same in our <a href="%s" target="_blank" title="Click here for rtPanel Free Support">Support forums</a>', 'rtPanel' ), 'http://rtcamp.com/support/forum/rtpanel/' ); ?>.</div>
</div>
<div class="postbox" id="latest_news">
<div title="<?php _e( 'Click to toggle', 'rtPanel' ); ?>" class="handlediv"><br /></div>
<h3 class="hndle"><span><?php _e( 'Latest News', 'rtPanel' ); ?></span></h3>
<div class="inside"><?php rtp_get_feeds(); ?></div>
</div><?php
}
/**
* Display feeds from a specified Feed URL
*
* @param string $feed_url The Feed URL.
*
* @since rtPanel 2.0
*/
function rtp_get_feeds($feed_url = 'http://rtcamp.com/blog/category/rtpanel/feed/' ) {
// Get RSS Feed(s)
require_once( ABSPATH . WPINC . '/feed.php' );
$maxitems = 0;
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed($feed_url);
if (!is_wp_error($rss)) { // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
}
?>
<ul><?php
if ($maxitems == 0) {
echo '<li>' . __( 'No items', 'rtPanel' ) . '.</li>';
} else {
// Loop through each feed item and display each item as a hyperlink.
foreach ($rss_items as $item) {
?>
<li>
<a href='<?php echo $item->get_permalink(); ?>' title='<?php echo __( 'Posted ', 'rtPanel' ) . $item->get_date( 'j F Y | g:i a' ); ?>'><?php echo $item->get_title(); ?></a>
</li><?php
}
}
?>
</ul><?php
}
/**
* Adds rtPanel Contextual help
*
* @return string
*
* @since rtPanel 2.1
*/
function rtp_theme_options_help() {
$general_help = '<p>';
$general_help .= __( 'rtPanel is the most easy to use WordPress Theme Framework. You will find many state of the art options and widgets with rtPanel.', 'rtPanel' );
$general_help .= '</p><p>';
$general_help .= __( 'rtPanel framework is used worldwide and keeping this in mind we have made it localization ready. ', 'rtPanel' );
$general_help .= __( 'Developers can use rtPanel as a basic and stripped to bones theme framework for developing their own creative and wonderful WordPress Themes.', 'rtPanel' );
$general_help .= '</p><p>';
$general_help .= __( 'By using rtPanel, developers and users can specify settings for basic functions (like date format, excerpt word count etc.) directly from theme options. ', 'rtPanel' );
$general_help .= __( 'rtPanel provides theme options to manage some basic settings for your theme. ', 'rtPanel' );
$general_help .= __( 'Below are the options provided for your convenience.', 'rtPanel' );
$general_help .= '</p><p>';
$general_help .= __( '<strong>Logo Settings:</strong> Theme\'s logo can be managed from this setting.', 'rtPanel' );
$general_help .= '</p><p>';
$general_help .= __( '<strong>Favicon Settings:</strong> Theme\'s favicon can be managed from this setting.', 'rtPanel' );
$general_help .= '</p><p>';
$general_help .= __( '<strong>Google Custom Search Integration:</strong> This option would enable you to harness the power of Google Search instead of the default WordPress search by specifying the Google Custom Search Code. You also have the option of rendering the Google Search Page without the sidebar.', 'rtPanel' );
$general_help .= '</p><p>';
$general_help .= __( '<strong>Sidebar Settings:</strong> Enable / Disable the Footer Sidebar from here.', 'rtPanel' );
$general_help .= '</p><p>';
$general_help .= __( '<strong>Custom Styles:</strong> You can specify your own CSS styles in this option to override the default Style.', 'rtPanel' );
$general_help .= '</p><p>';
$general_help .= __( '<strong>Plugin Support:</strong> You will get a summary of plugins\' status that are supported by rtPanel. This information box will allow you to manipulate the plugin settings on the fly.', 'rtPanel' );
$general_help .= '</p><p>';
$general_help .= __( '<strong>Backup rtPanel Options:</strong> Export or import all settings that you have configured in rtPanel.', 'rtPanel' );
$general_help .= '</p>';
$general_help .= '<p>' . __( 'Remember to click "<strong>Save All Changes</strong>" to save any changes you have made to the theme options.', 'rtPanel' ) . '</p>';
$post_comment_help = '<p>';
$post_comment_help .= __( 'rtPanel is the most easy to use WordPress Theme Framework. You will find many state of the art options and widgets with rtPanel.', 'rtPanel' );
$post_comment_help .= '</p><p>';
$post_comment_help .= __( 'rtPanel framework is used worldwide and keeping this in mind we have made it localization ready. ', 'rtPanel' );
$post_comment_help .= __( 'Developers can use rtPanel as a basic and stripped to bones theme framework for developing their own creative and wonderful WordPress Themes.', 'rtPanel' );
$post_comment_help .= '</p><p>';
$post_comment_help .= __( 'By using rtPanel, developers and users can specify settings for basic functions (like date format, excerpt word count etc.) directly from theme options. ', 'rtPanel' );
$post_comment_help .= __( 'rtPanel provides theme options to manage some basic settings for your theme. ', 'rtPanel' );
$post_comment_help .= __( 'Below are the options provided for your convenience.', 'rtPanel' );
$post_comment_help .= '</p><p>';
$post_comment_help .= __( '<strong>Post Summaries Settings:</strong> Specify the different excerpt parameters like word count etc.', 'rtPanel' );
$post_comment_help .= '</p><p>';
$post_comment_help .= __( '<strong>Post Thumbnail Settings:</strong> Specify the post thumbnail options like position, size etc.', 'rtPanel' );
$post_comment_help .= '<br />';
$post_comment_help .= __( '<small><strong><em>NOTE:</em></strong> If you are using this option to change height or width of the thumbnail, then please use \'Regenerate Thumbnails\' plugin, to apply the new dimension settings to your thumbnails.</small>', 'rtPanel' );
$post_comment_help .= '</p><p>';
$post_comment_help .= __( '<strong>Post Meta Settings:</strong> You can specify the post meta options like post date format, display or hide author name and their positions in relation with the content.', 'rtPanel' );
$post_comment_help .= '</p><p>';
$post_comment_help .= __( '<strong>Pagination Settings:</strong> Enable this setting to use default WordPress pagination.', 'rtPanel' );
$post_comment_help .= '</p><p>';
$post_comment_help .= __( '<strong>Comment Settings:</strong> You can specify the comment settings from this option.', 'rtPanel' );
$post_comment_help .= '</p><p>';
$post_comment_help .= __( '<strong>Gravtar Settings:</strong> Specify the general Gravtar support from this option.', 'rtPanel' );
$post_comment_help .= '</p>';
$post_comment_help .= '<p>' . __( 'Remember to click "<strong>Save All Changes</strong>" to save any changes you have made to the theme options.', 'rtPanel' ) . '</p>';
$sidebar = '<p><strong>' . __( 'For more information, <br />you can always visit:', 'rtPanel' ) . '</strong></p>' .
'<p><a href="' . RTP_THEME_URL . '" target="_blank" title="' . __( 'rtPanel Official Page', 'rtPanel' ) . '">' . __( 'rtPanel Official Page', 'rtPanel' ) . '</a></p>' .
'<p><a href="' . RTP_DOCS_URL . '" target="_blank" title="' . __( 'rtPanel Documentation', 'rtPanel' ) . '">' . __( 'rtPanel Documentation', 'rtPanel' ) . '</a></p>' .
'<p><a href="' . RTP_AUTHOR_URL . '" target="_blank" title="' . __( 'rtPanel Forum', 'rtPanel' ) . '">' . __( 'rtPanel Forum', 'rtPanel' ) . '</a></p>';
$screen = get_current_screen();
$screen->add_help_tab(array( 'title' => __( 'General', 'rtPanel' ), 'id' => 'rtp-general-help', 'content' => $general_help));
$screen->add_help_tab(array( 'title' => __( 'Post & Comment', 'rtPanel' ), 'id' => 'post-comments-help', 'content' => $post_comment_help));
$screen->set_help_sidebar($sidebar);
}
add_action( 'load-appearance_page_rtp_general', 'rtp_theme_options_help' );
add_action( 'load-appearance_page_rtp_post_comments', 'rtp_theme_options_help' );
/**
* Show rtPanel only to Admin Users ( Admin-Bar only !!! )
*
* @since rtPanel 2.0
*/
function rtp_admin_bar_init() {
// Is the user sufficiently leveled, or has the bar been disabled?
if (!is_super_admin() || !is_admin_bar_showing()) {
return;
}
// Good to go, let's do this!
add_action( 'admin_bar_menu', 'rtp_admin_bar_links', 500);
}
add_action( 'admin_bar_init', 'rtp_admin_bar_init' );
/**
* Adds rtPanel links to Admin Bar
*
* @uses object $wp_admin_bar
*
* @since rtPanel 2.0
*/
function rtp_admin_bar_links() {
global $wp_admin_bar, $rt_panel_theme;
// Links to add, in the form: 'Label' => 'URL'
foreach ($rt_panel_theme->theme_pages as $key => $theme_page) {
if (is_array($theme_page))
$links[$theme_page['menu_title']] = array( 'url' => admin_url( 'themes.php?page=' . $theme_page['menu_slug']), 'slug' => $theme_page['menu_slug']);
}
// Add parent link
$wp_admin_bar->add_menu(array(
'title' => 'rtPanel',
'href' => admin_url( 'themes.php?page=rtp_general' ),
'id' => 'rt_links',
));
// Add submenu links
foreach ($links as $label => $menu) {
$wp_admin_bar->add_menu(array(
'title' => $label,
'href' => $menu['url'],
'parent' => 'rt_links',
'id' => $menu['slug']
));
}
}
/**
* Creates rtPanel Options backup file
*