PluginProbe
ActivityPub / 0.14.0
ActivityPub v0.14.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 / activitypub.php

activitypub.php in ActivityPub 0.14.0, at activitypub.php

147 lines 5.3 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.14.0
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)|(?<=<p>)|(?<=<br>)|^)#([A-Za-z0-9_]+)(?:(?=\s|[[:punct:]]|$))' );
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 \define( 'ACTIVITYPUB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
26 \define( 'ACTIVITYPUB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
27 \define( 'ACTIVITYPUB_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) );
28
29 require_once \dirname( __FILE__ ) . '/includes/table/followers-list.php';
30 require_once \dirname( __FILE__ ) . '/includes/class-signature.php';
31 require_once \dirname( __FILE__ ) . '/includes/class-webfinger.php';
32 require_once \dirname( __FILE__ ) . '/includes/peer/class-followers.php';
33 require_once \dirname( __FILE__ ) . '/includes/functions.php';
34
35 require_once \dirname( __FILE__ ) . '/includes/model/class-activity.php';
36 require_once \dirname( __FILE__ ) . '/includes/model/class-post.php';
37
38 require_once \dirname( __FILE__ ) . '/includes/class-activity-dispatcher.php';
39 \Activitypub\Activity_Dispatcher::init();
40
41 require_once \dirname( __FILE__ ) . '/includes/class-activitypub.php';
42 \Activitypub\Activitypub::init();
43
44 // Configure the REST API route
45 require_once \dirname( __FILE__ ) . '/includes/rest/class-outbox.php';
46 \Activitypub\Rest\Outbox::init();
47
48 require_once \dirname( __FILE__ ) . '/includes/rest/class-inbox.php';
49 \Activitypub\Rest\Inbox::init();
50
51 require_once \dirname( __FILE__ ) . '/includes/rest/class-followers.php';
52 \Activitypub\Rest\Followers::init();
53
54 require_once \dirname( __FILE__ ) . '/includes/rest/class-following.php';
55 \Activitypub\Rest\Following::init();
56
57 require_once \dirname( __FILE__ ) . '/includes/rest/class-webfinger.php';
58 \Activitypub\Rest\Webfinger::init();
59
60 // load NodeInfo endpoints only if blog is public
61 if ( true === (bool) \get_option( 'blog_public', 1 ) ) {
62 require_once \dirname( __FILE__ ) . '/includes/rest/class-nodeinfo.php';
63 \Activitypub\Rest\NodeInfo::init();
64 }
65
66 require_once \dirname( __FILE__ ) . '/includes/class-admin.php';
67 \Activitypub\Admin::init();
68
69 require_once \dirname( __FILE__ ) . '/includes/class-hashtag.php';
70 \Activitypub\Hashtag::init();
71
72 require_once \dirname( __FILE__ ) . '/includes/class-debug.php';
73 \Activitypub\Debug::init();
74
75 require_once \dirname( __FILE__ ) . '/includes/class-health-check.php';
76 \Activitypub\Health_Check::init();
77
78 require_once \dirname( __FILE__ ) . '/includes/rest/class-server.php';
79 \add_filter(
80 'wp_rest_server_class',
81 function() {
82 return '\Activitypub\Rest\Server';
83 }
84 );
85
86 if ( \WP_DEBUG ) {
87 require_once \dirname( __FILE__ ) . '/includes/debug.php';
88 }
89 }
90 \add_action( 'plugins_loaded', '\Activitypub\init' );
91
92 /**
93 * Add plugin settings link
94 */
95 function plugin_settings_link( $actions ) {
96 $settings_link[] = \sprintf(
97 '<a href="%1s">%2s</a>',
98 \menu_page_url( 'activitypub', false ),
99 \__( 'Settings', 'activitypub' )
100 );
101
102 return \array_merge( $settings_link, $actions );
103 }
104 \add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), '\Activitypub\plugin_settings_link' );
105
106 /**
107 * Add rewrite rules
108 */
109 function add_rewrite_rules() {
110 if ( ! \class_exists( 'Webfinger' ) ) {
111 \add_rewrite_rule( '^.well-known/webfinger', 'index.php?rest_route=/activitypub/1.0/webfinger', 'top' );
112 }
113
114 if ( ! \class_exists( 'Nodeinfo' ) || ! (bool) \get_option( 'blog_public', 1 ) ) {
115 \add_rewrite_rule( '^.well-known/nodeinfo', 'index.php?rest_route=/activitypub/1.0/nodeinfo/discovery', 'top' );
116 \add_rewrite_rule( '^.well-known/x-nodeinfo2', 'index.php?rest_route=/activitypub/1.0/nodeinfo2', 'top' );
117 }
118 }
119 \add_action( 'init', '\Activitypub\add_rewrite_rules', 1 );
120
121 /**
122 * Flush rewrite rules;
123 */
124 function flush_rewrite_rules() {
125 \Activitypub\add_rewrite_rules();
126 \flush_rewrite_rules();
127 }
128 \register_activation_hook( __FILE__, '\Activitypub\flush_rewrite_rules' );
129 \register_deactivation_hook( __FILE__, '\flush_rewrite_rules' );
130
131 /**
132 * Only load code that needs BuddyPress to run once BP is loaded and initialized.
133 */
134 function enable_buddypress_features() {
135 require_once \dirname( __FILE__ ) . '/integration/class-buddypress.php';
136 \Activitypub\Integration\Buddypress::init();
137 }
138 add_action( 'bp_include', '\Activitypub\enable_buddypress_features' );
139
140 add_action(
141 'friends_load_parsers',
142 function( \Friends\Feed $friends_feed ) {
143 require_once __DIR__ . '/integration/class-friends-feed-parser-activitypub.php';
144 $friends_feed->register_parser( Friends_Feed_Parser_ActivityPub::SLUG, new Friends_Feed_Parser_ActivityPub( $friends_feed ) );
145 }
146 );
147