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