Created
January 15, 2026 19:45
-
-
Save nilovelez/b626521279e3ad26c46d12bbb9397f7b to your computer and use it in GitHub Desktop.
Code to test if a textdomain function is called before the init hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('init', function(){ | |
| define('MACHETE_DEBUG_INIT_PASSED', true); | |
| }, 1); | |
| add_filter( 'gettext_' . 'machete', 'machete_gettext_debug', 10, 2 ); | |
| function machete_gettext_debug( $text, $untranslated ) { | |
| if ( defined( 'MACHETE_DEBUG_INIT_PASSED' ) ) { | |
| return $text; | |
| } | |
| error_log( "Textdomain 'machete' was loaded. Stack trace:" ); | |
| $debug_backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 10 ); | |
| foreach ( $debug_backtrace as $trace ) { | |
| // if file starts with "D:\repos\" or "C:\Users\" | |
| if ( strpos( $trace['file'], 'D:\repos' ) === 0 ) { | |
| error_log( "Trace: " . print_r( $trace, true ) ); | |
| break; | |
| } | |
| } | |
| return $text; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if ( ! defined( 'WP_DEBUG' ) ) {
define( 'WP_DEBUG', true );
}
define( 'WP_DEBUG_LOG', true );
error_reporting(E_ALL);