PluginProbe
ActivityPub / 7.8.2
ActivityPub v7.8.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
activitypub / includes / debug.php

debug.php in ActivityPub 7.8.2, at includes/debug.php

111 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Debugging functions.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub;
9
10 use Activitypub\Collection\Inbox;
11 use Activitypub\Collection\Outbox;
12 use Activitypub\Collection\Posts;
13
14 /**
15 * Allow localhost URLs if WP_DEBUG is true.
16 *
17 * @param array $parsed_args An array of HTTP request arguments.
18 *
19 * @return array Array or string of HTTP request arguments.
20 */
21 function allow_localhost( $parsed_args ) {
22 $parsed_args['reject_unsafe_urls'] = false;
23
24 return $parsed_args;
25 }
26 \add_filter( 'http_request_args', '\Activitypub\allow_localhost' );
27
28 /**
29 * Debug the outbox post type.
30 *
31 * @param array $args The arguments for the post type.
32 * @param string $post_type The post type.
33 *
34 * @return array The arguments for the post type.
35 */
36 function debug_post_type( $args, $post_type ) {
37 if ( ! \in_array( $post_type, array( Outbox::POST_TYPE, Inbox::POST_TYPE, Posts::POST_TYPE ), true ) ) {
38 return $args;
39 }
40
41 $args['show_ui'] = true;
42
43 if ( Outbox::POST_TYPE === $post_type ) {
44 $args['menu_icon'] = 'dashicons-upload';
45 } elseif ( Inbox::POST_TYPE === $post_type ) {
46 $args['menu_icon'] = 'dashicons-download';
47 } elseif ( Posts::POST_TYPE === $post_type ) {
48 $args['menu_icon'] = 'dashicons-media-document';
49 }
50
51 return $args;
52 }
53 \add_filter( 'register_post_type_args', '\Activitypub\debug_post_type', 10, 2 );
54
55 /**
56 * Debug the object type taxonomy.
57 *
58 * @param array $args The arguments for the taxonomy.
59 * @param string $taxonomy The taxonomy.
60 *
61 * @return array The arguments for the taxonomy.
62 */
63 function debug_taxonomy( $args, $taxonomy ) {
64 if ( ! in_array( $taxonomy, array( 'ap_object_type', 'ap_tag' ), true ) ) {
65 return $args;
66 }
67
68 $args['show_ui'] = true;
69 $args['show_in_menu'] = true;
70
71 return $args;
72 }
73 \add_filter( 'register_taxonomy_args', '\Activitypub\debug_taxonomy', 10, 2 );
74
75 /**
76 * Debug the outbox post type column.
77 *
78 * @param array $columns The columns.
79 * @param string $post_type The post type.
80 *
81 * @return array The updated columns.
82 */
83 function debug_outbox_post_type_column( $columns, $post_type ) {
84 if ( ! \in_array( $post_type, array( Outbox::POST_TYPE, Inbox::POST_TYPE ), true ) ) {
85 return $columns;
86 }
87
88 $columns['ap_meta'] = 'Meta';
89
90 return $columns;
91 }
92 \add_filter( 'manage_posts_columns', '\Activitypub\debug_outbox_post_type_column', 10, 2 );
93
94 /**
95 * Debug the outbox post type meta.
96 *
97 * @param string $column_name The column name.
98 * @param int $post_id The post ID.
99 *
100 * @return void
101 */
102 function manage_posts_custom_column( $column_name, $post_id ) {
103 if ( 'ap_meta' === $column_name ) {
104 $meta = \get_post_meta( $post_id );
105 foreach ( $meta as $key => $value ) {
106 echo \esc_attr( $key ) . ': ' . \esc_html( $value[0] ) . '<br>';
107 }
108 }
109 }
110 \add_action( 'manage_posts_custom_column', '\Activitypub\manage_posts_custom_column', 10, 2 );
111