BP_Group_Extension::setup_edit_hooks()
Hook this extension’s Edit panel into BuddyPress, if necessary.
Description
Source
File: bp-groups/classes/class-bp-group-extension.php
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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 | protected function setup_edit_hooks() { // Bail if not in a group. if ( ! bp_is_group() ) { return ; } // Bail if not an edit screen. if ( ! $this ->is_screen_enabled( 'edit' ) || ! bp_is_item_admin() ) { return ; } $screen = $this ->screens[ 'edit' ]; $position = isset( $screen [ 'position' ] ) ? (int) $screen [ 'position' ] : 10; $position += 40; $current_group = groups_get_current_group(); $admin_link = trailingslashit( bp_get_group_permalink( $current_group ) . 'admin' ); $subnav_args = array ( 'name' => $screen [ 'name' ], 'slug' => $screen [ 'slug' ], 'parent_slug' => $current_group ->slug . '_manage' , 'parent_url' => $admin_link , 'user_has_access' => bp_is_item_admin(), 'position' => $position , 'screen_function' => 'groups_screen_group_admin' , ); // Should we add a menu to the Group's WP Admin Bar. if ( ! empty ( $screen [ 'show_in_admin_bar' ] ) ) { $subnav_args [ 'show_in_admin_bar' ] = true; } // Add the tab to the manage navigation. bp_core_new_subnav_item( $subnav_args , 'groups' ); // Catch the edit screen and forward it to the plugin template. if ( bp_is_groups_component() && bp_is_current_action( 'admin' ) && bp_is_action_variable( $screen [ 'slug' ], 0 ) ) { $this ->call_edit_screen_save( $this ->group_id ); add_action( 'groups_custom_edit_steps' , array ( & $this , 'call_edit_screen' ) ); // Determine the proper template and save for later // loading. if ( '' !== bp_locate_template( array ( 'groups/single/home.php' ), false ) ) { $this ->edit_screen_template = '/groups/single/home' ; } else { add_action( 'bp_template_content_header' , function () { echo '<ul class="content-header-nav">' ; bp_group_admin_tabs(); echo '</ul>' ; } ); add_action( 'bp_template_content' , array ( & $this , 'call_edit_screen' ) ); $this ->edit_screen_template = '/groups/single/plugins' ; } // We load the template at bp_screens, to give all // extensions a chance to load. add_action( 'bp_screens' , array ( $this , 'call_edit_screen_template_loader' ) ); } } |
Changelog
Version | Description |
---|---|
BuddyPress 1.8.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.