Skip to content

Instantly share code, notes, and snippets.

@boonebgorges
Created May 6, 2016 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boonebgorges/6025ad2e0f7ab8b42b26c965773d8805 to your computer and use it in GitHub Desktop.
Save boonebgorges/6025ad2e0f7ab8b42b26c965773d8805 to your computer and use it in GitHub Desktop.
backward compatibility testing for bp_nav and bp_options_nav
<?php
function nav_backcompat_test() {
$bp = buddypress();
// Groups.
if ( bp_is_group() ) {
$slug = bp_get_current_group_slug();
// Get a property.
var_dump( $bp->bp_options_nav[ $slug ]['members']['name'] );
// Set a property.
$bp->bp_options_nav[ $slug ]['members']['name'] = 'Modified Members';
// Unset a nav item. @todo not working
unset( $bp->bp_options_nav[ $slug ]['admin'] );
// isset
var_dump( isset( $bp->bp_options_nav[ $slug ] ) );
var_dump( isset( $bp->bp_options_nav[ $slug ]['members'] ) );
}
// Users.
if ( bp_is_user() ) {
// bp_nav
// Get a property.
var_dump( $bp->bp_nav['profile']['name'] );
// Set a property.
$bp->bp_nav['profile']['name'] = 'Modified Profile';
// Unset a nav item.
unset( $bp->bp_nav['friends'] );
// isset
var_dump( isset( $bp->bp_nav['profile'] ) );
var_dump( isset( $bp->bp_nav['profile']['name'] ) );
// bp_options_nav
// Get a property.
var_dump( $bp->bp_options_nav['activity']['mentions']['name'] );
// Set a property.
$bp->bp_options_nav['activity']['mentions']['name'] = 'Modified Mentions';
// Unset a subnav item.
unset( $bp->bp_options_nav['activity']['friends'] );
// isset
var_dump( isset( $bp->bp_options_nav['activity'] ) );
var_dump( isset( $bp->bp_options_nav['activity']['mentions'] ) );
var_dump( isset( $bp->bp_options_nav['activity']['mentions']['name'] ) );
}
}
add_action( 'bp_actions', 'nav_backcompat_test' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment