Created
July 30, 2020 17:15
-
-
Save jchristopher/ef0b528251d736f4a7835b390644cd0d to your computer and use it in GitHub Desktop.
Log backtrace for SearchWP Post edit event
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
<?php | |
add_action( 'searchwp\source\post\drop', function( $args ) { | |
do_action( 'searchwp\debug\log', "Drop event for post {$args['post_id']}", 'backtrace' ); | |
$e = new \Exception(); | |
$trace = explode( "\n", $e->getTraceAsString() ); | |
$trace = array_reverse( $trace ); | |
array_shift( $trace ); | |
array_pop( $trace ); | |
$length = count( $trace ); | |
$result = []; | |
for ( $i = 0; $i < $length; $i++ ) { | |
$result[] = ( $i + 1 ) . ')' . substr( $trace[ $i ], strpos( $trace[ $i ], ' ') ); | |
} | |
do_action( 'searchwp\debug\log', "\n\t" . implode( "\n\t", $result ), 'backtrace' ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment