WordPress Theme/Plugin Information API Response to Text and Button

There’s quite a bit to this… I feel like I’m doing your job for you, but here it is.

A table automatically build to display download buttons for each version of a theme returned in the themes_api() request.

You must run this at an appropriate time – at least after WordPress init:

Simply call the function with the theme slug you want:

function display_version_downloads_table_for_theme( $slug ) {

    if ( !function_exists( 'themes_api' ) ) {
        echo "You're calling this function display_version_downloads_table_for_theme() too soon.";
        return;
    }

    $result = themes_api( 'theme_information', [
        'slug'   => $slug,
        'fields' => [
            'versions'       => true,
            'sections'       => false,
            'screenshot_url' => false,
            'tags'           => false,
        ]
    ] );

    $versions = ( is_object( $result ) && !empty( $result->versions ) && is_array( $result->versions ) ) ? $result->versions : [];
    foreach ( $versions as $version => $link ) {
        if ( empty( $version ) ) {
            unset( $versions[ $version ] );
        }
    }

    if ( empty( $versions ) ) {
        echo 'Themes API request either failed, or there were no versions available for the requested theme';
    }
    else {
        ?>
        <script type="text/javascript">
            function runDownload( button ) {
                window.open( button.getAttribute( 'data-href' ), '_blank' );
            }
        </script>

        <table>
            
            <thead>
                <tr>
                    <th>Version</th>
                    <th>Download</th>
                </tr>
            </thead>
            
            <tbody>
            <?php foreach ( $versions as $version => $href ) : ?>
                <tr>
                    <td><?= $version ?></td>
                    <td>
                        <button onclick="runDownload( this )" data-href="<?= esc_url( $href ) ?>">
                            Download
                        </button>
                    </td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    <?php }
}

display_version_downloads_table_for_theme( 'twentyfifteen' );

error code: 523