[buddypress-trac] [BuddyPress Trac] #6507: Allow Ajax sub nav tab loading
buddypress-trac
noreply at wordpress.org
Mon Jun 15 21:24:43 UTC 2015
#6507: Allow Ajax sub nav tab loading
---------------------------------+-----------------------------
Reporter: CodeMonkeyBanana | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Component - Any/All | Version:
Severity: normal | Keywords:
---------------------------------+-----------------------------
Hi,
With ajax subnav tab loading it needs to work for logged in and logged out
users alike so I made function that will work for both and check if user
has access to view tab.
{{{
function bp_legacy_theme_tab_template_loader() {
global $bp;
// Bail if not a POST action
if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
exit( '1' );
// exit if full path not specified
if (empty($_POST['component']) || empty($_POST['page']) ||
empty($_POST['tab'])) {
if ( SCRIPT_DEBUG ) {
exit( 'missing path component' );
} else {
exit( '1' );
}
}
// create full path
$component = sanitize_title( $_POST['component'] );
$page = sanitize_title( $_POST['page'] );
$tab = sanitize_title( $_POST['tab'] );
$path = $component.'/single/'.$page.'/'.$tab;
if ($bp->bp_options_nav[$page][$tab]['user_has_access'] === true)
{
// they are allowed to view it so return template
bp_get_template_part( $path );
exit( '0' );
}
else
{
if(SCRIPT_DEBUG) {
exit( 'insufficient access' );
}else {
exit( '1' );
}
}
}
}}}
I haven't included javascript as I am working on theme with custom menu
that works a bit different but just needs a small bit of code added to
when it checks for no-ajax class to work although that would probably be
confusing to read. I can post it if needed once I finish this theme.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6507>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list