This commit is contained in:
Javier Casares 2026-08-10 16:21:45 +00:00
commit cc1bca74fa
29 changed files with 770 additions and 204 deletions

View file

@ -180,8 +180,8 @@ class Admin_Page {
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'idrivee2-media-upload' ) );
}
$raw_test_file = is_string( $_POST['test_file'] ) ? $_POST['test_file'] : '';
$this->handle_delete_test( sanitize_file_name( wp_unslash( $raw_test_file ) ) );
$raw_test_file = is_string( $_POST['test_file'] ) ? wp_unslash( $_POST['test_file'] ) : '';
$this->handle_delete_test( sanitize_file_name( $raw_test_file ) );
return;
}
}
@ -327,6 +327,7 @@ class Admin_Page {
'Bucket' => $this->config->get_bucket(),
'Key' => $file_name,
'Body' => $content,
// ACL matches the media uploader: files are served publicly via CDN/S3.
'ACL' => 'public-read',
)
);
@ -531,6 +532,9 @@ class Admin_Page {
$allowed_modes = array( 'all', 'thumbnail', 'none' );
$sanitized['subsizes_mode'] = in_array( $raw_mode, $allowed_modes, true ) ? $raw_mode : 'all';
// Data cleanup on uninstall: checkbox, default off (preserve data).
$sanitized['delete_on_uninstall'] = ! empty( $input['delete_on_uninstall'] ) ? '1' : '';
return $sanitized;
}
@ -577,6 +581,7 @@ class Admin_Page {
$region = $this->config->get_region();
$domain = $this->config->get_domain();
$subsizes_mode = $this->config->get_subsizes_mode();
$delete_on_uninstall = $this->config->is_delete_on_uninstall();
$is_configured = $this->config->is_configured();
@ -811,23 +816,34 @@ class Admin_Page {
</p>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Data Cleanup', 'idrivee2-media-upload' ); ?></th>
<td>
<label for="idrivee2_delete_on_uninstall">
<input
type="checkbox"
id="idrivee2_delete_on_uninstall"
name="idrivee2_media_settings[delete_on_uninstall]"
value="1"
<?php checked( $delete_on_uninstall ); ?>
/>
<?php esc_html_e( 'Delete all plugin data when the plugin is uninstalled', 'idrivee2-media-upload' ); ?>
</label>
<p class="description">
<?php esc_html_e( 'By default, all data is preserved when the plugin is uninstalled. Check this to remove settings, statistics, and post meta on uninstall.', 'idrivee2-media-upload' ); ?>
</p>
</td>
</tr>
</tbody>
</table>
<?php if ( ! $any_in_config ) : ?>
<?php submit_button( __( 'Save Settings', 'idrivee2-media-upload' ) ); ?>
<?php else : ?>
<?php if ( $any_in_config ) : ?>
<p class="description">
<?php esc_html_e( 'To modify settings defined in wp-config.php, please edit your wp-config.php file directly.', 'idrivee2-media-upload' ); ?>
</p>
<?php
// Show submit button only if at least one field can be edited.
$can_edit = ! $host_in_config || ! $key_in_config || ! $secret_in_config || ! $bucket_in_config || ! $region_in_config || ! $domain_in_config || ! $subsizes_mode_in_config;
if ( $can_edit ) :
?>
<?php submit_button( __( 'Save Settings', 'idrivee2-media-upload' ) ); ?>
<?php endif; ?>
<?php endif; ?>
<?php submit_button( __( 'Save Settings', 'idrivee2-media-upload' ) ); ?>
</form>
<?php if ( $is_configured ) : ?>