Guest User

Untitled

a guest
Jun 11th, 2024
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: BuddyPress Group Test
  4. Plugin URI: https://zombo.com
  5. Description: Test adding group tab
  6. Version: 1.0
  7. Author: Kenny Jackson
  8. Author URI: https://kkjdroid.github.io
  9. License: AGPLv3
  10. */
  11.  
  12. add_action('bp_actions', function()
  13. {
  14. if(bp_is_group())
  15. {
  16. $group_slug = bp_get_current_group_slug();
  17. bp_core_remove_subnav_item("{$group_slug}_manage", 'group-avatar', 'groups');
  18.  
  19. }
  20. else
  21. {
  22. bp_core_remove_subnav_item('profile', 'change-avatar', 'members');
  23. }
  24. }, 8);
  25.  
  26. add_action('bp_setup_nav', function()
  27. {
  28. $bp = buddypress();
  29. if(bp_is_group())
  30. {
  31.  
  32. $group_slug = bp_get_current_group_slug();
  33. $args =
  34. [
  35. 'name' => 'Change Group Photo',
  36. 'slug' => 'change-group-photo',
  37. 'rewrite_id' => 'bp_group_manage_change_group_photo',
  38. 'parent_slug' => "{$group_slug}_manage",
  39. 'position' => 81,
  40. 'user_has_access' => true,
  41. 'show_in_admin_bar' => true,
  42. 'no_access_url' => bp_get_group_permalink($group_slug),
  43. 'screen_function' => 'groups_screen_group_admin'
  44. ];
  45. $tab = bp_core_new_subnav_item($args, 'groups');
  46. }
  47. else
  48. {
  49. $tab = bp_core_new_subnav_item(
  50. [
  51. 'name' => 'Change Profile Photo',
  52. 'slug' => 'change-profile-photo',
  53. 'parent_slug' => $bp->profile->slug,
  54. 'position' => 30,
  55. 'user_has_access' => true,
  56. 'screen_function' => function()
  57. {
  58. bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
  59. add_action('bp_template_content', function()
  60. {
  61. echo '<h1>USER</h1>';
  62. });
  63. },
  64. ]);
  65. }
  66. }, 100);
  67.  
  68. add_action('bp_screens', function()
  69. {
  70. if ( 'change-group-photo' != bp_get_group_current_admin_tab() ) {
  71. return false;
  72. }
  73. bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'groups/single/plugins' ) );
  74. add_action('bp_after_group_home_content', function()
  75. {
  76. echo '<h1>GROUP</h1>';
  77. });
  78. });
Advertisement
Add Comment
Please, Sign In to add comment