Plugin Directory

Changeset 3492636


Ignore:
Timestamp:
03/27/2026 12:17:44 PM (23 hours ago)
Author:
bastho
Message:

Add stat for upload dir

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ressources/trunk/ressources.php

    r3492583 r3492636  
    222222    }
    223223    function content_disk(){
    224         $chem = ABSPATH . '/wp-content';
    225         // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec
    226         exec('du -h --max-depth=1 ' . $chem, $che);;
    227         if(array_pop($che) !== null){
    228             $info = explode("\t", array_pop($che));
     224        // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec
     225        exec('du -h --max-depth=0 ' . WP_CONTENT_DIR, $dir_stat_content);;
     226        if(!empty($dir_stat_content)){
     227            $info = explode("\t", array_pop($dir_stat_content));
    229228            ?>
    230229            <tr>
    231                 <td colspan="3"><?php esc_html_e('space used by wp-content:', 'ressources') ?></td>
     230                <td colspan="2"><?php esc_html_e('Space used by wp-content:', 'ressources') ?></td>
    232231                <td><b><?php echo esc_html( $info[0] );  ?></b></td>
    233             </tr>
    234             <?php
    235         }
     232                <td></td>
     233                <td></td>
     234            </tr>
     235            <?php
     236        }
     237        $blog_upload_space = (int)get_option('blog_upload_space')*1024*1024;
     238        $upload_dir = wp_upload_dir();
     239        // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec
     240        exec('du -h --max-depth=0 ' . $upload_dir['basedir'], $dir_stat_upload);
     241        if(!empty($dir_stat_upload)){
     242            $info = explode("\t", array_pop($dir_stat_upload));
     243            $used = $this->strtoint($info[0]);
     244            $prc_used = $blog_upload_space > 0 ? $used / $blog_upload_space * 100 : 0;
     245            ?>
     246            <tr>
     247                <td><?php esc_html_e('Space used by uploads:', 'ressources') ?></td>
     248                <td><?php echo esc_html( $blog_upload_space ? $this->human_filesize($blog_upload_space) : __('No limit', 'ressources') ); ?></td>
     249                <td><b><?php echo esc_html( $this->human_filesize($used) );  ?></b></td>
     250                <td>
     251                    <?php if($blog_upload_space): ?>
     252                        <div class="progress-container"><div class="progress-bar" style="width:<?php echo esc_html( $prc_used ) ?>%;"></div></div>
     253                    <?php endif; ?>
     254                </td>
     255            </tr>
     256            <?php
     257        }
     258        ?>
     259            <tr>
     260                <td colspan="4"><hr></td>
     261            </tr>
     262            <?php
     263
    236264        // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec
    237265        exec('df -h', $out);
Note: See TracChangeset for help on using the changeset viewer.