audit clean-up
add 'no dates' logic
This commit is contained in:
@@ -406,8 +406,8 @@ Headers: X-HSSM-API-Key: your-api-key</code></pre>
|
||||
add_settings_error( 'hssm_settings', 'api_key_generated', __( 'New API key generated successfully.', 'hi-school-slide-manager' ), 'success' );
|
||||
}
|
||||
|
||||
// Handle API key deletion
|
||||
if ( isset( $_POST['delete_api_key'] ) && isset( $_POST['api_key_index'] ) ) {
|
||||
// Handle API key deletion (only when delete was explicitly triggered via JS with index)
|
||||
if ( ! empty( $_POST['delete_api_key'] ) && isset( $_POST['api_key_index'] ) && $_POST['api_key_index'] !== '' ) {
|
||||
$api_keys = get_option( 'hssm_api_keys', array() );
|
||||
$index = (int) $_POST['api_key_index'];
|
||||
if ( isset( $api_keys[ $index ] ) ) {
|
||||
@@ -511,6 +511,8 @@ Headers: X-HSSM-API-Key: your-api-key</code></pre>
|
||||
if ( empty( $api_keys ) ) {
|
||||
echo '<p>' . __( 'No API keys generated yet.', 'hi-school-slide-manager' ) . '</p>';
|
||||
} else {
|
||||
echo '<input type="hidden" name="api_key_index" id="hssm-delete-api-key-index" value="" />';
|
||||
echo '<input type="hidden" name="delete_api_key" id="hssm-delete-api-key-flag" value="0" />';
|
||||
echo '<table class="widefat">';
|
||||
echo '<thead><tr><th>' . __( 'API Key', 'hi-school-slide-manager' ) . '</th><th>' . __( 'Actions', 'hi-school-slide-manager' ) . '</th></tr></thead>';
|
||||
echo '<tbody>';
|
||||
@@ -519,9 +521,8 @@ Headers: X-HSSM-API-Key: your-api-key</code></pre>
|
||||
echo '<tr>';
|
||||
echo '<td><code>' . esc_html( $key ) . '</code></td>';
|
||||
echo '<td>';
|
||||
echo '<button type="button" class="button copy-api-key" data-key="' . esc_attr( $key ) . '">' . __( 'Copy', 'hi-school-slide-manager' ) . '</button> ';
|
||||
echo '<button type="submit" name="delete_api_key" value="1" class="button button-link-delete" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete this API key?', 'hi-school-slide-manager' ) ) . '\')">' . __( 'Delete', 'hi-school-slide-manager' ) . '</button>';
|
||||
echo '<input type="hidden" name="api_key_index" value="' . esc_attr( $index ) . '" />';
|
||||
echo '<button type="button" class="button copy-api-key" data-key="' . esc_attr( $key ) . '">' . __( 'Copy', 'hi-school-slide-manager' ) . '</button> ';
|
||||
echo '<button type="button" class="button button-link-delete hssm-delete-api-key" data-index="' . esc_attr( $index ) . '">' . __( 'Delete', 'hi-school-slide-manager' ) . '</button>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
@@ -534,7 +535,7 @@ Headers: X-HSSM-API-Key: your-api-key</code></pre>
|
||||
|
||||
echo '</div>';
|
||||
|
||||
// Add JavaScript for copy functionality
|
||||
// Add JavaScript for copy and delete functionality
|
||||
?>
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
@@ -544,6 +545,15 @@ Headers: X-HSSM-API-Key: your-api-key</code></pre>
|
||||
alert("API key copied to clipboard!");
|
||||
});
|
||||
});
|
||||
$(".hssm-delete-api-key").on("click", function() {
|
||||
if (! confirm("<?php echo esc_js( __( 'Are you sure you want to delete this API key?', 'hi-school-slide-manager' ) ); ?>")) {
|
||||
return;
|
||||
}
|
||||
var index = $(this).data("index");
|
||||
$("#hssm-delete-api-key-index").val(index);
|
||||
$("#hssm-delete-api-key-flag").val("1");
|
||||
$(this).closest("form").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user