<!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>[14283] sites/trunk/buddypress.org/public_html/wp-content/plugins/buddypress-org/toolbar.php: BuddyPress.org: simplify admin toolbar</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 { white-space: pre-line; 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://meta.trac.wordpress.org/changeset/14283">14283</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/14283","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>johnjamesjacoby</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-12-16 19:56:10 +0000 (Mon, 16 Dec 2024)</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'>BuddyPress.org: simplify admin toolbar
See: https://buddypress.trac.wordpress.org/ticket/9262</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkbuddypressorgpublic_htmlwpcontentpluginsbuddypressorgtoolbarphp">sites/trunk/buddypress.org/public_html/wp-content/plugins/buddypress-org/toolbar.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkbuddypressorgpublic_htmlwpcontentpluginsbuddypressorgtoolbarphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/buddypress.org/public_html/wp-content/plugins/buddypress-org/toolbar.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/buddypress.org/public_html/wp-content/plugins/buddypress-org/toolbar.php 2024-12-16 19:55:06 UTC (rev 14282)
+++ sites/trunk/buddypress.org/public_html/wp-content/plugins/buddypress-org/toolbar.php 2024-12-16 19:56:10 UTC (rev 14283)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,16 +7,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.0.1
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function bporg_toolbar_tweaks() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 );
- remove_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
- remove_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
- remove_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 );
- remove_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 );
- remove_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 70 );
- remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // WordPress Menus
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_site_menu', 40 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 70 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 9991 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_recovery_mode_menu', 9992 );
+ remove_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 9999 );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // BuddyPress Menus
</span><span class="cx" style="display: block; padding: 0 10px"> remove_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_my_account_menu', 4 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // WordPress.org Profiles site specific removals
+ if ( 'profiles.wordpress.org' === $_SERVER['HTTP_HOST'] ) {
+ remove_action( 'admin_bar_menu', 'bp_groups_group_admin_menu', 99 );
+ remove_action( 'admin_bar_menu', 'bp_admin_bar_my_account_root', 100 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'add_admin_bar_menus', 'bporg_toolbar_tweaks', 11 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -27,6 +40,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function bporg_remove_about_pages( $wp_admin_bar ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // About page links
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->remove_menu( 'bp-about' );
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->remove_menu( 'bbp-about' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,6 +48,47 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_bar_menu', 'bporg_remove_about_pages', 99 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Remove the BuddyPress XProfile
+ * @author johnjamesjacoby
+ * @since 1.1.0
+ */
+function bporg_remove_my_account_items( $wp_admin_bar ) {
+ $wp_admin_bar->remove_menu( 'my-account-blogs' );
+ $wp_admin_bar->remove_menu( 'my-account-xprofile-edit' );
+ $wp_admin_bar->remove_menu( 'my-account-xprofile-change-avatar' );
+}
+add_action( 'admin_bar_menu', 'bporg_remove_my_account_items', 99 );
+
+/**
+ * Prevent the BuddyPress Component admin-bar nav items from being added.
+ *
+ * This function adds filters to return false inside of the
+ * BP_Component::setup_admin_bar() methods.
+ *
+ * WordPress.org & BuddyPress.org implement their own user profile flow. The
+ * relevant components all have their
+ *
+ * @author johnjamesjacoby
+ * @since 1.1.0
+ */
+function bporg_remove_component_menu_items() {
+
+ // BuddyPress
+ $components = bp_core_get_active_components();
+
+ // bbPress
+ if ( ! array_search( 'forums', $components, true ) ) {
+ array_push( $components, 'forums' );
+ }
+
+ // Filter admin-nav for all components
+ foreach ( $components as $component ) {
+ add_filter( 'bp_' . $component . '_admin_nav', '__return_false' );
+ }
+}
+add_action( 'bp_init', 'bporg_remove_component_menu_items', 99 );
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Add a new main top-left menu with links for each project.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @todo GlotPress/BackPress
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -57,7 +113,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'parent' => 'wp-logo',
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'wordpress',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => __( 'WordPress.org' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'href' => 'https://wordpress.org',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'href' => 'https://wordpress.org',
</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"> // Add "About WordPress" link
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -70,26 +126,26 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add codex link
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'wordpress',
- 'id' => 'wp-documentation',
- 'title' => __('Documentation'),
- 'href' => 'https://codex.wordpress.org/',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'wordpress',
+ 'id' => 'wp-documentation',
+ 'title' => __( 'Documentation' ),
+ 'href' => 'https://codex.wordpress.org/',
</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"> // Add forums link
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'wordpress',
- 'id' => 'wp-support-forums',
- 'title' => __('Support Forums'),
- 'href' => 'https://wordpress.org/support/',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'wordpress',
+ 'id' => 'wp-support-forums',
+ 'title' => __( 'Support Forums' ),
+ 'href' => 'https://wordpress.org/support/',
</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"> // Add feedback link
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'wordpress',
- 'id' => 'wp-feedback',
- 'title' => __('Feedback'),
- 'href' => 'https://wordpress.org/support/forum/requests-and-feedback',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'wordpress',
+ 'id' => 'wp-feedback',
+ 'title' => __( 'Feedback' ),
+ 'href' => 'https://wordpress.org/support/forum/requests-and-feedback',
</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"> /** WordPress Developer **/
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -122,7 +178,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'parent' => 'wp-logo',
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'bbpress',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => __( 'bbPress.org' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'href' => 'https://bbpress.org',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'href' => 'https://bbpress.org',
</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"> // Add "About bbPress" link
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -135,26 +191,26 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add codex link
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'bbpress',
- 'id' => 'bbp-documentation',
- 'title' => __( 'Documentation' ),
- 'href' => 'https://codex.bbpress.org/',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'bbpress',
+ 'id' => 'bbp-documentation',
+ 'title' => __( 'Documentation' ),
+ 'href' => 'https://codex.bbpress.org/',
</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"> // Add forums link
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'bbpress',
- 'id' => 'bbp-support-forums',
- 'title' => __( 'Support Forums' ),
- 'href' => __( 'https://bbpress.org/forums/' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'bbpress',
+ 'id' => 'bbp-support-forums',
+ 'title' => __( 'Support Forums' ),
+ 'href' => __( 'https://bbpress.org/forums/' ),
</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"> // Add feedback link
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'bbpress',
- 'id' => 'bbp-feedback',
- 'title' => __( 'Feedback' ),
- 'href' => 'https://bbpress.org/forums/forum/requests-and-feedback',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'bbpress',
+ 'id' => 'bbp-feedback',
+ 'title' => __( 'Feedback' ),
+ 'href' => 'https://bbpress.org/forums/forum/requests-and-feedback',
</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"> /** bbPress Developer **/
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -187,7 +243,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'parent' => 'wp-logo',
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'buddypress',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => __( 'BuddyPress.org' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'href' => 'https://buddypress.org',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'href' => 'https://buddypress.org',
</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"> // Add "About BuddyPress" link
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -200,26 +256,26 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add codex link
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'buddypress',
- 'id' => 'bp-documentation',
- 'title' => __( 'Documentation' ),
- 'href' => 'https://codex.buddypress.org/',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'buddypress',
+ 'id' => 'bp-documentation',
+ 'title' => __( 'Documentation' ),
+ 'href' => 'https://codex.buddypress.org/',
</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"> // Add forums link
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'buddypress',
- 'id' => 'bp-support-forums',
- 'title' => __( 'Support Forums' ),
- 'href' => 'https://buddypress.org/support/',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'buddypress',
+ 'id' => 'bp-support-forums',
+ 'title' => __( 'Support Forums' ),
+ 'href' => 'https://buddypress.org/support/',
</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"> // Add feedback link
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'buddypress',
- 'id' => 'bp-feedback',
- 'title' => __( 'Feedback' ),
- 'href' => 'https://buddypress.org/support/forum/feedback/',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'buddypress',
+ 'id' => 'bp-feedback',
+ 'title' => __( 'Feedback' ),
+ 'href' => 'https://buddypress.org/support/forum/feedback/',
</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"> /** BuddyPress Developer **/
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -250,68 +306,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Add a new "Site Name" menu with less things for average users to do
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @author johnjamesjacoby
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.0.2
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function bporg_new_admin_bar_site_menu( $wp_admin_bar ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Profiles
- if ( 'profiles.wordpress.org' == $_SERVER['HTTP_HOST'] ) {
- $wp_admin_bar->add_menu( array(
- 'id' => 'bp-site-name',
- 'title' => __( 'WordPress.org' ),
- 'href' => 'https://wordpress.org'
- ) );
-
- return;
-
- // bbPress Network
- } elseif ( strstr( $_SERVER['HTTP_HOST'], 'bbpress.org' ) ) {
- $wp_admin_bar->add_menu( array(
- 'id' => 'bp-site-name',
- 'title' => __( 'bbPress.org' ),
- 'href' => 'https://bbpress.org'
- ) );
-
- return;
-
- // BuddyPress Network
- } else {
- $wp_admin_bar->add_menu( array(
- 'id' => 'bp-site-name',
- 'title' => __( 'BuddyPress.org' ),
- 'href' => 'https://buddypress.org'
- ) );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Create submenu items.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( is_user_logged_in() ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Add a link to create a new topic.
- $wp_admin_bar->add_menu( array(
- 'id' => 'bp-new-topic',
- 'title' => __( 'Create New Topic' ),
- 'href' => 'https://buddypress.org/support/new-topic/'
- ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_main_site() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Add an option to visit the admin dashboard
- if ( is_super_admin() ) {
-
- $wp_admin_bar->add_group( array(
- 'parent' => 'bp-site-name',
- 'id' => 'bp-site-name-super-admin',
- 'meta' => array(
- 'class' => 'ab-sub-secondary',
- ),
- ) );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add a link to create a new topic.
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => 'bp-site-name-super-admin',
- 'id' => 'bp-admin-link',
- 'title' => __( 'Admin Dashbooard' ),
- 'href' => get_admin_url()
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'id' => 'bp-new-topic',
+ 'parent' => 'top-secondary',
+ 'title' => __( 'Create New Topic' ),
+ 'href' => 'https://buddypress.org/support/new-topic/'
</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">@@ -319,12 +329,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'bp-login',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => 'top-secondary',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'title' => __( 'Log in' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'href' => wp_login_url(),
</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">-add_action( 'admin_bar_menu', 'bporg_new_admin_bar_site_menu', 20 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'admin_bar_menu', 'bporg_new_admin_bar_site_menu', 2 );
</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"> * Add the "My Account" menu and all submenus.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -385,6 +396,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => __( 'Register' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'href' => wp_registration_url(),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_admin_bar->add_menu( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'parent' => 'user-actions',
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'login',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -402,105 +414,53 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.0.2
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function bporg_admin_bar_my_account_item( $wp_admin_bar ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = get_current_user_id();
+ $current_user = wp_get_current_user();
</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 ( is_user_logged_in() )
- return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Logged out
+ if ( empty( $user_id ) ) {
+ $howdy = __( 'Anonymous' );
+ $avatar = get_avatar( 0, 16, 'mystery' );
+ $class = empty( $avatar ) ? '' : 'with-avatar';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $avatar = get_avatar( 0, 16, 'mystery' );
- $howdy = __( 'Anonymous' );
- $class = empty( $avatar ) ? '' : 'with-avatar';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wp_admin_bar->add_menu( array(
+ 'id' => 'my-account',
+ 'parent' => 'top-secondary',
+ 'title' => $howdy . $avatar,
+ 'href' => wp_login_url(),
+ 'meta' => array(
+ 'class' => $class,
+ 'title' => __( 'My Account' ),
+ ),
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wp_admin_bar->add_menu( array(
- 'id' => 'my-account',
- 'parent' => 'top-secondary',
- 'title' => $howdy . $avatar,
- 'href' => wp_login_url(),
- 'meta' => array(
- 'class' => $class,
- 'title' => __('My Account'),
- ),
- ) );
-}
-add_action( 'admin_bar_menu', 'bporg_admin_bar_my_account_item', 0 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Logged in
+ } else {
+ if ( current_user_can( 'read' ) ) {
+ $profile_url = get_edit_profile_url( $user_id );
+ } elseif ( is_multisite() ) {
+ $profile_url = get_dashboard_url( $user_id, 'profile.php' );
+ } else {
+ $profile_url = false;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * Force toolbar styling into looking like sub-navigation
- *
- * Note: slightly experimental - kind of a hack
- *
- * @author johnjamesjacoby
- * @since 1.0.3
- */
-function bporg_toolbar_css_overrides() {
-?>
- <style type="text/css">
- /* Admin Bar */
- <?php if ( is_main_site() && is_front_page() ) : ?>
- #wpadminbar { display: none !important; }
- <?php else : ?>
- #wpadminbar { color: #555; background: #eee; top: 81px; border-bottom: 1px solid #ddd; height: 42px; }
- #wpadminbar #wp-toolbar a.ab-item, #wpadminbar .quicklinks li#wp-admin-bar-bp-notifications > a { padding: 5px; }
- #wpadminbar #wp-toolbar ul.ab-submenu a.ab-item { padding: 0 2em 0 1em; }
- #wpadminbar #wp-toolbar .ab-top-secondary .menupop .menupop > a.ab-item { padding: 0 1em 0 2em; }
- #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon { color: #555; }
- #wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after { color: #d84800; }
- #wpadminbar .ab-top-menu > li:hover > .ab-item,
- #wpadminbar .ab-top-menu > li.hover > .ab-item,
- #wpadminbar .ab-top-menu > li > .ab-item:focus,
- #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus,
- #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item,
- #wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item,
- #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { color: #555; background: #e2e2e2; }
- #wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label { color: #555; }
- #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before { color: #999; }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $howdy = '<span class="display-name">' . $current_user->display_name . '</span>';
+ $avatar = get_avatar( $user_id, 26 );
+ $class = empty( $avatar ) ? '' : 'with-avatar';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* Admin Bar: submenu */
- #wpadminbar .menupop .ab-sub-wrapper { background: #e2e2e2; }
- #wpadminbar .quicklinks .menupop .ab-submenu { background: #e2e2e2; }
- #wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { background: #d2d2d2; }
- #wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a { color: #555; }
- #wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before { color: #f1f1f3; }
- #wpadminbar .quicklinks .menupop ul li a:hover,
- #wpadminbar .quicklinks .menupop ul li a:focus,
- #wpadminbar .quicklinks .menupop ul li a:hover strong,
- #wpadminbar .quicklinks .menupop ul li a:focus strong,
- #wpadminbar .quicklinks .menupop.hover ul li a:hover,
- #wpadminbar .quicklinks .menupop.hover ul li a:focus,
- #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover,
- #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,
- #wpadminbar li:hover .ab-icon:before,
- #wpadminbar li:hover .ab-item:before,
- #wpadminbar li a:focus .ab-icon:before,
- #wpadminbar li .ab-item:focus:before,
- #wpadminbar li.hover .ab-icon:before,
- #wpadminbar li.hover .ab-item:before,
- #wpadminbar li:hover .ab-item:after,
- #wpadminbar li.hover .ab-item:after,
- #wpadminbar li:hover #adminbarsearch:before { color: #d84800; }
- #wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before { color: #d84800; }
-
- /* Admin Bar: my account */
- #wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { border-color: #e2e2e2; background-color: #e2e2e2; }
- #wpadminbar #wp-admin-bar-user-info .display-name { color: #555; }
- #wpadminbar #wp-admin-bar-user-info a:hover .display-name { color: #d84800; }
- #wpadminbar #wp-admin-bar-user-info .username { color: #000; }
-
- /* Some responsive'ish tweaks */
- @media screen and ( max-width: 460px ) {
- #wpadminbar {
- height: 56px;
- }
- #wpadminbar #wp-toolbar a.ab-item,
- #wpadminbar .quicklinks li#wp-admin-bar-bp-notifications > a { padding: 0; }
- }
-
- <?php endif; ?>
- </style>
-<?php
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wp_admin_bar->add_node(
+ array(
+ 'id' => 'my-account',
+ 'parent' => 'top-secondary',
+ 'title' => $howdy . $avatar,
+ 'href' => $profile_url,
+ 'meta' => array(
+ 'class' => $class,
+ 'menu_title' => $current_user->display_name,
+ 'tabindex' => ( false !== $profile_url ) ? '' : 0,
+ ),
+ )
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-// These toolbar modifications are for the buddypress.org network only.
-// (Do not override the toolbar for profiles.wordpress.org)
-if ( $_SERVER['HTTP_HOST'] !== 'profiles.wordpress.org' ) {
- add_theme_support( 'admin-bar', array( 'callback' => 'bporg_toolbar_css_overrides' ) );
-}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'admin_bar_menu', 'bporg_admin_bar_my_account_item', 9991 );
</ins></span></pre>
</div>
</div>
</body>
</html>