Skip to content

Instantly share code, notes, and snippets.

@zartgesotten
Last active October 15, 2022 16:53
Show Gist options
  • Save zartgesotten/1589c823b1d1e2a33063868a0990cb8d to your computer and use it in GitHub Desktop.
Save zartgesotten/1589c823b1d1e2a33063868a0990cb8d to your computer and use it in GitHub Desktop.
<?php
add_action( 'delete_attachment', function( $postid ) {
$past_backtrace = get_option( 'backtrace_for_deletion', [] );
$current_backtrace = debug_backtrace();
$past_backtrace[] = json_encode( $current_backtrace );
update_option( 'backtrace_for_deletion', $past_backtrace );
});
$backtraces = get_option( 'backtrace_for_deletion' );
foreach( $backtraces as $backtrace ) {
?>
<pre>
<?php
print_r( json_decode( $backtrace ) );
echo '-----------------------------------------------------------------------------------';
?>
</pre>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment