PluginProbe
ActivityPub / 0.13.2
ActivityPub v0.13.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 / activitypub.php

activitypub.php in ActivityPub 0.13.2, at activitypub.php

118 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: ActivityPub
4 * Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
5 * Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
6 * Version: 0.13.2
7 * Author: Matthias Pfefferle
8 * Author URI: https://notiz.blog/
9 * License: MIT
10 * License URI: http://opensource.org/licenses/MIT
11 * Requires PHP: 5.6
12 * Text Domain: activitypub
13 * Domain Path: /languages
14 */
15
16 namespace Activitypub;
17
18 /**
19 * Initialize plugin
20 */
21 function init() {
22 \defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|^)#(\w*[A-Za-z_]+\w*)' );
23 \defined( 'ACTIVITYPUB_ALLOWED_HTML' ) || \define( 'ACTIVITYPUB_ALLOWED_HTML', '<strong><a><p><ul><ol><li><code><blockquote><pre><img>' );
24 \defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "<p><strong>%title%</strong></p>\n\n%content%\n\n<p>%hashtags%</p>\n\n<p>%shortlink%</p>" );
25
26 require_once \dirname( __FILE__ ) . '/includes/table/followers-list.php';
27 require_once \dirname( __FILE__ ) . '/includes/class-signature.php';
28 require_once \dirname( __FILE__ ) . '/includes/peer/class-followers.php';
29 require_once \dirname( __FILE__ ) . '/includes/functions.php';
30
31 require_once \dirname( __FILE__ ) . '/includes/model/class-activity.php';
32 require_once \dirname( __FILE__ ) . '/includes/model/class-post.php';
33
34 require_once \dirname( __FILE__ ) . '/includes/class-activity-dispatcher.php';
35 \Activitypub\Activity_Dispatcher::init();
36
37 require_once \dirname( __FILE__ ) . '/includes/class-activitypub.php';
38 \Activitypub\Activitypub::init();
39
40 // Configure the REST API route
41 require_once \dirname( __FILE__ ) . '/includes/rest/class-outbox.php';
42 \Activitypub\Rest\Outbox::init();
43
44 require_once \dirname( __FILE__ ) . '/includes/rest/class-inbox.php';
45 \Activitypub\Rest\Inbox::init();
46
47 require_once \dirname( __FILE__ ) . '/includes/rest/class-followers.php';
48 \Activitypub\Rest\Followers::init();
49
50 require_once \dirname( __FILE__ ) . '/includes/rest/class-following.php';
51 \Activitypub\Rest\Following::init();
52
53 require_once \dirname( __FILE__ ) . '/includes/rest/class-webfinger.php';
54 \Activitypub\Rest\Webfinger::init();
55
56 // load NodeInfo endpoints only if blog is public
57 if ( true === (bool) \get_option( 'blog_public', 1 ) ) {
58 require_once \dirname( __FILE__ ) . '/includes/rest/class-nodeinfo.php';
59 \Activitypub\Rest\NodeInfo::init();
60 }
61
62 require_once \dirname( __FILE__ ) . '/includes/class-admin.php';
63 \Activitypub\Admin::init();
64
65 require_once \dirname( __FILE__ ) . '/includes/class-hashtag.php';
66 \Activitypub\Hashtag::init();
67
68 require_once \dirname( __FILE__ ) . '/includes/class-debug.php';
69 \Activitypub\Debug::init();
70
71 require_once \dirname( __FILE__ ) . '/includes/class-health-check.php';
72 \Activitypub\Health_Check::init();
73
74 require_once \dirname( __FILE__ ) . '/includes/rest/class-server.php';
75 \add_filter( 'wp_rest_server_class', function() {
76 return '\Activitypub\Rest\Server';
77 } );
78
79 if ( \WP_DEBUG ) {
80 require_once \dirname( __FILE__ ) . '/includes/debug.php';
81 }
82 }
83 \add_action( 'plugins_loaded', '\Activitypub\init' );
84
85 /**
86 * Add rewrite rules
87 */
88 function add_rewrite_rules() {
89 if ( ! \class_exists( 'Webfinger' ) ) {
90 \add_rewrite_rule( '^.well-known/webfinger', 'index.php?rest_route=/activitypub/1.0/webfinger', 'top' );
91 }
92
93 if ( ! \class_exists( 'Nodeinfo' ) ) {
94 \add_rewrite_rule( '^.well-known/nodeinfo', 'index.php?rest_route=/activitypub/1.0/nodeinfo/discovery', 'top' );
95 \add_rewrite_rule( '^.well-known/x-nodeinfo2', 'index.php?rest_route=/activitypub/1.0/nodeinfo2', 'top' );
96 }
97 }
98 \add_action( 'init', '\Activitypub\add_rewrite_rules', 1 );
99
100 /**
101 * Flush rewrite rules;
102 */
103 function flush_rewrite_rules() {
104 \Activitypub\add_rewrite_rules();
105 \flush_rewrite_rules();
106 }
107 \register_activation_hook( __FILE__, '\Activitypub\flush_rewrite_rules' );
108 \register_deactivation_hook( __FILE__, '\flush_rewrite_rules' );
109
110 /**
111 * Only load code that needs BuddyPress to run once BP is loaded and initialized.
112 */
113 function enable_buddypress_features() {
114 require_once \dirname( __FILE__ ) . '/integration/class-buddypress.php';
115 \Activitypub\Integration\Buddypress::init();
116 }
117 add_action( 'bp_include', '\Activitypub\enable_buddypress_features' );
118