WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The My Sites admin page only has links to the sites’ dashboards and production pages which is of limited value. I am trying to figure out a way to add a more useful links to them like New Post, Drafts, and Comments in order to make the page a practical central administration location (that way, I don’t have to use a page that I cobbled together with IFrames several years ago for this).

Obviously I will have to write a plugin, but I’m having trouble finding good examples of modifying the admin pages, especially in this specific manner (adding blog-specific information to multiple items on an admin page). The closest thing I could find was right here; a question about sorting the items, but the accepted solution simply adds a filter to sort the list of blogs and doesn’t help with this.

The file /wp-admin/my-sites.php creates the blog list on the My Sites page with the following code:

foreach ( $row as $user_blog ) {
    $s = $i == 3 ? '' : 'border-right: 1px solid #ccc;';
    echo "<td valign='top' style='$s'>";
    echo "<h3>{$user_blog->blogname}</h3>";

    echo "<p>" . apply_filters( 'myblogs_blog_actions', "<a href='" . esc_url( get_home_url( $user_blog->userblog_id ) ). "'>" . __( 'Visit' ) . "</a> | <a href='" . esc_url( get_admin_url( $user_blog->userblog_id ) ) . "'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>";

    echo apply_filters( 'myblogs_options', '', $user_blog );
    echo "</td>";

There are two problems:

  1. I can find no information on chaining a modification to the myblogs_blog_actions filter. The best I can accomplish is to append some text to the HTML containing the links, but without information on the specific blog being processed, I cannot provide blog-specific links, at least not without first parsing the links already provided which seems like the wrong way to be doing this.

  2. I cannot find any information on a function that returns the URL of the comments, post-new, or drafts (or other admin) pages. Obviously I could append a hard-coded string to the blog root URL (e.g., post-new.php) but that seems kludgy; surely there is a proper built-in way to get them.

I made a test plugin which can modify the links, but it has no way of accessing the blog id to provide blog-specific links because no additional parameters are provided. I suppose I could parse the existing links in the string passed to the filter, but that is as inelegant as it gets:

add_filter('myblogs_blog_actions', 'my_sites_links');
function my_sites_links($links, $a, $b, $c) {
return                 "\n"
  . var_dump($links) . "\n"
  . var_dump($a)     . "\n"
  . var_dump($b)     . "\n"
  . var_dump($c)     . "\n";

Does anyone have any suggestions on accomplishing this?

share|improve this question
up vote 1 down vote accepted
function my_sites_links($links, $a, $b, $c) {
global $user_blog; 
share|improve this answer
Please add an explanation to your answer: why could that solve the problem? – toscho Jun 8 '13 at 17:58
Very nice. It correctly returns the id of each blog. The next step is to get the correct URLs of the desired pages for each blog. I examined the code for the admin bar and the side-menu and found that the Core uses admin_url to get the base URL and appends the specified page (e.g., 'edit-comments.php'). So I did likewise: get_admin_url($user_blog->userblog_id, "post-new.php") Bingo! All that’s left is to style it (e.g., add the ` | ` between the links). Thanks! (I’m also going to add a conditional to not show the links for blogs that have no comments/drafts.) – Synetech Jun 8 '13 at 21:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.