Permalink
Browse files

add function to remove comments menu in MU

  • Loading branch information...
1 parent a28e237 commit c54ef7a37b68fa3a9ea9911ee0d2ddf69084b56a @bueltge committed Apr 8, 2013
Showing with 21 additions and 0 deletions.
  1. +21 −0 remove-comments-absolute.php
@@ -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 );
@@ -245,6 +247,9 @@ 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' );
@@ -253,6 +258,22 @@ public function admin_bar_render() {
}
/**
+ * 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
*
* @access public

0 comments on commit c54ef7a

Please sign in to comment.