<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][9996] trunk/src/bp-core/bp-core-buddybar.php: Remove extract() from bp_core_new_nav_item.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/9996">9996</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/9996","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dcavins</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-07-05 16:57:22 +0000 (Sun, 05 Jul 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Remove extract() from bp_core_new_nav_item.
Remove `extract()` and other formatting clean up
in `bp_core_new_nav_item()`,
`bp_core_new_nav_default()` and
`bp_core_sort_nav_items()`. Bracket if statements,
normalize white space.
See <a href="http://buddypress.trac.wordpress.org/ticket/6503">#6503</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcorebpcorebuddybarphp">trunk/src/bp-core/bp-core-buddybar.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpcorebpcorebuddybarphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/bp-core-buddybar.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-buddybar.php 2015-07-04 22:23:19 UTC (rev 9995)
+++ trunk/src/bp-core/bp-core-buddybar.php 2015-07-05 16:57:22 UTC (rev 9996)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,28 +46,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $r = wp_parse_args( $args, $defaults );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- extract( $r, EXTR_SKIP );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If we don't have the required info we need, don't create this subnav item
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $name ) || empty( $slug ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $r['name'] ) || empty( $r['slug'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If this is for site admins only and the user is not one, don't create the subnav item
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $site_admin_only ) && !bp_current_user_can( 'bp_moderate' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $item_css_id ) )
- $item_css_id = $slug;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $r['item_css_id'] ) ) {
+ $r['item_css_id'] = $r['slug'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $bp->bp_nav[$slug] = array(
- 'name' => $name,
- 'slug' => $slug,
- 'link' => trailingslashit( bp_loggedin_user_domain() . $slug ),
- 'css_id' => $item_css_id,
- 'show_for_displayed_user' => $show_for_displayed_user,
- 'position' => $position,
- 'screen_function' => &$screen_function,
- 'default_subnav_slug' => $default_subnav_slug
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $bp->bp_nav[$r['slug']] = array(
+ 'name' => $r['name'],
+ 'slug' => $r['slug'],
+ 'link' => trailingslashit( bp_loggedin_user_domain() . $r['slug'] ),
+ 'css_id' => $r['item_css_id'],
+ 'show_for_displayed_user' => $r['show_for_displayed_user'],
+ 'position' => $r['position'],
+ 'screen_function' => &$r['screen_function'],
+ 'default_subnav_slug' => $r['default_subnav_slug']
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -75,33 +77,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * the logged in user is not the displayed user
</span><span class="cx" style="display: block; padding: 0 10px"> * looking at their own profile, don't create the nav item.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $show_for_displayed_user ) && !bp_user_has_access() )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $r['show_for_displayed_user'] ) && ! bp_user_has_access() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * If the nav item is visible, we are not viewing a user, and this is a root
</span><span class="cx" style="display: block; padding: 0 10px"> * component, don't attach the default subnav function so we can display a
</span><span class="cx" style="display: block; padding: 0 10px"> * directory or something else.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ( -1 != $position ) && bp_is_root_component( $slug ) && !bp_displayed_user_id() )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ( -1 != $r['position'] ) && bp_is_root_component( $r['slug'] ) && ! bp_displayed_user_id() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Look for current component
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( bp_is_current_component( $slug ) || bp_is_current_item( $slug ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( bp_is_current_component( $r['slug'] ) || bp_is_current_item( $r['slug'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // The requested URL has explicitly included the default subnav
</span><span class="cx" style="display: block; padding: 0 10px"> // (eg: http://example.com/members/membername/activity/just-me/)
</span><span class="cx" style="display: block; padding: 0 10px"> // The canonical version will not contain this subnav slug.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $default_subnav_slug ) && bp_is_current_action( $default_subnav_slug ) && !bp_action_variable( 0 ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $r['default_subnav_slug'] ) && bp_is_current_action( $r['default_subnav_slug'] ) && !bp_action_variable( 0 ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> unset( $bp->canonical_stack['action'] );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! bp_current_action() ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add our screen hook if screen function is callable
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_callable( $screen_function ) ) {
- add_action( 'bp_screens', $screen_function, 3 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_callable( $r['screen_function'] ) ) {
+ add_action( 'bp_screens', $r['screen_function'], 3 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $default_subnav_slug ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $r['default_subnav_slug'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the default component subnav item.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -112,7 +116,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * to select when clicked.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $r Parsed arguments for the nav item.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $bp->current_action = apply_filters( 'bp_default_component_subnav', $r['default_subnav_slug'], $r );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -148,43 +152,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $r = wp_parse_args( $args, $defaults );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- extract( $r, EXTR_SKIP );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $function = $bp->bp_nav[$parent_slug]['screen_function'] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $function = $bp->bp_nav[$r['parent_slug']]['screen_function'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // Remove our screen hook if screen function is callable
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_callable( $function ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> remove_action( 'bp_screens', $function, 3 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $bp->bp_nav[$parent_slug]['screen_function'] = &$screen_function;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $bp->bp_nav[$r['parent_slug']]['screen_function'] = &$r['screen_function'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( bp_is_current_component( $parent_slug ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( bp_is_current_component( $r['parent_slug'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // The only way to tell whether to set the subnav is to peek at the unfiltered_uri
</span><span class="cx" style="display: block; padding: 0 10px"> // Find the component
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $component_uri_key = array_search( $parent_slug, $bp->unfiltered_uri );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $component_uri_key = array_search( $r['parent_slug'], $bp->unfiltered_uri );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false !== $component_uri_key ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $bp->unfiltered_uri[$component_uri_key + 1] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $bp->unfiltered_uri[$component_uri_key + 1] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $unfiltered_action = $bp->unfiltered_uri[$component_uri_key + 1];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No subnav item has been requested in the URL, so set a new nav default
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $unfiltered_action ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !bp_is_current_action( $subnav_slug ) ) {
- if ( is_callable( $screen_function ) ) {
- add_action( 'bp_screens', $screen_function, 3 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! bp_is_current_action( $r['subnav_slug'] ) ) {
+ if ( is_callable( $r['screen_function'] ) ) {
+ add_action( 'bp_screens', $r['screen_function'], 3 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $bp->current_action = $subnav_slug;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $bp->current_action = $r['subnav_slug'];
</ins><span class="cx" style="display: block; padding: 0 10px"> unset( $bp->canonical_stack['action'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // The URL is explicitly requesting the new subnav item, but should be
</span><span class="cx" style="display: block; padding: 0 10px"> // directed to the canonical URL
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( $unfiltered_action == $subnav_slug ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( $unfiltered_action == $r['subnav_slug'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> unset( $bp->canonical_stack['action'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // In all other cases (including the case where the original subnav item
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -209,19 +212,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function bp_core_sort_nav_items() {
</span><span class="cx" style="display: block; padding: 0 10px"> $bp = buddypress();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $bp->bp_nav ) || ! is_array( $bp->bp_nav ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $temp = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $bp->bp_nav as $slug => $nav_item ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $temp[$nav_item['position']]) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $temp[$nav_item['position']] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $temp[$nav_item['position']] = $nav_item;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> // increase numbers here to fit new items in.
</span><span class="cx" style="display: block; padding: 0 10px"> do {
</span><span class="cx" style="display: block; padding: 0 10px"> $nav_item['position']++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } while ( !empty( $temp[$nav_item['position']] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } while ( ! empty( $temp[$nav_item['position']] ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $temp[$nav_item['position']] = $nav_item;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -278,42 +282,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- extract( $r, EXTR_SKIP );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // If we don't have the required info we need, don't create this subnav item
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $name ) || empty( $slug ) || empty( $parent_slug ) || empty( $parent_url ) || empty( $screen_function ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $r['name'] ) || empty( $r['slug'] ) || empty( $r['parent_slug'] ) || empty( $r['parent_url'] ) || empty( $r['screen_function'] ) )
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Link was not forced, so create one
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $link ) ) {
- $link = trailingslashit( $parent_url . $slug );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $r['link'] ) ) {
+ $r['link'] = trailingslashit( $r['parent_url'] . $r['slug'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If this sub item is the default for its parent, skip the slug
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) && $slug == $bp->bp_nav[$parent_slug]['default_subnav_slug'] ) {
- $link = trailingslashit( $parent_url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $bp->bp_nav[$r['parent_slug']]['default_subnav_slug'] ) && $r['slug'] == $bp->bp_nav[$r['parent_slug']]['default_subnav_slug'] ) {
+ $r['link'] = trailingslashit( $r['parent_url'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If this is for site admins only and the user is not one, don't create the subnav item
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !empty( $site_admin_only ) && !bp_current_user_can( 'bp_moderate' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $item_css_id ) )
- $item_css_id = $slug;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $r['item_css_id'] ) ) {
+ $r['item_css_id'] = $r['slug'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $subnav_item = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'name' => $name,
- 'link' => $link,
- 'slug' => $slug,
- 'css_id' => $item_css_id,
- 'position' => $position,
- 'user_has_access' => $user_has_access,
- 'no_access_url' => $no_access_url,
- 'screen_function' => &$screen_function,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'name' => $r['name'],
+ 'link' => $r['link'],
+ 'slug' => $r['slug'],
+ 'css_id' => $r['item_css_id'],
+ 'position' => $r['position'],
+ 'user_has_access' => $r['user_has_access'],
+ 'no_access_url' => $r['no_access_url'],
+ 'screen_function' => &$r['screen_function'],
</ins><span class="cx" style="display: block; padding: 0 10px"> 'show_in_admin_bar' => (bool) $r['show_in_admin_bar'],
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $bp->bp_options_nav[$parent_slug][$slug] = $subnav_item;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $bp->bp_options_nav[$r['parent_slug']][$r['slug']] = $subnav_item;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The last step is to hook the screen function for the added subnav item. But this only
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -333,11 +337,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If we *don't* meet condition (1), return
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! bp_is_current_component( $parent_slug ) && ! bp_is_current_item( $parent_slug ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! bp_is_current_component( $r['parent_slug'] ) && ! bp_is_current_item( $r['parent_slug'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If we *do* meet condition (2), then the added subnav item is currently being requested
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ( bp_current_action() && bp_is_current_action( $slug ) ) || ( bp_is_user() && ! bp_current_action() && ( $screen_function == $bp->bp_nav[$parent_slug]['screen_function'] ) ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ( bp_current_action() && bp_is_current_action( $r['slug'] ) ) || ( bp_is_user() && ! bp_current_action() && ( $r['screen_function'] == $bp->bp_nav[$parent_slug]['screen_function'] ) ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $hooked = bp_core_maybe_hook_new_subnav_screen_function( $subnav_item );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>