forked from buddypress/buddypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-bp-admin.php
1604 lines (1384 loc) · 61.7 KB
/
class-bp-admin.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
/**
* Main BuddyPress Admin Class.
*
* @package BuddyPress
* @subpackage CoreAdministration
* @since 1.0.0
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
if ( !class_exists( 'BP_Admin' ) ) :
/**
* Load BuddyPress plugin admin area.
*
* @todo Break this apart into each applicable Component.
*
* @since 1.6.0
*/
#[AllowDynamicProperties]
class BP_Admin {
/** Directory *************************************************************/
/**
* Path to the BuddyPress admin directory.
*
* @since 1.6.0
* @var string $admin_dir
*/
public $admin_dir = '';
/** URLs ******************************************************************/
/**
* URL to the BuddyPress admin directory.
*
* @since 1.6.0
* @var string $admin_url
*/
public $admin_url = '';
/**
* URL to the BuddyPress images directory.
*
* @since 1.6.0
* @var string $images_url
*/
public $images_url = '';
/**
* URL to the BuddyPress admin CSS directory.
*
* @since 1.6.0
* @var string $css_url
*/
public $css_url = '';
/**
* URL to the BuddyPress admin JS directory.
*
* @since 1.6.0
* @var string
*/
public $js_url = '';
/** Other *****************************************************************/
/**
* Notices used for user feedback, like saving settings.
*
* @since 1.9.0
* @var array()
*/
public $notices = array();
/**
* BuddyPress admin screens nav tabs.
*
* @since 10.0.0
* @var array()
*/
public $nav_tabs = array();
/**
* BuddyPress admin active nav tab.
*
* @since 10.0.0
* @var string()
*/
public $active_nav_tab = '';
/**
* BuddyPress admin screens submenu pages.
*
* @since 10.0.0
* @var array()
*/
public $submenu_pages = array();
/** Methods ***************************************************************/
/**
* The main BuddyPress admin loader.
*
* @since 1.6.0
*
*/
public function __construct() {
$this->setup_globals();
$this->includes();
$this->setup_actions();
}
/**
* Set admin-related globals.
*
* @since 1.6.0
*/
private function setup_globals() {
$bp = buddypress();
// Paths and URLs
$this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-core/admin' ); // Admin path.
$this->admin_url = trailingslashit( $bp->plugin_url . 'bp-core/admin' ); // Admin url.
$this->images_url = trailingslashit( $this->admin_url . 'images' ); // Admin images URL.
$this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin css URL.
$this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin css URL.
// Main settings page.
$this->settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
// Main capability.
$this->capability = bp_core_do_network_admin() ? 'manage_network_options' : 'manage_options';
}
/**
* Include required files.
*
* @since 1.6.0
*/
private function includes() {
require $this->admin_dir . 'bp-core-admin-actions.php';
require $this->admin_dir . 'bp-core-admin-settings.php';
require $this->admin_dir . 'bp-core-admin-functions.php';
require $this->admin_dir . 'bp-core-admin-components.php';
require $this->admin_dir . 'bp-core-admin-tools.php';
require $this->admin_dir . 'bp-core-admin-optouts.php';
if ( 'rewrites' === bp_core_get_query_parser() ) {
require $this->admin_dir . 'bp-core-admin-rewrites.php';
}
}
/**
* Set up the admin hooks, actions, and filters.
*
* @since 1.6.0
*
*/
private function setup_actions() {
/* General Actions ***************************************************/
// Add some page specific output to the <head>.
add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 );
// Add menu item to settings menu.
add_action( 'admin_menu', array( $this, 'site_admin_menus' ), 5 );
add_action( bp_core_admin_hook(), array( $this, 'admin_menus' ), 5 );
// Enqueue all admin JS and CSS.
add_action( 'bp_admin_enqueue_scripts', array( $this, 'admin_register_styles' ), 1 );
add_action( 'bp_admin_enqueue_scripts', array( $this, 'admin_register_scripts' ), 1 );
add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
/* BuddyPress Actions ************************************************/
// Load the BuddyPress metabox in the WP Nav Menu Admin UI.
add_action( 'load-nav-menus.php', 'bp_admin_wp_nav_menu_meta_box' );
// Add settings.
add_action( 'bp_register_admin_settings', array( $this, 'register_admin_settings' ) );
// Add a link to BuddyPress Hello in the admin bar.
add_action( 'admin_bar_menu', array( $this, 'admin_bar_about_link' ), 100 );
// Add a description of BuddyPress tools in the available tools page.
if ( bp_current_user_can( 'bp_moderate' ) ) {
add_action( 'tool_box', 'bp_core_admin_available_tools_intro' );
add_action( 'bp_network_tool_box', 'bp_core_admin_available_tools_intro' );
}
// On non-multisite, catch.
add_action( 'load-users.php', 'bp_core_admin_user_manage_spammers' );
// Emails.
add_filter( 'manage_' . bp_get_email_post_type() . '_posts_columns', array( $this, 'emails_register_situation_column' ) );
add_action( 'manage_' . bp_get_email_post_type() . '_posts_custom_column', array( $this, 'emails_display_situation_column_data' ), 10, 2 );
// Privacy Policy.
add_action( 'bp_admin_init', array( $this, 'add_privacy_policy_content' ) );
// BuddyPress Hello.
add_action( 'admin_footer', array( $this, 'about_screen' ) );
// BuddyPress Types administration.
add_action( 'load-edit-tags.php', array( 'BP_Admin_Types', 'register_types_admin' ) );
// Official BuddyPress supported Add-ons.
add_action( 'install_plugins_bp-add-ons', array( $this, 'display_addons_table' ) );
/* Filters ***********************************************************/
// Add link to settings page.
add_filter( 'plugin_action_links', array( $this, 'modify_plugin_action_links' ), 10, 2 );
add_filter( 'network_admin_plugin_action_links', array( $this, 'modify_plugin_action_links' ), 10, 2 );
// Add "Mark as Spam" row actions on users.php.
add_filter( 'ms_user_row_actions', 'bp_core_admin_user_row_actions', 10, 2 );
add_filter( 'user_row_actions', 'bp_core_admin_user_row_actions', 10, 2 );
// Emails
add_filter( 'bp_admin_menu_order', array( $this, 'emails_admin_menu_order' ), 20 );
// Official BuddyPress supported Add-ons.
add_filter( 'install_plugins_tabs', array( $this, 'addons_tab' ) );
add_filter( 'install_plugins_table_api_args_bp-add-ons', array( $this,'addons_args' ) );
}
/**
* Register site- or network-admin nav menu elements.
*
* Contextually hooked to site or network-admin depending on current configuration.
*
* @since 1.6.0
*/
public function admin_menus() {
// Bail if user cannot moderate.
if ( ! bp_current_user_can( 'manage_options' ) ) {
return;
}
$hooks = array();
// Changed in BP 1.6 . See bp_core_admin_backpat_menu().
$hooks[] = add_menu_page(
__( 'BuddyPress', 'buddypress' ),
__( 'BuddyPress', 'buddypress' ),
$this->capability,
'bp-general-settings',
'bp_core_admin_backpat_menu',
'div'
);
$hooks[] = add_submenu_page(
'bp-general-settings',
__( 'BuddyPress Help', 'buddypress' ),
__( 'Help', 'buddypress' ),
$this->capability,
'bp-general-settings',
'bp_core_admin_backpat_page'
);
// Add the option pages.
$bp_components_page = add_submenu_page(
$this->settings_page,
__( 'BuddyPress Components', 'buddypress' ),
__( 'BuddyPress', 'buddypress' ),
$this->capability,
'bp-components',
'bp_core_admin_components_settings'
);
$this->submenu_pages['settings']['bp-components'] = $bp_components_page;
$hooks[] = $bp_components_page;
if ( 'rewrites' === bp_core_get_query_parser() ) {
$bp_rewrites_settings_page = add_submenu_page(
$this->settings_page,
__( 'BuddyPress URLs', 'buddypress' ),
__( 'BuddyPress URLs', 'buddypress' ),
$this->capability,
'bp-rewrites',
'bp_core_admin_rewrites_settings'
);
$this->submenu_pages['settings']['bp-rewrites'] = $bp_rewrites_settings_page;
$hooks[] = $bp_rewrites_settings_page;
}
$bp_settings_page = add_submenu_page(
$this->settings_page,
__( 'BuddyPress Options', 'buddypress' ),
__( 'BuddyPress Options', 'buddypress' ),
$this->capability,
'bp-settings',
'bp_core_admin_settings'
);
$this->submenu_pages['settings']['bp-settings'] = $bp_settings_page;
$hooks[] = $bp_settings_page;
// Credits.
$bp_credits_page = add_submenu_page(
$this->settings_page,
__( 'BuddyPress Credits', 'buddypress' ),
__( 'BuddyPress Credits', 'buddypress' ),
$this->capability,
'bp-credits',
array( $this, 'credits_screen' )
);
$this->submenu_pages['settings']['bp-credits'] = $bp_credits_page;
$hooks[] = $bp_credits_page;
// For consistency with non-Multisite, we add a Tools menu in
// the Network Admin as a home for our Tools panel.
if ( is_multisite() && bp_core_do_network_admin() ) {
$tools_parent = 'network-tools';
$hooks[] = add_menu_page(
__( 'Tools', 'buddypress' ),
__( 'Tools', 'buddypress' ),
$this->capability,
$tools_parent,
'bp_core_tools_top_level_item',
'',
24 // Just above Settings.
);
$hooks[] = add_submenu_page(
$tools_parent,
__( 'Available Tools', 'buddypress' ),
__( 'Available Tools', 'buddypress' ),
$this->capability,
'available-tools',
'bp_core_admin_available_tools_page'
);
} else {
$tools_parent = 'tools.php';
}
// Init the Tools submenu pages global.
$this->submenu_pages['tools'] = array();
$bp_repair_tools = add_submenu_page(
$tools_parent,
__( 'BuddyPress Tools', 'buddypress' ),
__( 'BuddyPress', 'buddypress' ),
$this->capability,
'bp-tools',
'bp_core_admin_tools'
);
$this->submenu_pages['tools']['bp-tools'] = $bp_repair_tools;
$hooks[] = $bp_repair_tools;
$bp_optouts_tools = add_submenu_page(
$tools_parent,
__( 'Manage Opt-outs', 'buddypress' ),
__( 'Manage Opt-outs', 'buddypress' ),
$this->capability,
'bp-optouts',
'bp_core_optouts_admin'
);
$this->submenu_pages['tools']['bp-optouts'] = $bp_optouts_tools;
$hooks[] = $bp_optouts_tools;
// For network-wide configs, add a link to (the root site's) Emails screen.
if ( is_network_admin() && bp_is_network_activated() ) {
$email_labels = bp_get_email_post_type_labels();
$email_url = get_admin_url( bp_get_root_blog_id(), 'edit.php?post_type=' . bp_get_email_post_type() );
$hooks[] = add_menu_page(
$email_labels['name'],
$email_labels['menu_name'],
$this->capability,
'',
'',
'dashicons-email',
26
);
// Hack: change the link to point to the root site's admin, not the network admin.
$GLOBALS['menu'][26][2] = esc_url_raw( $email_url );
}
foreach( $hooks as $hook ) {
add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
if ( 'settings_page_bp-rewrites' === $hook ) {
add_action( "load-{$hook}", 'bp_core_admin_rewrites_load' );
}
}
/**
* Fires before adding inline styles for BP Admin tabs.
*
* @since 10.0.0
*
* @param array $submenu_pages The BP_Admin submenu pages passed by reference.
*/
do_action_ref_array( 'bp_admin_submenu_pages', array( &$this->submenu_pages ) );
foreach( $this->submenu_pages as $subpage_type => $subpage_hooks ) {
foreach ( $subpage_hooks as $subpage_hook ) {
add_action( "admin_print_styles-{$subpage_hook}", array( $this, 'add_inline_styles' ), 20 );
// When BuddyPress is activated on the network, the settings screens need an admin notice when settings have been updated.
if ( is_network_admin() && bp_is_network_activated() && 'settings' === $subpage_type && 'settings_page_bp-credits' !== $subpage_hook ) {
add_action( "load-{$subpage_hook}", array( $this, 'admin_load' ) );
}
}
}
}
/**
* Register site-admin nav menu elements.
*
* @since 2.5.0
*/
public function site_admin_menus() {
if ( ! bp_current_user_can( 'manage_options' ) ) {
return;
}
$hooks = array();
// Appearance > Emails.
$hooks[] = add_theme_page(
_x( 'Emails', 'screen heading', 'buddypress' ),
_x( 'Emails', 'screen heading', 'buddypress' ),
$this->capability,
'bp-emails-customizer-redirect',
'bp_email_redirect_to_customizer'
);
// Emails > Customize.
$hooks[] = add_submenu_page(
'edit.php?post_type=' . bp_get_email_post_type(),
_x( 'Customize', 'email menu label', 'buddypress' ),
_x( 'Customize', 'email menu label', 'buddypress' ),
$this->capability,
'bp-emails-customizer-redirect',
'bp_email_redirect_to_customizer'
);
foreach( $hooks as $hook ) {
add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
}
}
/**
* Register the settings.
*
* @since 1.6.0
*
*/
public function register_admin_settings() {
/* Main Section ******************************************************/
// Add the main section.
add_settings_section( 'bp_main', __( 'Main Settings', 'buddypress' ), 'bp_admin_setting_callback_main_section', 'buddypress' );
// Hide toolbar for logged out users setting.
add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' );
register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' );
// Allow account deletion.
add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' );
// Community Visibility
if ( 'rewrites' === bp_core_get_query_parser() ) {
add_settings_field( '_bp_community_visibility', __( 'Community Visibility', 'buddypress' ), 'bp_admin_setting_callback_community_visibility', 'buddypress', 'bp_main' );
register_setting( 'buddypress', '_bp_community_visibility', 'bp_admin_sanitize_callback_community_visibility' );
}
// Template pack picker.
add_settings_field( '_bp_theme_package_id', __( 'Template Pack', 'buddypress' ), 'bp_admin_setting_callback_theme_package_id', 'buddypress', 'bp_main', array( 'label_for' => '_bp_theme_package_id' ) );
register_setting( 'buddypress', '_bp_theme_package_id', 'sanitize_text_field' );
/* Members Section **************************************************/
// Add the main section.
add_settings_section( 'bp_members', _x( 'Members Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_members_section', 'buddypress' );
// Avatars.
add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_members' );
register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
// Cover images.
if ( bp_is_active( 'members', 'cover_image' ) ) {
add_settings_field( 'bp-disable-cover-image-uploads', __( 'Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_cover_image_uploads', 'buddypress', 'bp_members' );
register_setting( 'buddypress', 'bp-disable-cover-image-uploads', 'intval' );
}
// Community Invitations.
if ( bp_is_active( 'members', 'invitations' ) ) {
add_settings_field( 'bp-enable-members-invitations', __( 'Invitations', 'buddypress' ), 'bp_admin_setting_callback_members_invitations', 'buddypress', 'bp_members' );
register_setting( 'buddypress', 'bp-enable-members-invitations', 'intval' );
}
// Membership requests.
if ( bp_is_active( 'members', 'membership_requests' ) ) {
add_settings_field( 'bp-enable-membership-requests', __( 'Membership Requests', 'buddypress' ), 'bp_admin_setting_callback_membership_requests', 'buddypress', 'bp_members' );
register_setting( 'buddypress', 'bp-enable-membership-requests', 'intval' );
}
/* XProfile Section **************************************************/
if ( bp_is_active( 'xprofile' ) ) {
// Add the main section.
add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
// Profile sync setting.
add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' );
register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' );
}
/* Groups Section ****************************************************/
if ( bp_is_active( 'groups' ) ) {
// Add the main section.
add_settings_section( 'bp_groups', __( 'Groups Settings', 'buddypress' ), 'bp_admin_setting_callback_groups_section', 'buddypress' );
// Allow subscriptions setting.
add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation', 'buddypress' ), 'bp_admin_setting_callback_group_creation', 'buddypress', 'bp_groups' );
register_setting( 'buddypress', 'bp_restrict_group_creation', 'intval' );
// Allow group avatars.
add_settings_field( 'bp-disable-group-avatar-uploads', __( 'Group Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_avatar_uploads', 'buddypress', 'bp_groups' );
register_setting( 'buddypress', 'bp-disable-group-avatar-uploads', 'intval' );
// Allow group cover images.
if ( bp_is_active( 'groups', 'cover_image' ) ) {
add_settings_field( 'bp-disable-group-cover-image-uploads', __( 'Group Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_cover_image_uploads', 'buddypress', 'bp_groups' );
register_setting( 'buddypress', 'bp-disable-group-cover-image-uploads', 'intval' );
}
}
/* Activity Section **************************************************/
if ( bp_is_active( 'activity' ) ) {
// Add the main section.
add_settings_section( 'bp_activity', __( 'Activity Settings', 'buddypress' ), 'bp_admin_setting_callback_activity_section', 'buddypress' );
// Activity commenting on post and comments.
add_settings_field( 'bp-disable-blogforum-comments', __( 'Post Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' );
register_setting( 'buddypress', 'bp-disable-blogforum-comments', 'bp_admin_sanitize_callback_blogforum_comments' );
// Activity Heartbeat refresh.
add_settings_field( '_bp_enable_heartbeat_refresh', __( 'Activity auto-refresh', 'buddypress' ), 'bp_admin_setting_callback_heartbeat', 'buddypress', 'bp_activity' );
register_setting( 'buddypress', '_bp_enable_heartbeat_refresh', 'intval' );
// Allow activity akismet.
if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) {
add_settings_field( '_bp_enable_akismet', __( 'Akismet', 'buddypress' ), 'bp_admin_setting_callback_activity_akismet', 'buddypress', 'bp_activity' );
register_setting( 'buddypress', '_bp_enable_akismet', 'intval' );
}
}
/* Notification Section **************************************************/
if ( bp_is_active( 'notifications' ) ) {
// Add the main section.
add_settings_section( 'bp_notifications', __( 'Notifications Settings', 'buddypress' ), 'bp_admin_setting_callback_notifications_section', 'buddypress' );
// Enable Private Message Notification
add_settings_field( 'bp-enable-pm-notifications', __( 'Private Message', 'buddypress' ), 'bp_admin_setting_callback_private_message_notifications', 'buddypress', 'bp_notifications' );
register_setting( 'buddypress', 'bp-enable-pm-notifications', 'intval' );
}
}
/**
* Add a link to BuddyPress Hello to the admin bar.
*
* @since 1.9.0
* @since 3.0.0 Hooked at priority 100 (was 15).
*
* @param WP_Admin_Bar $wp_admin_bar WordPress object implementing a Toolbar API.
*/
public function admin_bar_about_link( $wp_admin_bar ) {
if ( ! is_user_logged_in() ) {
return;
}
$wp_admin_bar->add_node( array(
'parent' => 'wp-logo',
'id' => 'bp-about',
'title' => esc_html_x( 'Hello, BuddyPress!', 'Colloquial alternative to "learn about BuddyPress"', 'buddypress' ),
'href' => bp_get_admin_url( '?hello=buddypress' ),
'meta' => array(
'class' => 'say-hello-buddypress',
),
) );
}
/**
* Add Settings link to plugins area.
*
* @since 1.6.0
*
* @param array $links Links array in which we would prepend our link.
* @param string $file Current plugin basename.
* @return array Processed links.
*/
public function modify_plugin_action_links( $links, $file ) {
// Return normal links if not BuddyPress.
if ( plugin_basename( buddypress()->basename ) != $file ) {
return $links;
}
// Add a few links to the existing links array.
return array_merge( $links, array(
'settings' => '<a href="' . esc_url( add_query_arg( array( 'page' => 'bp-components' ), bp_get_admin_url( $this->settings_page ) ) ) . '">' . esc_html__( 'Settings', 'buddypress' ) . '</a>',
'about' => '<a href="' . esc_url( bp_get_admin_url( '?hello=buddypress' ) ) . '">' . esc_html_x( 'Hello, BuddyPress!', 'Colloquial alternative to "learn about BuddyPress"', 'buddypress' ) . '</a>'
) );
}
/**
* Displays an admin notice to inform settings have been saved.
*
* The notice is only displayed inside the Network Admin when
* BuddyPress is network activated.
*
* @since 10.0.0
*/
public function admin_load() {
if ( ! isset( $_GET['updated'] ) ) {
return;
}
bp_core_add_admin_notice( __( 'Settings saved.', 'buddypress' ), 'updated' );
}
/**
* Add some general styling to the admin area.
*
* @since 1.6.0
*/
public function admin_head() {
// Settings pages.
remove_submenu_page( $this->settings_page, 'bp-rewrites' );
remove_submenu_page( $this->settings_page, 'bp-settings' );
remove_submenu_page( $this->settings_page, 'bp-credits' );
// Network Admin Tools.
remove_submenu_page( 'network-tools', 'network-tools' );
// About and Credits pages.
remove_submenu_page( 'index.php', 'bp-about' );
remove_submenu_page( 'index.php', 'bp-credits' );
// Nonmembers Opt-outs page.
if ( is_network_admin() ) {
remove_submenu_page( 'network-tools', 'bp-optouts' );
} else {
remove_submenu_page( 'tools.php', 'bp-optouts' );
}
}
/**
* Add some general styling to the admin area.
*
* @since 1.6.0
*/
public function enqueue_scripts() {
wp_enqueue_style( 'bp-admin-common-css' );
// BuddyPress Hello.
if ( 0 === strpos( get_current_screen()->id, 'dashboard' ) && ! empty( $_GET['hello'] ) && $_GET['hello'] === 'buddypress' ) {
wp_enqueue_style( 'bp-hello-css' );
wp_enqueue_script( 'bp-hello-js' );
wp_localize_script( 'bp-hello-js', 'bpHelloStrings', array(
'pageNotFound' => __( 'Sorry, the page you requested was not found.', 'buddypress' ),
'modalLabel' => __( 'Hello BuddyPress', 'buddypress' ),
) );
}
}
/**
* Registers BuddyPress's suggested privacy policy language.
*
* @since 4.0.0
*/
public function add_privacy_policy_content() {
$suggested_text = '<strong class="privacy-policy-tutorial">' . esc_html__( 'Suggested text:', 'buddypress' ) . ' </strong>';
$content = '';
$content .= '<div class="wp-suggested-text">';
$content .= '<h2>' . esc_html__( 'What personal data we collect and why we collect it', 'buddypress' ) . '</h2>';
$content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'Sites powered by BuddyPress rely heavily on user-provided data. In this section, you should note what data you collect, from both registered users and anonymous visitors.', 'buddypress' ) . '</p>';
if ( bp_is_active( 'xprofile' ) ) {
$content .= '<h3>' . esc_html__( 'Profile Data', 'buddypress' ) . '</h3>';
$content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'In this section you should note what information is collected on user profiles. The suggested text gives an overview of the kinds of profile data collected by BuddyPress.', 'buddypress' ) . '</p>';
$content .= '<p>' . $suggested_text . esc_html__( 'When you register for the site, you may be asked to provide certain personal data for display on your profile. The "Name" field is required as well as public, and user profiles are visible to any site visitor. Other profile information may be required or optional, as configured by the site administrator.', 'buddypress' ) . '</p>';
$content .= '<p>' . esc_html__( 'User information provided during account registration can be modified or removed on the Profile > Edit panel. In most cases, users also have control over who is able to view a particular piece of profile content, limiting visibility on a field-by-field basis to friends, logged-in users, or administrators only. Site administrators can read and edit all profile data for all users.', 'buddypress' ) . '</p>';
}
if ( bp_is_active( 'activity' ) ) {
$content .= '<h3>' . esc_html__( 'Activity', 'buddypress' ) . '</h3>';
$content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'In this section you should describe the kinds of information collected in the activity stream, how and whether it can be edited or deleted, and to whom the activity is visible.', 'buddypress' ) . '</p>';
$content .= '<p>' . $suggested_text . esc_html__( 'This site records certain user actions, in the form of "activity" data. Activity includes updates and comments posted directly to activity streams, as well as descriptions of other actions performed while using the site, such as new friendships, newly joined groups, and profile updates.', 'buddypress' ) . '</p>';
$content .= '<p>' . esc_html__( 'The content of activity items obey the same privacy rules as the contexts in which the activity items are created. For example, activity updates created in a user\'s profile is publicly visible, while activity items generated in a private group are visible only to members of that group. Site administrators can view all activity items, regardless of context.', 'buddypress' ) . '</p>';
$content .= '<p>' . esc_html__( 'Activity items may be deleted at any time by users who created them. Site administrators can edit all activity items.', 'buddypress' ) . '</p>';
}
if ( bp_is_active( 'messages' ) ) {
$content .= '<h3>' . esc_html__( 'Messages', 'buddypress' ) . '</h3>';
$content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'In this section you should describe any personal data related to private messages.', 'buddypress' ) . '</p>';
$content .= '<p>' . $suggested_text . esc_html__( 'The content of private messages is visible only to the sender and the recipients of the message. With the exception of site administrators, who can read all private messages, private message content is never visible to other users or site visitors. Site administrators may delete the content of any message.', 'buddypress' ) . '</p>';
}
$content .= '<h3>' . esc_html__( 'Cookies', 'buddypress' ) . '</h3>';
$content .= '<p class="privacy-policy-tutorial">' . esc_html__( 'In this section you should describe the BuddyPress-specific cookies that your site collects. The suggested text describes the default cookies.', 'buddypress' ) . '</p>';
$content .= '<p>' . $suggested_text . esc_html__( 'We use a cookie to show success and failure messages to logged-in users, in response to certain actions, like joining a group. These cookies contain no personal data, and are deleted immediately after the next page load.', 'buddypress' ) . '</p>';
$content .= '<p>' . esc_html__( 'We use cookies on group, member, and activity directories to keep track of a user\'s browsing preferences. These preferences include the last-selected values of the sort and filter dropdowns, as well as pagination information. These cookies contain no personal data, and are deleted after 24 hours.', 'buddypress' ) . '</p>';
if ( bp_is_active( 'groups' ) ) {
$content .= '<p>' . esc_html__( 'When a logged-in user creates a new group, we use a number of cookies to keep track of the group creation process. These cookies contain no personal data, and are deleted either upon the successful creation of the group or after 24 hours.', 'buddypress' ) . '</p>';
}
$content .= '</div><!-- .wp-suggested-text -->';
wp_add_privacy_policy_content(
'BuddyPress',
wp_kses_post( wpautop( $content, false ) )
);
}
/** About *****************************************************************/
/**
* Output the BuddyPress Hello template.
*
* @since 1.7.0 Screen content.
* @since 3.0.0 Now outputs BuddyPress Hello template.
*/
public function about_screen() {
if ( 0 !== strpos( get_current_screen()->id, 'dashboard' ) || empty( $_GET['hello'] ) || $_GET['hello'] !== 'buddypress' ) {
return;
}
// Get BuddyPress stable version.
$version = self::display_version();
$version_slug = 'version-' . str_replace( '.', '-', $version );
?>
<div id="bp-hello-container">
<div id="plugin-information-scrollable" role="document">
<div id='plugin-information-title' class="with-banner">
<div class='vignette'></div>
<h1>
<?php printf(
/* translators: %s is the placeholder for the BuddyPress version number. */
esc_html__( 'BuddyPress %s', 'buddypress' ),
$version
); ?>
</h1>
</div>
<div id="plugin-information-tabs">
<a name="whats-new" href="#whats-new" class="current"><?php esc_html_e( 'What\'s new?', 'buddypress' ); ?></a>
<a name="changelog" href="#changelog" class="dynamic" data-slug="<?php echo esc_attr( $version_slug ); ?>" data-endpoint="https://codex.buddypress.org/wp-json/wp/v2/pages"><?php esc_html_e( 'Changelog', 'buddypress' ); ?></a>
<a name="get-involved" href="#get-involved" class="dynamic" data-slug="participate-and-contribute" data-endpoint="https://codex.buddypress.org/wp-json/wp/v2/pages"><?php esc_html_e( 'Get involved', 'buddypress' ); ?></a>
</div>
<div class="bp-hello-content">
<div id="dynamic-content"></div>
<div id="top-features">
<p>
<?php esc_html_e( 'Thanks for upgrading BuddyPress to 11.0.0.', 'buddypress' ); ?>
<?php esc_html_e( 'This new major version of your site’s community engine introduces around 50 changes mostly acting under the hood to improve performance, consistency and the stability of the plugin.', 'buddypress' ); ?>
<?php esc_html_e( 'Here are five important changes we would like to highlight:', 'buddypress' ); ?>
</p>
<ol>
<li>
<?php
printf(
/* Translators: %s is a the link to the .webp support developer note. */
esc_html__( 'You may now use %s images for your profile and cover images (requires WordPress 5.8 or newer).', 'buddypress' ),
sprintf(
'<a href="%s">.webp</a>',
esc_url( 'https://bpdevel.wordpress.com/2022/11/24/webp-support-is-arriving-in-buddypress-11-0-0/' )
)
);
?>
</li>
<li>
<?php
printf(
/* Translators: %s is a the link to the community assets restricting filter developer note. */
esc_html__( 'A %s was introduced to only load BuddyPress JavaScript & CSS assets on BuddyPress-generated pages.', 'buddypress' ),
sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( 'https://bpdevel.wordpress.com/2022/11/21/buddypress-will-soon-only-load-its-javascript-and-style-assets-into-the-community-area-of-your-site/' ),
esc_html__( 'new filter', 'buddypress' )
)
);
?>
</li>
<li>
<?php
printf(
/* Translators: %s is a the link to the deprecated code developer note. */
esc_html__( 'The way BuddyPress loads its %s has been improved.', 'buddypress' ),
sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( 'https://bpdevel.wordpress.com/2022/11/20/the-way-buddypress-loads-deprecated-code-will-change-in-version-11-0-0/' ),
esc_html__( 'deprecated code', 'buddypress' )
)
);
?>
</li>
<li>
<?php
printf(
/* Translators: %s is a the link to the activity loop new arguments developer note. */
esc_html__( 'Advanced users or developers can now extend the Activity loop to %s.', 'buddypress' ),
sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( 'https://bpdevel.wordpress.com/2022/12/01/bp-11-fetch-activities-for-or-excluding-a-group-of-users/' ),
esc_html__( 'include or exclude a list of users', 'buddypress' )
)
);
?>
</li>
<li>
<?php
printf(
/* Translators: %s is a the link to the xProfile fields loop edited argument developer note. */
esc_html__( 'Advanced users or developers can now build custom xProfile loops %s.', 'buddypress' ),
sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( 'https://bpdevel.wordpress.com/2022/12/06/bp-11-bp_has_profile-now-accepts-an-array-of-profile-group-ids/' ),
esc_html__( 'including a specific set of profile field groups', 'buddypress' )
)
);
?>
</li>
</ol>
<hr class="bp-hello-divider"/>
<h2><?php esc_html_e( '11.0.0 also marks the beginning of a transitional year for BuddyPress: get ready for great features and changes.', 'buddypress' ); ?></h2>
<p>
<?php
printf(
/* translators: %s is the placeholder for the link to the BuddyPress Add-ons administration page. */
esc_html__( 'In 10.0.0, we’ve introduced a %s to easily find BuddyPress Add-ons maintained by the BuddyPress Core Team. Check this list often as we will soon publish the following add-ons:', 'buddypress' ),
sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( add_query_arg( 'tab', 'bp-add-ons', network_admin_url( 'plugin-install.php' ) ) ),
esc_html__( 'new area in the Plugin Administration screen', 'buddypress' )
)
);
?>
</p>
<ol>
<li><?php esc_html_e( '"THE" long-awaited feature: Community Media Attachments.', 'buddypress' ); ?></li>
<li><?php esc_html_e( 'A revolutionary Block-based Activity Post Form to standardize the way to extend activity updates with richer & more engaging content.', 'buddypress' ); ?></li>
</ol>
<p>
<?php
printf(
/* translators: %s is the placeholder for the link to the BP Rewrites' w.org plugin page. */
esc_html__( 'An example about this new way to keep moving forward is the %s Add-on.', 'buddypress' ),
sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( 'https://wordpress.org/plugins/bp-rewrites/' ),
esc_html__( 'BP Rewrites', 'buddypress' )
)
);
?>
<?php esc_html_e( 'You can already test this breaking change, which uses the WordPress way to parse URLs (thanks to the WP Rewrites API), and report issues to us or to the third-party plugin authors.', 'buddypress' ); ?>
<?php esc_html_e( 'Once BP Rewrites are merged into BuddyPress 12.0.0 (our next major release), we’ll make sure to build a backward-compatibility add-on so that you can still use plugins that do not work with "BP Rewrites".', 'buddypress' ); ?>
</p>
<p>
<?php
printf(
/* Translators: %s is a Passport control emoji. */
esc_html__( 'By the way, the latest version of BP Rewrites also includes a feature to restrict the community area to your site members only %s.', 'buddypress' ),
wp_staticize_emoji( '🛂' )
);
?>
</p>
<hr class="bp-hello-divider"/>
<figure class="bp-hello-aligncenter">
<div class="dashicons dashicons-buddicons-buddypress-logo big"></div>
</figure>
<hr class="bp-hello-divider"/>
<h2><?php echo esc_html( _x( 'Your feedback', 'screen heading', 'buddypress' ) ); ?></h2>
<p>
<?php esc_html_e( 'How are you using BuddyPress? Receiving your feedback and suggestions for future versions of BuddyPress genuinely motivates and encourages our contributors.', 'buddypress' ); ?>
<?php
printf(
/* translators: %s is the placeholder for the link to BuddyPress support forums. */
esc_html__( 'Please %s about this version of BuddyPress on our website.', 'buddypress' ),
sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( 'https://buddypress.org/support/' ),
esc_html__( 'share your feedback', 'buddypress' )
)
);
?>
</p>
<p>
<?php
printf(
/* Translators: %s is a hugging face emoji. */
esc_html__( 'Many thanks to you for trusting BuddyPress to power your community site %s', 'buddypress' ),
wp_staticize_emoji( '🤗' )
);
?>
</p>
<br /><br />
</div>
</div>
</div>
<div id="plugin-information-footer">
<div class="bp-hello-social-cta">
<p>
<?php
printf(
/* translators: 1: heart dashicons. 2: BP Credits screen url. 3: number of BuddyPress contributors to this version. */
_n( 'Built with %1$s by <a href="%2$s">%3$d volunteer</a>.', 'Built with %1$s by <a href="%2$s">%3$d volunteers</a>.', 34, 'buddypress' ),
'<span class="dashicons dashicons-heart"></span>',
esc_url( bp_get_admin_url( 'admin.php?page=bp-credits' ) ),
number_format_i18n( 34 )
);
?>
</p>
</div>
<div class="bp-hello-social-links">
<ul class="bp-hello-social">
<li>
<?php
printf(
'<a class="twitter bp-tooltip" data-bp-tooltip="%1$s" href="%2$s"><span class="screen-reader-text">%3$s</span></a>',
esc_attr__( 'Follow BuddyPress on Twitter', 'buddypress' ),
esc_url( 'https://twitter.com/buddypress' ),
esc_html__( 'Follow BuddyPress on Twitter', 'buddypress' )
);
?>
</li>
<li>
<?php
printf(
'<a class="support bp-tooltip" data-bp-tooltip="%1$s" href="%2$s"><span class="screen-reader-text">%3$s</span></a>',
esc_attr__( 'Visit the Support Forums', 'buddypress' ),
esc_url( 'https://buddypress.org/support/' ),
esc_html__( 'Visit the Support Forums', 'buddypress' )
);
?>
</li>
</ul>
</div>
</div>
</div>
<?php
}
/**
* Output the credits screen.
*
* Hardcoding this in here is pretty janky. It's fine for now, but we'll
* want to leverage api.wordpress.org eventually.
*
* @since 1.7.0
*/
public function credits_screen() {
bp_core_admin_tabbed_screen_header( __( 'BuddyPress Settings', 'buddypress' ), __( 'Credits', 'buddypress' ) );