WordPress.org

Make WordPress Core

Ticket #17121: 17121.diff

File 17121.diff, 2.2 KB (added by ryan, 7 years ago)

Rough draft

  • wp-admin/includes/ms.php

     
    496496}
    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'];
     499function _access_denied_splash() {
     500        if ( ! is_user_logged_in() )
     501                return;
    503502
    504         if ( $c >= 5 ) {
    505                 wp_die( __( "You don’t have permission to view this site. Please contact the system administrator." ) );
     503        $blogs = get_blogs_of_user( get_current_user_id() );
     504
     505        $blog_name = get_bloginfo( 'name' );
     506
     507        if ( empty( $blogs ) ) {
     508                wp_die( sprintf( __( 'You have reached the dashboard of "%s" but have no privileges on this site. Please ask an administrator to add you to this one.' ), $blog_name ) );
     509                exit;
    506510        }
    507         $c ++;
    508511
    509         $blog = get_active_blog_for_user( get_current_user_id() );
     512        $output .= sprintf( __( 'You have reached the dashboard of "%s" but have no privileges on this site. Please visit one of your own dashboards or ask an administrator to add you to this one.' ), $blog_name );
    510513
    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"
     514        $output .= '<h3>' . __('Your Sites') . '</h3>';
     515        $output .= '<table>';
     516
     517        foreach ( $blogs as $blog ) {
     518                $output .= "<tr>";
     519                $output .= "<td valign='top'>";
     520                $output .= "{$blog->blogname}";
     521                $output .= "</td>";
     522                $output .= "<td valign='top'>";
     523                $output .= "<a href='" . esc_url( get_home_url( $blog->userblog_id ) ). "'>" . __( 'Visit' ) . "</a> | <a href='" . esc_url( get_admin_url( $blog->userblog_id ) ) . "'>" . __( 'Dashboard' ) . "</a>";
     524                $output .= "</td>";
     525                $output .= "</tr>";
    515526        }
     527        $output .= '</table>';
     528
     529        wp_die($output);
    516530        exit;
    517531}
    518 add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );
     532add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
    519533
    520534function check_import_new_users( $permission ) {
    521535        if ( !is_super_admin() )