PluginProbe
ActivityPub / 3.2.4
ActivityPub v3.2.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
← All changes | integration/load.php +68 -151 8.2.13.2.4 View file →
@@ -1,43 +1,33 @@
1 1 <?php
2 2 /**
3 3 * Load the ActivityPub integrations.
4 - *
5 - * @package Activitypub
6 4 */
7 5
8 6 namespace Activitypub\Integration;
9 7
10 -use function Activitypub\site_supports_blocks;
11 -
12 -\Activitypub\Autoloader::register_path( __NAMESPACE__, __DIR__ );
13 -
14 -/**
15 - * Initialize the ActivityPub integrations.
16 - */
17 8 function plugin_init() {
18 9 /**
19 - * Adds Akismet support.
10 + * Adds WebFinger (plugin) support.
20 11 *
21 - * This class handles the compatibility with the Akismet plugin.
12 + * This class handles the compatibility with the WebFinger plugin
13 + * and coordinates the internal WebFinger implementation.
22 14 *
23 - * @see https://wordpress.org/plugins/akismet/
15 + * @see https://wordpress.org/plugins/webfinger/
24 16 */
25 - if ( \defined( 'AKISMET_VERSION' ) ) {
26 - Akismet::init();
27 - }
17 + require_once __DIR__ . '/class-webfinger.php';
18 + Webfinger::init();
28 19
29 20 /**
30 - * Adds Classic Editor support.
21 + * Adds NodeInfo (plugin) support.
31 22 *
32 - * This class handles the compatibility with the Classic Editor plugin
33 - * and sites without block editor support.
23 + * This class handles the compatibility with the NodeInfo plugin
24 + * and coordinates the internal NodeInfo implementation.
34 25 *
35 - * @see https://wordpress.org/plugins/classic-editor/
26 + * @see https://wordpress.org/plugins/nodeinfo/
36 27 */
37 - if ( \class_exists( '\Classic_Editor' ) || \function_exists( 'classicpress_version' ) || ! site_supports_blocks() ) {
38 - Classic_Editor::init();
39 - }
28 + require_once __DIR__ . '/class-nodeinfo.php';
29 + Nodeinfo::init();
40 30
41 31 /**
42 32 * Adds Enable Mastodon Apps support.
43 33 *
@@ -44,54 +34,14 @@
44 34 * This class handles the compatibility with the Enable Mastodon Apps plugin.
45 35 *
46 36 * @see https://wordpress.org/plugins/enable-mastodon-apps/
47 37 */
48 - if ( \defined( 'ENABLE_MASTODON_APPS_VERSION' ) ) {
38 + if ( \defined( 'MASTODON_APPS_VERSION' ) ) {
39 + require_once __DIR__ . '/class-enable-mastodon-apps.php';
49 40 Enable_Mastodon_Apps::init();
50 41 }
51 42
52 43 /**
53 - * Adds Jetpack support.
54 - *
55 - * This class handles the compatibility with Jetpack.
56 - *
57 - * @see https://jetpack.com/
58 - */
59 - if ( \defined( 'JETPACK__VERSION' ) ) {
60 - Jetpack::init();
61 - }
62 -
63 - /**
64 - * Adds LiteSpeed Cache support.
65 - *
66 - * The check for whether LiteSpeed Cache is loaded and initialized happens inside Litespeed_Cache::init().
67 - *
68 - * @see https://wordpress.org/plugins/litespeed-cache/
69 - */
70 - Litespeed_Cache::init();
71 -
72 - /**
73 - * Adds Multisite Language Switcher support.
74 - *
75 - * This class handles the compatibility with the Multisite Language Switcher plugin.
76 - *
77 - * @see https://wordpress.org/plugins/multisite-language-switcher/
78 - */
79 - if ( \defined( 'MSLS_PLUGIN_VERSION' ) ) {
80 - Multisite_Language_Switcher::init();
81 - }
82 -
83 - /**
84 - * Adds NodeInfo (plugin) support.
85 - *
86 - * This class handles the compatibility with the NodeInfo plugin
87 - * and coordinates the internal NodeInfo implementation.
88 - *
89 - * @see https://wordpress.org/plugins/nodeinfo/
90 - */
91 - Nodeinfo::init();
92 -
93 - /**
94 44 * Adds OpenGraph support.
95 45 *
96 46 * This class handles the compatibility with the OpenGraph plugin.
97 47 *
@@ -97,37 +47,22 @@
97 47 *
98 48 * @see https://wordpress.org/plugins/opengraph/
99 49 */
100 50 if ( '1' === \get_option( 'activitypub_use_opengraph', '1' ) ) {
51 + require_once __DIR__ . '/class-opengraph.php';
101 52 Opengraph::init();
102 53 }
103 54
104 55 /**
105 - * Adds Podlove Podcast Publisher support.
56 + * Adds Jetpack support.
106 57 *
107 - * This class handles the compatibility with Podlove Podcast Publisher.
58 + * This class handles the compatibility with Jetpack.
108 59 *
109 - * @see https://wordpress.org/plugins/podlove-podcasting-plugin-for-wordpress/
60 + * @see https://jetpack.com/
110 61 */
111 - if ( \defined( 'Podlove\PLUGIN_FILE' ) ) {
112 - // Enable ActivityPub support for the podcast post type.
113 - \add_post_type_support( 'podcast', 'activitypub' );
114 -
115 - \add_filter(
116 - 'activitypub_transformer',
117 - static function ( $transformer, $data, $object_class ) {
118 - if (
119 - 'WP_Post' === $object_class &&
120 - 'podcast' === $data->post_type &&
121 - \Podlove\Model\Episode::find_one_by_post_id( $data->ID )
122 - ) {
123 - return new Podlove_Podcast_Publisher( $data );
124 - }
125 - return $transformer;
126 - },
127 - 10,
128 - 3
129 - );
62 + if ( \defined( 'JETPACK__VERSION' ) && ! \defined( 'IS_WPCOM' ) ) {
63 + require_once __DIR__ . '/class-jetpack.php';
64 + Jetpack::init();
130 65 }
131 66
132 67 /**
133 68 * Adds Seriously Simple Podcasting support.
@@ -138,14 +73,16 @@
138 73 */
139 74 if ( \defined( 'SSP_VERSION' ) ) {
140 75 add_filter(
141 76 'activitypub_transformer',
142 - static function ( $transformer, $data, $object_class ) {
77 + // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound
78 + function( $transformer, $object, $object_class ) {
143 79 if (
144 80 'WP_Post' === $object_class &&
145 - \get_post_meta( $data->ID, 'audio_file', true )
81 + \get_post_meta( $object->ID, 'audio_file', true )
146 82 ) {
147 - return new Seriously_Simple_Podcasting( $data );
83 + require_once __DIR__ . '/class-seriously-simple-podcasting.php';
84 + return new Seriously_Simple_Podcasting( $object );
148 85 }
149 86 return $transformer;
150 87 },
151 88 10,
@@ -151,80 +88,53 @@
151 88 10,
152 89 3
153 90 );
154 91 }
92 +}
93 +\add_action( 'plugins_loaded', __NAMESPACE__ . '\plugin_init' );
155 94
156 - /**
157 - * Adds Stream support.
158 - *
159 - * This class handles the compatibility with the Stream plugin.
160 - *
161 - * @see https://wordpress.org/plugins/stream/
162 - */
163 - Stream\Stream::init();
95 +/**
96 + * Register the Stream Connector for ActivityPub.
97 + *
98 + * @param array $classes The Stream connectors.
99 + *
100 + * @return array The Stream connectors with the ActivityPub connector.
101 + */
102 +function register_stream_connector( $classes ) {
103 + require plugin_dir_path( __FILE__ ) . '/class-stream-connector.php';
164 104
165 - /**
166 - * Adds Surge support.
167 - *
168 - * Only load code that needs Surge to run once Surge is loaded and initialized.
169 - *
170 - * @see https://wordpress.org/plugins/surge/
171 - */
172 - Surge::init();
105 + $class_name = '\Activitypub\Integration\Stream_Connector';
173 106
174 - /**
175 - * Adds WebFinger (plugin) support.
176 - *
177 - * This class handles the compatibility with the WebFinger plugin
178 - * and coordinates the internal WebFinger implementation.
179 - *
180 - * @see https://wordpress.org/plugins/webfinger/
181 - */
182 - Webfinger::init();
107 + if ( ! class_exists( $class_name ) ) {
108 + return;
109 + }
183 110
184 - /**
185 - * Adds WP REST Cache support.
186 - *
187 - * This class handles the compatibility with the WP REST Cache plugin.
188 - *
189 - * @see https://wordpress.org/plugins/wp-rest-cache/
190 - */
191 - if ( \class_exists( 'WP_Rest_Cache_Plugin\Includes\Plugin' ) ) {
192 - WP_Rest_Cache::init();
111 + wp_stream_get_instance();
112 + $class = new $class_name();
113 +
114 + if ( ! method_exists( $class, 'is_dependency_satisfied' ) ) {
115 + return;
193 116 }
194 117
195 - /**
196 - * Adds WPML Multilingual CMS (plugin) support.
197 - *
198 - * This class handles the compatibility with the WPML plugin.
199 - *
200 - * @see https://wpml.org/
201 - */
202 - if ( \defined( 'ICL_SITEPRESS_VERSION' ) ) {
203 - WPML::init();
118 + if ( $class->is_dependency_satisfied() ) {
119 + $classes[] = $class;
204 120 }
205 121
206 - /**
207 - * Adds Yoast SEO support.
208 - *
209 - * This class handles the compatibility with Yoast SEO.
210 - *
211 - * @see https://wordpress.org/plugins/wordpress-seo/
212 - */
213 - if ( \defined( 'WPSEO_VERSION' ) ) {
214 - Yoast_Seo::init();
215 - }
122 + return $classes;
216 123 }
217 -\add_action( 'plugins_loaded', __NAMESPACE__ . '\plugin_init' );
124 +add_filter( 'wp_stream_connectors', __NAMESPACE__ . '\register_stream_connector' );
218 125
219 -// Register activation and deactivation hooks for Surge integration.
220 -\register_activation_hook( ACTIVITYPUB_PLUGIN_FILE, array( __NAMESPACE__ . '\Surge', 'add_cache_config' ) );
221 -\register_deactivation_hook( ACTIVITYPUB_PLUGIN_FILE, array( __NAMESPACE__ . '\Surge', 'remove_cache_config' ) );
126 +// Excluded ActivityPub post types from the Stream.
127 +add_filter(
128 + 'wp_stream_posts_exclude_post_types',
129 + function( $post_types ) {
130 + $post_types[] = 'ap_follower';
131 + $post_types[] = 'ap_extrafield';
132 + $post_types[] = 'ap_extrafield_blog';
133 + return $post_types;
134 + }
135 +);
222 136
223 -// Register activation and deactivation hooks for LiteSpeed Cache integration.
224 -\register_activation_hook( ACTIVITYPUB_PLUGIN_FILE, array( __NAMESPACE__ . '\LiteSpeed_Cache', 'add_htaccess_rules' ) );
225 -\register_deactivation_hook( ACTIVITYPUB_PLUGIN_FILE, array( __NAMESPACE__ . '\LiteSpeed_Cache', 'remove_htaccess_rules' ) );
226 -
227 137 /**
228 138 * Load the BuddyPress integration.
229 139 *
230 140 * Only load code that needs BuddyPress to run once BP is loaded and initialized.
@@ -230,5 +140,12 @@
230 140 * Only load code that needs BuddyPress to run once BP is loaded and initialized.
231 141 *
232 142 * @see https://buddypress.org/
233 143 */
234 -\add_action( 'bp_include', array( __NAMESPACE__ . '\Buddypress', 'init' ), 0 );
144 +add_action(
145 + 'bp_include',
146 + function () {
147 + require_once __DIR__ . '/class-buddypress.php';
148 + Buddypress::init();
149 + },
150 + 0
151 +);