Skip to content

Commit

Permalink
Merge pull request #10 from humanmade/override-admin-bar-menu
Browse files Browse the repository at this point in the history
Override the admin bar item
  • Loading branch information
roborourke authored Apr 29, 2019
2 parents 8acfd3a + 059fe09 commit cb75251
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions inc/stream/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace HM\Platform\Security\Stream;

use const HM\Platform\ROOT_DIR;
use WP_Admin_Bar;

function bootstrap() {
add_filter( 'wp_stream_admin_menu_title', function () : string {
Expand All @@ -16,6 +17,7 @@ function bootstrap() {
add_filter( 'site_option_wp_stream_network', __NAMESPACE__ . '\\default_stream_network_options' );
add_filter( 'default_site_option_wp_stream_network', __NAMESPACE__ . '\\default_stream_network_options' );
add_action( 'network_admin_menu', __NAMESPACE__ . '\\remove_stream_admin_pages', 11 );
add_action( 'admin_bar_menu', __NAMESPACE__ . '\\override_network_admin_bar_menu', 100 );

require_once ROOT_DIR . '/vendor/humanmade/stream/stream.php';
}
Expand Down Expand Up @@ -51,3 +53,27 @@ function remove_stream_admin_pages() {
global $wp_stream;
remove_submenu_page( $wp_stream->admin->records_page_slug, $wp_stream->admin->network->network_settings_page_slug );
}

/**
* Override the Stream admin bar menu.
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function override_network_admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) {
$wp_admin_bar->remove_menu( 'network-admin-stream' );
$href = add_query_arg(
[
'page' => wp_stream_get_instance()->admin->records_page_slug,
],
network_admin_url( wp_stream_get_instance()->admin->admin_parent_page )
);

$wp_admin_bar->add_menu(
[
'id' => 'network-admin-stream',
'parent' => 'network-admin',
'title' => esc_html__( 'Audit Log', 'hm-platform' ),
'href' => esc_url( $href ),
]
);
}

0 comments on commit cb75251

Please sign in to comment.