Files
dostavka_vodi/wp-content/plugins/robin-image-optimizer/admin/ajax/logs.php
Anton.AE 3e42863ef5 Task_12281 (#1)
Co-authored-by: User A0264400 <a0264400@jarl.from.sh>
Reviewed-on: #1
Co-authored-by: Anton.AE <ab.an.ev@yandex.ru>
Co-committed-by: Anton.AE <ab.an.ev@yandex.ru>
2026-07-05 16:07:04 +03:00

32 lines
608 B
PHP

<?php
/**
* Used to clean-up logs.
*/
add_action(
'wp_ajax_wrio_logs_cleanup',
function () {
check_admin_referer( 'wrio_clean_logs', 'nonce' );
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( - 1 );
}
if ( ! WRIO_Plugin::app()->logger->clean_up() ) {
wp_send_json_error(
[
'message' => esc_html__( 'Failed to clear logs. Please try again later.', 'robin-image-optimizer' ),
'type' => 'danger',
]
);
}
wp_send_json(
[
'message' => esc_html__( 'Logs cleared successfully.', 'robin-image-optimizer' ),
'type' => 'success',
]
);
}
);