__( 'Security token expired. Please reload the page.', 'aiforya-activity-log' ) ], 403 ); } if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( [ 'message' => __( 'Permission denied.', 'aiforya-activity-log' ) ], 403 ); } } /** * @return void */ public function save_settings(): void { $this->guard(); // phpcs:disable WordPress.Security.NonceVerification.Missing -- the nonce IS verified: guard() calls check_ajax_referer( 'aiforya_al_ajax', 'nonce', false ) on the line above and exits with a 403 when it fails. PHPCS does not follow method calls, so it cannot see it. // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitizing here would flatten the array; every value is sanitized field by field, against a whitelist of known keys, in Aiforya_Al_Settings::save() (booleans through ! empty(), retention_days clamped to 1..3650 through (int) with min/max). Nothing else from the payload survives. $in = isset( $_POST['settings'] ) && is_array( $_POST['settings'] ) ? wp_unslash( $_POST['settings'] ) : []; // phpcs:enable WordPress.Security.NonceVerification.Missing // phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized Aiforya_Al_Settings::get_instance()->save( $in ); wp_send_json_success( [ 'message' => __( 'Settings saved.', 'aiforya-activity-log' ) ] ); } /** * @return void */ public function clear_log(): void { $this->guard(); Aiforya_Al_Repository::get_instance()->clear(); wp_send_json_success( [ 'message' => __( 'Log cleared.', 'aiforya-activity-log' ) ] ); } } endif;