Skip to content

Instantly share code, notes, and snippets.

@Nekaravaev
Last active April 11, 2023 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nekaravaev/041b126ffb905422c5524bc611fe4ec4 to your computer and use it in GitHub Desktop.
Save Nekaravaev/041b126ffb905422c5524bc611fe4ec4 to your computer and use it in GitHub Desktop.
[wordpress] Debug switch_to_blog snippet
<?php
\add_action('switch_blog', function ($new_blog_id, $prev_blog_id, $context) {
error_log("Switch! {$prev_blog_id} -> {$new_blog_id}. Context: {$context}");
if (count($GLOBALS['_wp_switched_stack']) > 1) {
error_log('Catch anomaly with _wp_switched_stack!');
$e = new \Exception;
error_log($e->getTraceAsString()));
}
}, 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment