Automattic\WooCommerce\Internal\Logging
RemoteLogger::sanitize
Sanitize the content to exclude sensitive data.
The trace is sanitized by:
- Remove the absolute path to the plugin directory based on WC_ABSPATH. This is more accurate than using WP_PLUGIN_DIR when the plugin is symlinked.
- Remove the absolute path to the WordPress root directory.
- Redact potential user data such as email addresses and phone numbers.
For example, the trace:
/var/www/html/wp-content/plugins/woocommerce/includes/class-wc-remote-logger.php on line 123 will be sanitized to: **\/woocommerce/includes/class-wc-remote-logger.php on line 123
Additionally, any user data like email addresses or phone numbers will be redacted.
Method of the class: RemoteLogger{}
Hooks from the method
Returns
String. The sanitized content.
Usage
// private - for code of main (parent) class only $result = $this->sanitize( $content );
- $content(string) (required)
- The content to sanitize.
RemoteLogger::sanitize() RemoteLogger::sanitize code WC 10.7.0
private function sanitize( $content ) {
if ( ! is_string( $content ) ) {
return $content;
}
$sanitized = $this->normalize_paths( $content );
$sanitized = $this->redact_user_data( $sanitized );
if ( ! function_exists( 'apply_filters' ) ) {
require_once ABSPATH . WPINC . '/plugin.php';
}
/**
* Filter the sanitized log content before it's sent to the remote logging service.
*
* @since 9.5.0
*
* @param string $sanitized The sanitized content.
* @param string $content The original content.
*/
return apply_filters( 'woocommerce_remote_logger_sanitized_content', $sanitized, $content );
}