Added a woocommerce_disable_api_access_log filter. (#37332)

Co-authored-by: Mindaugas Budreika <mindaugas.budreika@thecoffeemate.group>
Co-authored-by: Néstor Soriano <konamiman@konamiman.com>
This commit is contained in:
Mindaugas Budreika 2023-04-17 11:40:27 +04:00 committed by GitHub
parent a4a2ef732d
commit e725a98f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: enhancement
Added a woocommerce_disable_api_access_log filter to disable last access logging for rest api.

View File

@ -587,6 +587,19 @@ class WC_REST_Authentication {
private function update_last_access() {
global $wpdb;
/**
* This filter enables the exclusion of the most recent access time from being logged for REST API calls.
*
* @param bool $result Default value.
* @param int $key_id Key ID associated with REST API request.
* @param int $user_id User ID associated with REST API request.
*
* @since 7.7.0
*/
if ( apply_filters( 'woocommerce_disable_rest_api_access_log', false, $this->user->key_id, $this->user->user_id ) ) {
return;
}
$wpdb->update(
$wpdb->prefix . 'woocommerce_api_keys',
array( 'last_access' => current_time( 'mysql' ) ),