| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * Admin Settings Page
- *
- * @package QDR_Temporary_Shared_Storage
- */
- // If this file is called directly, abort.
- if (!defined('WPINC')) {
- die;
- }
- // Get current settings
- $settings = QDR_TSS_Settings::instance()->get_settings();
- $db_manager = QDR_TSS_DB_Manager::instance();
- // Get total storage usage
- $total_size = $db_manager->get_total_storage();
- $max_size = $settings['max_upload_size'];
- $usage_percent = ($max_size > 0) ? min(100, ($total_size / $max_size) * 100) : 0;
- ?>
- <div class="wrap qdr-tss-admin">
- <h1><?php esc_html_e('Shared Storage Settings', 'qdr-temporary-shared-storage'); ?></h1>
-
- <form id="qdr-tss-settings-form" method="post">
- <table class="form-table">
- <tbody>
- <tr>
- <th scope="row">
- <label for="qdr-tss-api-key"><?php esc_html_e('API Key', 'qdr-temporary-shared-storage'); ?></label>
- </th>
- <td>
- <input type="text" id="qdr-tss-api-key" name="api_key" value="<?php echo esc_attr($settings['api_key']); ?>" class="regular-text">
- <p class="description"><?php esc_html_e('API key for REST API authentication.', 'qdr-temporary-shared-storage'); ?></p>
- <button type="button" id="qdr-tss-generate-key" class="button"><?php esc_html_e('Generate New Key', 'qdr-temporary-shared-storage'); ?></button>
- </td>
- </tr>
-
- <tr>
- <th scope="row">
- <label for="qdr-tss-media-category"><?php esc_html_e('Media Category', 'qdr-temporary-shared-storage'); ?></label>
- </th>
- <td>
- <input type="text" id="qdr-tss-media-category" name="media_category" value="<?php echo esc_attr($settings['media_category']); ?>" class="regular-text">
- <p class="description"><?php esc_html_e('Category to assign to uploaded media.', 'qdr-temporary-shared-storage'); ?></p>
- </td>
- </tr>
-
- <tr>
- <th scope="row">
- <label for="qdr-tss-max-upload-size"><?php esc_html_e('Maximum Storage Size (bytes)', 'qdr-temporary-shared-storage'); ?></label>
- </th>
- <td>
- <input type="number" id="qdr-tss-max-upload-size" name="max_upload_size" value="<?php echo esc_attr($settings['max_upload_size']); ?>" class="regular-text">
- <p class="description">
- <?php esc_html_e('Maximum total storage size in bytes. Current usage:', 'qdr-temporary-shared-storage'); ?>
- <span id="qdr-tss-current-usage"><?php echo esc_html(qdr_tss_format_bytes($total_size)); ?></span>
- (<?php echo esc_html(qdr_tss_format_bytes($settings['max_upload_size'])); ?> <?php esc_html_e('max', 'qdr-temporary-shared-storage'); ?>)
- </p>
- <div class="qdr-tss-storage-bar">
- <div class="qdr-tss-storage-used" style="width: <?php echo min(100, ($total_size / $settings['max_upload_size']) * 100); ?>%"></div>
- </div>
-
- <p class="description">
- <?php esc_html_e('Common sizes:', 'qdr-temporary-shared-storage'); ?><br>
- 1 GB = 1073741824 <?php esc_html_e('bytes', 'qdr-temporary-shared-storage'); ?><br>
- 5 GB = 5368709120 <?php esc_html_e('bytes', 'qdr-temporary-shared-storage'); ?><br>
- 10 GB = 10737418240 <?php esc_html_e('bytes', 'qdr-temporary-shared-storage'); ?>
- </p>
- </td>
- </tr>
- </tbody>
- </table>
-
- <p class="submit">
- <button type="submit" id="qdr-tss-save-settings" class="button button-primary"><?php esc_html_e('Save Settings', 'qdr-temporary-shared-storage'); ?></button>
- <button type="button" id="qdr-tss-purge-expired" class="button"><?php esc_html_e('Purge Expired Files', 'qdr-temporary-shared-storage'); ?></button>
- </p>
- </form>
- </div>
|