Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_llms_secure_log_messages( string $message, string $handle )

Automatically anonymize a list of registered “secure” strings before writing logs.

Description Description

This function is a callback for the llms_log_message_string filter. It loads secure strings defined in the llms_secure_strings filter and automatically anonymizes them when they are found within the supplied log message.

Top ↑

Parameters Parameters


(string) (Required) The string to log.


(string) (Required) Log file handle.

Top ↑

Return Return


Top ↑

Source Source

File: includes/functions/llms.functions.log.php

function _llms_secure_log_messages( $message, $handle ) {

	 * Filters a list of "secure" strings which should be anonymized prior to logging.
	 * A plugin or theme that might log potentially sensitive data (such as API keys), the
	 * API key strings can be registered with this filter to automatically be anonymized
	 * if they are found within logs.
	 * @since 6.4.0
	 * @param string[] $secure_strings An array of secure strings that should be anonymized.
	 * @param string   $handle         The log handle. This can be used to only register strings for a specific log file.
	$secure_strings = apply_filters( 'llms_secure_strings', array(), $handle );

	// Nothing to do.
	if ( empty( $secure_strings ) ) {
		return $message;

	$find    = array();
	$replace = array();

	foreach ( $secure_strings as $string ) {
		if ( false !== strpos( $message, $string ) ) {
			$find[]    = $string;
			$replace[] = llms_anonymize_string( $string );

	$message = str_replace( $find, $replace, $message );

	return $message;


Top ↑

Changelog Changelog

Version Description
6.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.