Help with updating a wp_get_sites to get_sites and sorting by alphebetical order

So the main things that have changed that need updating due to the deprecation of wp_get_sites() is to change that to get_sites(). When using get_sites(), $TheBlogs will be an array of WP_Site objects, rather than an array of arrays. This means that to get the details of the site, rather than using get_blog_details() you can use $blog->__get( 'blogname' ).

The other part, sorting alphabetically, will require sorting the resulting array, as get_sites() doesn’t appear to have an argument for ordering by blogname.

// Get blogs with get_sites(), which uses 'number' instead of 'limit'. 
$blogs = get_sites( ['number' => 1000] );

// Sort blogs alphabetically.
uasort( 
    $blogs, 
    function( $a, $b ) {
        // Compare site blog names alphabetically for sorting purposes.
        return strcmp( $a->__get( 'blogname' ), $b->__get( 'blogname' ) );
    }
);

foreach ( $blogs as $blog ) {
    // Store blog name in variable for later use.
    $blogname = $blog->__get( 'blogname' );

    // Check blog is not excluded.
    if ( 
        get_site_option( 'msregister_blog1_id' ) != $blogname && 
        get_site_option( 'msregister_exclude_' . $blogname ) != 'yes'
    ) { 
        // Output option tag, escaping the blog name as appropriate.
        printf(
            '<option value="%s">%s</option>',
            esc_attr( $blogname ),
            esc_html( $blogname )
        );
    }
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)