PluginProbe
ActivityPub / 2.4.0
ActivityPub v2.4.0
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 2.4.0, at includes/class-debug.php

38 lines 1.2 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 use WP_DEBUG;
5 use WP_DEBUG_LOG;
6
7 /**
8 * ActivityPub Debug Class
9 *
10 * @author Matthias Pfefferle
11 */
12 class Debug {
13 /**
14 * Initialize the class, registering WordPress hooks
15 */
16 public static function init() {
17 if ( WP_DEBUG_LOG ) {
18 \add_action( 'activitypub_safe_remote_post_response', array( self::class, 'log_remote_post_responses' ), 10, 4 );
19 }
20 }
21
22 // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
23 public static function log_remote_post_responses( $response, $url, $body, $user_id ) {
24 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
25 \error_log( "Request to: {$url} with response: " . \print_r( $response, true ) );
26 }
27
28 public static function write_log( $log ) {
29 if ( \is_array( $log ) || \is_object( $log ) ) {
30 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
31 \error_log( \print_r( $log, true ) );
32 } else {
33 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
34 \error_log( $log );
35 }
36 }
37 }
38