PluginProbe
ActivityPub / 0.13.4
ActivityPub v0.13.4
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.4, at activitypub.php

135 lines 4.6 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.4
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(
76 'wp_rest_server_class',
77 function() {
78 return '\Activitypub\Rest\Server';
79 }
80 );
81
82 if ( \WP_DEBUG ) {
83 require_once \dirname( __FILE__ ) . '/includes/debug.php';
84 }
85 }
86 \add_action( 'plugins_loaded', '\Activitypub\init' );
87
88 /**
89 * Add plugin settings link
90 */
91 function plugin_settings_link( $actions ) {
92 $settings_link[] = \sprintf(
93 '<a href="%1s">%2s</a>',
94 \menu_page_url( 'activitypub', false ),
95 \__( 'Settings', 'activitypub' )
96 );
97
98 return \array_merge( $settings_link, $actions );
99 }
100 \add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), '\Activitypub\plugin_settings_link' );
101
102 /**
103 * Add rewrite rules
104 */
105 function add_rewrite_rules() {
106 if ( ! \class_exists( 'Webfinger' ) ) {
107 \add_rewrite_rule( '^.well-known/webfinger', 'index.php?rest_route=/activitypub/1.0/webfinger', 'top' );
108 }
109
110 if ( ! \class_exists( 'Nodeinfo' ) ) {
111 \add_rewrite_rule( '^.well-known/nodeinfo', 'index.php?rest_route=/activitypub/1.0/nodeinfo/discovery', 'top' );
112 \add_rewrite_rule( '^.well-known/x-nodeinfo2', 'index.php?rest_route=/activitypub/1.0/nodeinfo2', 'top' );
113 }
114 }
115 \add_action( 'init', '\Activitypub\add_rewrite_rules', 1 );
116
117 /**
118 * Flush rewrite rules;
119 */
120 function flush_rewrite_rules() {
121 \Activitypub\add_rewrite_rules();
122 \flush_rewrite_rules();
123 }
124 \register_activation_hook( __FILE__, '\Activitypub\flush_rewrite_rules' );
125 \register_deactivation_hook( __FILE__, '\flush_rewrite_rules' );
126
127 /**
128 * Only load code that needs BuddyPress to run once BP is loaded and initialized.
129 */
130 function enable_buddypress_features() {
131 require_once \dirname( __FILE__ ) . '/integration/class-buddypress.php';
132 \Activitypub\Integration\Buddypress::init();
133 }
134 add_action( 'bp_include', '\Activitypub\enable_buddypress_features' );
135