[Pro Sites] display the quota of a blog in front end

Hello,
i have do a session chat and the support said to open a ticket.
How I can display the info about the level and the quota of a blog in front end ? (by custom code in template or in my plugin)
For exemple in the gallery we have
"You use 1 248,89 MB (41%) de 3 072,00 MB utilisé."
I want to display this in my custom template.

Thanks for your help

  • Ash

    Hello Samuel

    You can try something like this:

    add_filter( 'psts_primary_checkout_table', function( $content ){
    
        if ( ! isset( $_GET['bid'] ) ) {
            return $content;
        }
    
        $blog_id = (int) $_GET['bid'];
        $quota = get_space_allowed();
        $used = get_space_used();
        $quota_msg = '';
        switch_to_blog( $blog_id );
    
        ob_start();
        ?>
        <h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
        <div class="mu-storage">
        <ul>
            <li class="storage-count">
                <?php $text = sprintf(
                    __( '%s MB Space Allowed' ),
                    number_format_i18n( $quota )
                );
                echo $text;
                ?>
            </li><li class="storage-count">
                <?php $text = sprintf(
                    __( '%1$s MB (%2$s%%) Space Used' ),
                    number_format_i18n( $used, 2 ),
                    $percentused
                );
                echo $text;
                ?>
            </li>
        </ul>
        </div>
        <?php
    
        restore_current_blog();
    
        $quota_msg = ob_get_clean();
        return $content . $quota_msg;
    }, 999 );

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.