Created
February 3, 2015 20:51
-
-
Save peterchester/6bcbae502dc946bc8a63 to your computer and use it in GitHub Desktop.
show-blog-belongs-to.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Show User's Blogs | |
Description: Adds a list of what blogs a user belongs to to the user table. | |
Version: 1.0 | |
Author: Modern Tribe, Inc. | |
*/ | |
if(!class_exists('Show_Blog_Belongs')) { | |
class Show_Blog_Belongs { | |
public function __construct() { | |
$this->addActions(); | |
$this->addFilters(); | |
} | |
private function addActions() { | |
add_action('edit_user_profile', array($this, 'showBlogsForUser')); | |
add_action('show_user_profile', array($this, 'showBlogsForUser')); | |
} | |
private function addFilters() { | |
} | |
/// CALLBACK | |
public function showBlogsForUser($user) { | |
if(is_admin()) { | |
$blogs = get_blogs_of_user($user->ID, true); | |
?> | |
<h3><?php _e('Sites'); ?></h3> | |
<ul id="sites-this-user-belongs-to"> | |
<?php foreach($blogs as $key => $blog) { ?> | |
<li><a href="<?php esc_attr_e($blog->siteurl); ?>"><?php esc_html_e($blog->blogname); ?></a> — <a href="<?php esc_attr_e(trailingslashit($blog->siteurl)); ?>wp-admin/"><?php _e('Backend'); ?></a></li> | |
<?php } ?> | |
</ul> | |
<?php | |
} | |
} | |
} | |
global $Show_Blog_Belongs; | |
$Show_Blog_Belongs = new Show_Blog_Belongs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment