| 1 |
<?php |
| 2 |
namespace Activitypub; |
| 3 |
|
| 4 |
/** |
| 5 |
* ActivityPub Debug Class |
| 6 |
* |
| 7 |
* @author Matthias Pfefferle |
| 8 |
*/ |
| 9 |
class Debug { |
| 10 |
/** |
| 11 |
* Initialize the class, registering WordPress hooks |
| 12 |
*/ |
| 13 |
public static function init() { |
| 14 |
if ( WP_DEBUG && WP_DEBUG_LOG ) { |
| 15 |
\add_action( 'activitypub_safe_remote_post_response', array( '\Activitypub\Debug', 'log_remote_post_responses' ), 10, 4 ); |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
public static function log_remote_post_responses( $response, $url, $body, $user_id ) { |
| 20 |
\error_log( "Request to: {$url} with response: " . \print_r( $response, true ) ); |
| 21 |
} |
| 22 |
|
| 23 |
public static function write_log( $log ) { |
| 24 |
if ( \is_array( $log ) || \is_object( $log ) ) { |
| 25 |
\error_log( \print_r( $log, true ) ); |
| 26 |
} else { |
| 27 |
\error_log( $log ); |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
|