Plugin to restrict access to pages in wp-admin

if( is_admin() ) {
    add_filter( 'init', 'custom_restrict_pages_from_admin' );
}

function custom_restrict_pages_from_admin() {
    global $pagenow;

    $arr = array(
        'update-core.php',
        'edit.php'
    );

    if( custom_check_user_roles() && in_array( $pagenow , $arr ) ) {
        //echo some custom messages or call the functions 
    } else {
        echo 'This page has restricted access to specific roles';
        wp_die();
    }
}

function custom_check_user_roles() {
    //restrict pages by user role 

    if( current_user_can( 'administrator' ) || current_user_can( 'editor' ) ) 
         return true;
    else { 
        echo 'Not allowed!'; 
        wp_die();
    }
}