@@ -21,7 +21,11 @@ class Hub_Ajax {
2121
2222 private static $ registered = false ;
2323
24- public static function init () {
24+ private static $ addon_class = '' ;
25+
26+ public static function init ( $ gwp_addon_class = '' ) {
27+ self ::$ addon_class = (string ) $ gwp_addon_class ;
28+
2529 if ( self ::$ registered ) {
2630 return ;
2731 }
@@ -458,13 +462,37 @@ private static function fetch_wporg_download_link( $wporg_slug ) {
458462 return (string ) $ api ->download_link ;
459463 }
460464
461- /** Write a diagnostic line to wp-content/debug.log (always — short lines) . */
465+ /** Write a diagnostic line through the Gravity Forms add-on logger . */
462466 private static function log ( $ msg , $ context = array () ) {
467+ if ( '' === self ::$ addon_class || ! class_exists ( self ::$ addon_class ) || ! method_exists ( self ::$ addon_class , 'get_instance ' ) ) {
468+ return ;
469+ }
470+
471+ $ addon = call_user_func ( array ( self ::$ addon_class , 'get_instance ' ) );
472+ if ( ! is_object ( $ addon ) || ! method_exists ( $ addon , 'log_debug ' ) ) {
473+ return ;
474+ }
475+
463476 $ line = '[GWP_HUB_AJAX] ' . $ msg ;
464477 if ( ! empty ( $ context ) ) {
465- $ line .= ' ' . wp_json_encode ( $ context );
478+ $ line .= ' ' . wp_json_encode ( self :: redact_log_context ( $ context ) );
466479 }
467- error_log ( $ line );
480+ $ addon ->log_debug ( $ line );
481+ }
482+
483+ /** Redact signed/sensitive package URLs from log context. */
484+ private static function redact_log_context ( $ context ) {
485+ if ( is_array ( $ context ) ) {
486+ foreach ( $ context as $ key => $ value ) {
487+ if ( in_array ( $ key , array ( 'package ' , 'download_link ' ), true ) ) {
488+ $ context [ $ key ] = '[redacted] ' ;
489+ continue ;
490+ }
491+ $ context [ $ key ] = self ::redact_log_context ( $ value );
492+ }
493+ }
494+
495+ return $ context ;
468496 }
469497
470498 /** Flatten a WP_Error to a single readable line including data + child errors. */
0 commit comments