| @@ -6,10 +6,8 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace Activitypub\Integration; |
| 9 | 9 | |
| 10 | -use function Activitypub\site_supports_blocks; | |
| 11 | - | |
| 12 | 10 | \Activitypub\Autoloader::register_path( __NAMESPACE__, __DIR__ ); |
| 13 | 11 | |
| 14 | 12 | /** |
| 15 | 13 | * Initialize the ActivityPub integrations. |
| @@ -15,29 +13,26 @@ | ||
| 15 | 13 | * Initialize the ActivityPub integrations. |
| 16 | 14 | */ |
| 17 | 15 | function plugin_init() { |
| 18 | 16 | /** |
| 19 | - * Adds Akismet support. | |
| 17 | + * Adds WebFinger (plugin) support. | |
| 20 | 18 | * |
| 21 | - * This class handles the compatibility with the Akismet plugin. | |
| 19 | + * This class handles the compatibility with the WebFinger plugin | |
| 20 | + * and coordinates the internal WebFinger implementation. | |
| 22 | 21 | * |
| 23 | - * @see https://wordpress.org/plugins/akismet/ | |
| 22 | + * @see https://wordpress.org/plugins/webfinger/ | |
| 24 | 23 | */ |
| 25 | - if ( \defined( 'AKISMET_VERSION' ) ) { | |
| 26 | - Akismet::init(); | |
| 27 | - } | |
| 24 | + Webfinger::init(); | |
| 28 | 25 | |
| 29 | 26 | /** |
| 30 | - * Adds Classic Editor support. | |
| 27 | + * Adds NodeInfo (plugin) support. | |
| 31 | 28 | * |
| 32 | - * This class handles the compatibility with the Classic Editor plugin | |
| 33 | - * and sites without block editor support. | |
| 29 | + * This class handles the compatibility with the NodeInfo plugin | |
| 30 | + * and coordinates the internal NodeInfo implementation. | |
| 34 | 31 | * |
| 35 | - * @see https://wordpress.org/plugins/classic-editor/ | |
| 32 | + * @see https://wordpress.org/plugins/nodeinfo/ | |
| 36 | 33 | */ |
| 37 | - if ( \class_exists( '\Classic_Editor' ) || \function_exists( 'classicpress_version' ) || ! site_supports_blocks() ) { | |
| 38 | - Classic_Editor::init(); | |
| 39 | - } | |
| 34 | + Nodeinfo::init(); | |
| 40 | 35 | |
| 41 | 36 | /** |
| 42 | 37 | * Adds Enable Mastodon Apps support. |
| 43 | 38 | * |
| @@ -49,88 +44,41 @@ | ||
| 49 | 44 | Enable_Mastodon_Apps::init(); |
| 50 | 45 | } |
| 51 | 46 | |
| 52 | 47 | /** |
| 53 | - * Adds Jetpack support. | |
| 48 | + * Adds OpenGraph support. | |
| 54 | 49 | * |
| 55 | - * This class handles the compatibility with Jetpack. | |
| 50 | + * This class handles the compatibility with the OpenGraph plugin. | |
| 56 | 51 | * |
| 57 | - * @see https://jetpack.com/ | |
| 52 | + * @see https://wordpress.org/plugins/opengraph/ | |
| 58 | 53 | */ |
| 59 | - if ( \defined( 'JETPACK__VERSION' ) ) { | |
| 60 | - Jetpack::init(); | |
| 54 | + if ( '1' === \get_option( 'activitypub_use_opengraph', '1' ) ) { | |
| 55 | + Opengraph::init(); | |
| 61 | 56 | } |
| 62 | 57 | |
| 63 | 58 | /** |
| 64 | - * Adds LiteSpeed Cache support. | |
| 59 | + * Adds Jetpack support. | |
| 65 | 60 | * |
| 66 | - * The check for whether LiteSpeed Cache is loaded and initialized happens inside Litespeed_Cache::init(). | |
| 61 | + * This class handles the compatibility with Jetpack. | |
| 67 | 62 | * |
| 68 | - * @see https://wordpress.org/plugins/litespeed-cache/ | |
| 63 | + * @see https://jetpack.com/ | |
| 69 | 64 | */ |
| 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(); | |
| 65 | + if ( \defined( 'JETPACK__VERSION' ) && ! \defined( 'IS_WPCOM' ) ) { | |
| 66 | + Jetpack::init(); | |
| 81 | 67 | } |
| 82 | 68 | |
| 83 | 69 | /** |
| 84 | - * Adds NodeInfo (plugin) support. | |
| 70 | + * Adds Akismet support. | |
| 85 | 71 | * |
| 86 | - * This class handles the compatibility with the NodeInfo plugin | |
| 87 | - * and coordinates the internal NodeInfo implementation. | |
| 72 | + * This class handles the compatibility with the Akismet plugin. | |
| 88 | 73 | * |
| 89 | - * @see https://wordpress.org/plugins/nodeinfo/ | |
| 74 | + * @see https://wordpress.org/plugins/akismet/ | |
| 90 | 75 | */ |
| 91 | - Nodeinfo::init(); | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * Adds OpenGraph support. | |
| 95 | - * | |
| 96 | - * This class handles the compatibility with the OpenGraph plugin. | |
| 97 | - * | |
| 98 | - * @see https://wordpress.org/plugins/opengraph/ | |
| 99 | - */ | |
| 100 | - if ( '1' === \get_option( 'activitypub_use_opengraph', '1' ) ) { | |
| 101 | - Opengraph::init(); | |
| 76 | + if ( \defined( 'AKISMET_VERSION' ) ) { | |
| 77 | + Akismet::init(); | |
| 102 | 78 | } |
| 103 | 79 | |
| 104 | 80 | /** |
| 105 | - * Adds Podlove Podcast Publisher support. | |
| 106 | - * | |
| 107 | - * This class handles the compatibility with Podlove Podcast Publisher. | |
| 108 | - * | |
| 109 | - * @see https://wordpress.org/plugins/podlove-podcasting-plugin-for-wordpress/ | |
| 110 | - */ | |
| 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 | - ); | |
| 130 | - } | |
| 131 | - | |
| 132 | - /** | |
| 133 | 81 | * Adds Seriously Simple Podcasting support. |
| 134 | 82 | * |
| 135 | 83 | * This class handles the compatibility with Seriously Simple Podcasting. |
| 136 | 84 | * |
| @@ -138,9 +86,9 @@ | ||
| 138 | 86 | */ |
| 139 | 87 | if ( \defined( 'SSP_VERSION' ) ) { |
| 140 | 88 | add_filter( |
| 141 | 89 | 'activitypub_transformer', |
| 142 | - static function ( $transformer, $data, $object_class ) { | |
| 90 | + function ( $transformer, $data, $object_class ) { | |
| 143 | 91 | if ( |
| 144 | 92 | 'WP_Post' === $object_class && |
| 145 | 93 | \get_post_meta( $data->ID, 'audio_file', true ) |
| 146 | 94 | ) { |
| @@ -153,47 +101,8 @@ | ||
| 153 | 101 | ); |
| 154 | 102 | } |
| 155 | 103 | |
| 156 | 104 | /** |
| 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(); | |
| 164 | - | |
| 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(); | |
| 173 | - | |
| 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(); | |
| 183 | - | |
| 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(); | |
| 193 | - } | |
| 194 | - | |
| 195 | - /** | |
| 196 | 105 | * Adds WPML Multilingual CMS (plugin) support. |
| 197 | 106 | * |
| 198 | 107 | * This class handles the compatibility with the WPML plugin. |
| 199 | 108 | * |
| @@ -201,30 +110,40 @@ | ||
| 201 | 110 | */ |
| 202 | 111 | if ( \defined( 'ICL_SITEPRESS_VERSION' ) ) { |
| 203 | 112 | WPML::init(); |
| 204 | 113 | } |
| 114 | +} | |
| 115 | +\add_action( 'plugins_loaded', __NAMESPACE__ . '\plugin_init' ); | |
| 205 | 116 | |
| 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(); | |
| 117 | +/** | |
| 118 | + * Register the Stream Connector for ActivityPub. | |
| 119 | + * | |
| 120 | + * @param array $classes The Stream connectors. | |
| 121 | + * | |
| 122 | + * @return array The Stream connectors with the ActivityPub connector. | |
| 123 | + */ | |
| 124 | +function register_stream_connector( $classes ) { | |
| 125 | + $class = new Stream_Connector(); | |
| 126 | + | |
| 127 | + if ( method_exists( $class, 'is_dependency_satisfied' ) && $class->is_dependency_satisfied() ) { | |
| 128 | + $classes[] = $class; | |
| 215 | 129 | } |
| 130 | + | |
| 131 | + return $classes; | |
| 216 | 132 | } |
| 217 | -\add_action( 'plugins_loaded', __NAMESPACE__ . '\plugin_init' ); | |
| 133 | +add_filter( 'wp_stream_connectors', __NAMESPACE__ . '\register_stream_connector' ); | |
| 218 | 134 | |
| 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' ) ); | |
| 135 | +// Excluded ActivityPub post types from the Stream. | |
| 136 | +add_filter( | |
| 137 | + 'wp_stream_posts_exclude_post_types', | |
| 138 | + function ( $post_types ) { | |
| 139 | + $post_types[] = 'ap_follower'; | |
| 140 | + $post_types[] = 'ap_extrafield'; | |
| 141 | + $post_types[] = 'ap_extrafield_blog'; | |
| 142 | + return $post_types; | |
| 143 | + } | |
| 144 | +); | |
| 222 | 145 | |
| 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 | 146 | /** |
| 228 | 147 | * Load the BuddyPress integration. |
| 229 | 148 | * |
| 230 | 149 | * Only load code that needs BuddyPress to run once BP is loaded and initialized. |
| @@ -230,5 +149,5 @@ | ||
| 230 | 149 | * Only load code that needs BuddyPress to run once BP is loaded and initialized. |
| 231 | 150 | * |
| 232 | 151 | * @see https://buddypress.org/ |
| 233 | 152 | */ |
| 234 | -\add_action( 'bp_include', array( __NAMESPACE__ . '\Buddypress', 'init' ), 0 ); | |
| 153 | +add_action( 'bp_include', array( __NAMESPACE__ . '\Buddypress', 'init' ), 0 ); | |