PluginProbe
ActivityPub / 3.2.2
ActivityPub v3.2.2
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
← All changes | includes/class-debug.php +18 -8 1.3.03.2.2 View file →
@@ -3,8 +3,10 @@
3 3
4 4 use WP_DEBUG;
5 5 use WP_DEBUG_LOG;
6 6
7 +use function Activitypub\object_to_uri;
8 +
7 9 /**
8 10 * ActivityPub Debug Class
9 11 *
10 12 * @author Matthias Pfefferle
@@ -13,24 +15,32 @@
13 15 /**
14 16 * Initialize the class, registering WordPress hooks
15 17 */
16 18 public static function init() {
17 - if ( WP_DEBUG && WP_DEBUG_LOG ) {
19 + if ( WP_DEBUG_LOG ) {
18 20 \add_action( 'activitypub_safe_remote_post_response', array( self::class, 'log_remote_post_responses' ), 10, 4 );
21 + \add_action( 'activitypub_inbox', array( self::class, 'log_inbox' ), 10, 4 );
19 22 }
20 23 }
21 24
25 + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
22 26 public static function log_remote_post_responses( $response, $url, $body, $user_id ) {
23 27 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
24 - \error_log( "Request to: {$url} with response: " . \print_r( $response, true ) );
28 + \error_log( "[OUTBOX] Request to: {$url} with Response: " . \print_r( $response, true ) );
25 29 }
26 30
27 - public static function write_log( $log ) {
28 - if ( \is_array( $log ) || \is_object( $log ) ) {
31 + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
32 + public static function log_inbox( $data, $user_id, $type, $activity ) {
33 + $type = strtolower( $type );
34 +
35 + if ( 'delete' !== $type ) {
36 + $url = object_to_uri( $data['actor'] );
29 37 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
30 - \error_log( \print_r( $log, true ) );
31 - } else {
32 - // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
33 - \error_log( $log );
38 + \error_log( "[INBOX] Request From: {$url} with Activity: " . \print_r( $data, true ) );
34 39 }
40 + }
41 +
42 + public static function write_log( $log ) {
43 + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
44 + \error_log( \print_r( $log, true ) );
35 45 }
36 46 }