PluginProbe
ActivityPub / 0.14.3
ActivityPub v0.14.3
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
activitypub / includes / class-debug.php

class-debug.php in ActivityPub 0.14.3, at includes/class-debug.php

34 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
21 \error_log( "Request to: {$url} with response: " . \print_r( $response, true ) );
22 }
23
24 public static function write_log( $log ) {
25 if ( \is_array( $log ) || \is_object( $log ) ) {
26 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
27 \error_log( \print_r( $log, true ) );
28 } else {
29 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
30 \error_log( $log );
31 }
32 }
33 }
34