wordpress-website-lifecycle/debug/debug-early-translations.php
2025-05-10 11:34:56 +00:00

24 lines
658 B
PHP

<?php
/*
* Plugin Name: Log early translations (DBG)
* Plugin URI: https://github.com/szepeviktor/wordpress-website-lifecycle
*/
add_filter(
'gettext',
static function ($translated, $text, $domain) {
if (did_action('plugins_loaded')) {
return $translated;
}
error_log('[DBG] Early translation: ('.$domain.') '.$text);
foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $trace) {
if (isset($trace['file'], $trace['line'])) {
error_log('[DBG] Stack trace: '.$trace['file'].':'.$trace['line']);
}
}
return $translated;
},
0,
3
);