| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
// Handle save |
| 5 |
if ( isset( $_POST['qdbp_save_settings'] ) && current_user_can( 'manage_options' ) && check_admin_referer( 'qdbp_settings_save' ) ) { |
| 6 |
QDBP_Settings::save( $_POST ); |
| 7 |
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'Settings saved.', 'quick-download-button' ) . '</p></div>'; |
| 8 |
} |
| 9 |
|
| 10 |
$s = QDBP_Settings::all(); |
| 11 |
?> |
| 12 |
<div class="wrap qdbp-wrap"> |
| 13 |
<h1><?php esc_html_e( 'Quick Download Button Settings', 'quick-download-button' ); ?></h1> |
| 14 |
|
| 15 |
<form method="post"> |
| 16 |
<?php wp_nonce_field( 'qdbp_settings_save' ); ?> |
| 17 |
|
| 18 |
<!-- ── Download Counter ──────────────────────────────────── --> |
| 19 |
<h2><?php esc_html_e( 'Download Counter', 'quick-download-button' ); ?></h2> |
| 20 |
<table class="form-table" role="presentation"> |
| 21 |
<tr> |
| 22 |
<th scope="row"><?php esc_html_e( 'Show download count', 'quick-download-button' ); ?></th> |
| 23 |
<td> |
| 24 |
<label> |
| 25 |
<input type="checkbox" name="show_download_count" value="1" <?php checked( 1, $s['show_download_count'] ); ?> /> |
| 26 |
<?php esc_html_e( 'Display total download count below each button', 'quick-download-button' ); ?> |
| 27 |
</label> |
| 28 |
</td> |
| 29 |
</tr> |
| 30 |
<tr> |
| 31 |
<th scope="row"><label for="download_count_label"><?php esc_html_e( 'Count label', 'quick-download-button' ); ?></label></th> |
| 32 |
<td> |
| 33 |
<input type="text" id="download_count_label" name="download_count_label" class="regular-text" |
| 34 |
value="<?php echo esc_attr( $s['download_count_label'] ); ?>" /> |
| 35 |
<p class="description"><?php esc_html_e( 'Use {count} as a placeholder. Example: {count} downloads', 'quick-download-button' ); ?></p> |
| 36 |
</td> |
| 37 |
</tr> |
| 38 |
</table> |
| 39 |
|
| 40 |
<!-- ── Email Leads ──────────────────────────────────────── --> |
| 41 |
<h2><?php esc_html_e( 'Email Leads', 'quick-download-button' ); ?></h2> |
| 42 |
<table class="form-table" role="presentation"> |
| 43 |
<tr> |
| 44 |
<th scope="row"><?php esc_html_e( 'Admin notification', 'quick-download-button' ); ?></th> |
| 45 |
<td> |
| 46 |
<label> |
| 47 |
<input type="checkbox" name="admin_email_notify" value="1" <?php checked( 1, $s['admin_email_notify'] ); ?> /> |
| 48 |
<?php esc_html_e( 'Send an email when a new lead is captured', 'quick-download-button' ); ?> |
| 49 |
</label> |
| 50 |
</td> |
| 51 |
</tr> |
| 52 |
<tr> |
| 53 |
<th scope="row"><label for="notify_email"><?php esc_html_e( 'Notification email', 'quick-download-button' ); ?></label></th> |
| 54 |
<td> |
| 55 |
<input type="email" id="notify_email" name="notify_email" class="regular-text" |
| 56 |
value="<?php echo esc_attr( $s['notify_email'] ); ?>" |
| 57 |
placeholder="<?php echo esc_attr( get_option( 'admin_email' ) ); ?>" /> |
| 58 |
<p class="description"><?php esc_html_e( 'Leave blank to use the WordPress admin email.', 'quick-download-button' ); ?></p> |
| 59 |
</td> |
| 60 |
</tr> |
| 61 |
</table> |
| 62 |
|
| 63 |
<!-- ── Data Retention ───────────────────────────────────── --> |
| 64 |
<h2><?php esc_html_e( 'Data Retention', 'quick-download-button' ); ?></h2> |
| 65 |
<table class="form-table" role="presentation"> |
| 66 |
<tr> |
| 67 |
<th scope="row"><label for="log_retention_days"><?php esc_html_e( 'Auto-delete logs after', 'quick-download-button' ); ?></label></th> |
| 68 |
<td> |
| 69 |
<input type="number" id="log_retention_days" name="log_retention_days" min="0" step="1" class="small-text" |
| 70 |
value="<?php echo absint( $s['log_retention_days'] ); ?>" /> |
| 71 |
<span><?php esc_html_e( 'days (0 = keep forever)', 'quick-download-button' ); ?></span> |
| 72 |
<p class="description"><?php esc_html_e( 'Applies to download logs. Leads are never auto-deleted.', 'quick-download-button' ); ?></p> |
| 73 |
</td> |
| 74 |
</tr> |
| 75 |
</table> |
| 76 |
|
| 77 |
<?php submit_button( __( 'Save Settings', 'quick-download-button' ), 'primary', 'qdbp_save_settings' ); ?> |
| 78 |
</form> |
| 79 |
</div> |
| 80 |
|