Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ms.php

    r17228 r18009  
    497497add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
    498498
    499 function redirect_user_to_blog() {
    500     $c = 0;
    501     if ( isset( $_GET['c'] ) )
    502         $c = (int) $_GET['c'];
    503 
    504     if ( $c >= 5 ) {
    505         wp_die( __( "You don’t have permission to view this site. Please contact the system administrator." ) );
    506     }
    507     $c ++;
    508 
    509     $blog = get_active_blog_for_user( get_current_user_id() );
    510 
    511     if ( is_object( $blog ) ) {
    512         wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
    513     } else {
    514         wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case"
    515     }
    516     exit;
    517 }
    518 add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );
     499function _access_denied_splash() {
     500    if ( ! is_user_logged_in() || is_network_admin() )
     501        return;
     502
     503    $blogs = get_blogs_of_user( get_current_user_id() );
     504
     505    if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) )
     506        return;
     507
     508    $blog_name = get_bloginfo( 'name' );
     509
     510    if ( empty( $blogs ) )
     511        wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) );
     512
     513    $output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
     514    $output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
     515
     516    $output .= '<h3>' . __('Your Sites') . '</h3>';
     517    $output .= '<table>';
     518
     519    foreach ( $blogs as $blog ) {
     520        $output .= "<tr>";
     521        $output .= "<td valign='top'>";
     522        $output .= "{$blog->blogname}";
     523        $output .= "</td>";
     524        $output .= "<td valign='top'>";
     525        $output .= "<a href='" . esc_url( get_admin_url( $blog->userblog_id ) ) . "'>" . __( 'Visit Dashboard' ) . "</a> | <a href='" . esc_url( get_home_url( $blog->userblog_id ) ). "'>" . __( 'View Site' ) . "</a>" ;
     526        $output .= "</td>";
     527        $output .= "</tr>";
     528    }
     529    $output .= '</table>';
     530
     531    wp_die( $output );
     532}
     533add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
    519534
    520535function check_import_new_users( $permission ) {
Note: See TracChangeset for help on using the changeset viewer.