Opened 13 years ago
Closed 13 years ago
#4586 closed defect (bug) (fixed)
Problem with registering multiple group extensions and group tabs
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 1.8 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Groups | Keywords: | |
| Cc: | mercijavier@…, shiftyRZA |
Description
bp_register_group_extension appears to stop registering tabs after the current one is selected in "Admin" under Groups.
Test case:
- Enable plugin
- Navigate to a group page, "Admin > Test 3"
- Click "Test 2", then "Test"
Expected Result:
All tabs should continue to display.
Actual Result:
Tabs disappear as you click backwards through "Test 3" > "Test 2" > "Test"
Plugin Test Code
<?php
/**
Plugin Name: BuddyPress Groups Test Tab
Description: Test case for a bug. When using the Admin subnav, select "Test" and "Test 2" will disappear
Version: 0.6
Author: Tyler Mulligan
**/
function bptt_init() {
class Groups_Test_Tab extends BP_Group_Extension {
var $visibility = 'public'; // 'public' will show your extension to non-group members, 'private' means you have to be a member of the group to view your extension.
var $enable_create_step = false; // If your extension does not need a creation step, set this to false
var $enable_nav_item = true; // If your extension does not need a navigation item, set this to false
var $enable_edit_item = true; // If your extension does not need an edit screen, set this to false
function Groups_Test_Tab() {
$this->name = "Test";
$this->slug = "test";
$this->create_step_position = 21;
$this->nav_item_position = 31;
}
function display() {
echo "test";
}
function edit_screen() {
echo "test";
}
}
class Groups_Test_Tab2 extends BP_Group_Extension {
var $visibility = 'public'; // 'public' will show your extension to non-group members, 'private' means you have to be a member of the group to view your extension.
var $enable_create_step = false; // If your extension does not need a creation step, set this to false
var $enable_nav_item = true; // If your extension does not need a navigation item, set this to false
var $enable_edit_item = true; // If your extension does not need an edit screen, set this to false
function Groups_Test_Tab2() {
$this->name = "Test 2";
$this->slug = "test2";
$this->create_step_position = 22;
$this->nav_item_position = 32;
}
function display() {
echo "test 2";
}
function edit_screen() {
echo "Test 2";
}
}
class Groups_Test_Tab3 extends BP_Group_Extension {
var $visibility = 'public'; // 'public' will show your extension to non-group members, 'private' means you have to be a member of the group to view your extension.
var $enable_create_step = false; // If your extension does not need a creation step, set this to false
var $enable_nav_item = true; // If your extension does not need a navigation item, set this to false
var $enable_edit_item = true; // If your extension does not need an edit screen, set this to false
function Groups_Test_Tab3() {
$this->name = "Test 3";
$this->slug = "test3";
$this->create_step_position = 23;
$this->nav_item_position = 33;
}
function display() {
echo "test 3";
}
function edit_screen() {
echo "Test 3";
}
}
bp_register_group_extension( 'Groups_Test_Tab' );
bp_register_group_extension( 'Groups_Test_Tab2' );
bp_register_group_extension( 'Groups_Test_Tab3' );
}
add_action( 'bp_include', 'bptt_init' );
?>
$this->create_step_position = 22;
$this->nav_item_position = 32;
}
function display() {
echo "test 3";
}
function edit_screen() {
echo "Test 3";
}
}
bp_register_group_extension( 'Groups_Test_Tab' );
bp_register_group_extension( 'Groups_Test_Tab2' );
bp_register_group_extension( 'Groups_Test_Tab3' );
}
add_action( 'bp_include', 'bptt_init' );
?>
Attachments (3)
Change History (11)
#1
in reply to:
↑ description
@
13 years ago
#2
@
13 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 1.6.2
- Summary changed from stops loading tabs after to Problem with registering multiple group extensions and group tabs
I tested this briefly in both 1.7-bleeding and 1.6.1.
In 1.7, your code works the way it is supposed to; in 1.6.1, I can duplicate your problem.
#4
@
13 years ago
- Resolution set to fixed
- Status changed from new to closed
Confirmed this works correctly in 1.7. Closing as fixed.
#5
@
13 years ago
- Cc shiftyRZA added
- Resolution fixed deleted
- Status changed from closed to reopened
- Version changed from 1.6.1 to 1.7
After trying to solve a forum question, I discovered this ticket. See http://buddypress.org/support/topic/creating-more-than-one-editable-extra-group-tab-page/
The test code above doesn't work as expected on my site (WP 3.5.1, BP 1.7.2). The tabs after the current one, including admin tabs of other plugins, disappear.
#6
@
13 years ago
- Version 1.7 deleted
"Version" refers to the version where the problem first popped up - please don't change it to a newer version. It so happens that this bug has been around pretty much forever.
As of 1.7, it only occurs in the context of legacy themes - those that do not use theme compatibility. So, for those who were unable to reproduce, make sure you're testing using bp-default or a derivative.
The cause: Just to make it clearer, I'll explain in terms of the refactored BP_Group_Extension. When you're on an Edit panel, the setup_edit_hooks() method is called https://buddypress.trac.wordpress.org/browser/trunk/bp-groups/bp-groups-classes.php#L2016. This method does roughly three things: adds the admin tabs (2034), hooks the admin tab content if necessary (2050), and then loads the template (2048, 2052). When using a legacy theme, calling bp_core_load_template() will include the template file, and then exit(). That means that group extensions will load, in order, until BP reaches the "current" admin tab, at which point loading stops. (
It doesn't happen on theme compat because template loading is delayed until template_include. The fix for legacy mode is to delay template loading in the same way. Basically, because setup_edit_hooks() is called at bp_actions:8, we need to load the template sometime after bp_actions:8. bp_screens seems like the appropriate place. Fix coming momentarily.
Screwed up pasting test code, fixed below: