Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
add function to remove comments menu in MU
Browse files Browse the repository at this point in the history
  • Loading branch information
bueltge committed Apr 8, 2013
1 parent a28e237 commit c54ef7a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions remove-comments-absolute.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function __construct() {

// change admin bar items
add_action( 'wp_before_admin_bar_render', array( $this, 'admin_bar_render' ) );
if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
add_action( 'admin_bar_menu', array( $this, 'remove_network_comment_items' ), 500 );

// remove string on frontend in Theme
add_filter( 'gettext', array( $this, 'remove_theme_string' ), 20, 3 );
Expand Down Expand Up @@ -245,13 +247,32 @@ public function remove_comments_areas() {
*/
public function admin_bar_render() {

if ( ! is_admin_bar_showing() )
return NULL;

// remove comment item in blog -list for "My Sites" in Admin Bar
if ( isset( $GLOBALS['blog_id'] ) )
$GLOBALS['wp_admin_bar']->remove_menu( 'blog-' . $GLOBALS['blog_id'] . '-c' );
// remove entry in admin bar
$GLOBALS['wp_admin_bar']->remove_menu( 'comments' );
}

/**
* Remove comments item on network admin bar
*
* @since 04/08/2013
* @param $wp_admin_bar Array
* @return void
*/
public function remove_network_comment_items( $wp_admin_bar ) {

if ( ! is_admin_bar_showing() )
return NULL;

foreach( (array) $wp_admin_bar->user->blogs as $blog )
$wp_admin_bar->remove_menu( 'blog-' . $blog->userblog_id . '-c' );
}

/**
* Display the links to the general feeds, without comments
*
Expand Down

0 comments on commit c54ef7a

Please sign in to comment.