Skip to content

Commit

Permalink
Integrations: Use Autoloader (#1052)
Browse files Browse the repository at this point in the history
* Use WP Autoloader class

* Load Autoloader first thing so it can be used at any time after that.

* Integrations: Use Autoloader
  • Loading branch information
obenland authored Dec 9, 2024
1 parent f07cb12 commit 7a8b586
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions integration/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Activitypub\Integration;

\Activitypub\Autoloader::register_path( __NAMESPACE__, __DIR__ );

/**
* Initialize the ActivityPub integrations.
*/
Expand All @@ -19,7 +21,6 @@ function plugin_init() {
*
* @see https://wordpress.org/plugins/webfinger/
*/
require_once __DIR__ . '/class-webfinger.php';
Webfinger::init();

/**
Expand All @@ -30,7 +31,6 @@ function plugin_init() {
*
* @see https://wordpress.org/plugins/nodeinfo/
*/
require_once __DIR__ . '/class-nodeinfo.php';
Nodeinfo::init();

/**
Expand All @@ -41,7 +41,6 @@ function plugin_init() {
* @see https://wordpress.org/plugins/enable-mastodon-apps/
*/
if ( \defined( 'ENABLE_MASTODON_APPS_VERSION' ) ) {
require_once __DIR__ . '/class-enable-mastodon-apps.php';
Enable_Mastodon_Apps::init();
}

Expand All @@ -53,7 +52,6 @@ function plugin_init() {
* @see https://wordpress.org/plugins/opengraph/
*/
if ( '1' === \get_option( 'activitypub_use_opengraph', '1' ) ) {
require_once __DIR__ . '/class-opengraph.php';
Opengraph::init();
}

Expand All @@ -65,7 +63,6 @@ function plugin_init() {
* @see https://jetpack.com/
*/
if ( \defined( 'JETPACK__VERSION' ) && ! \defined( 'IS_WPCOM' ) ) {
require_once __DIR__ . '/class-jetpack.php';
Jetpack::init();
}

Expand All @@ -84,7 +81,6 @@ function ( $transformer, $data, $object_class ) {
'WP_Post' === $object_class &&
\get_post_meta( $data->ID, 'audio_file', true )
) {
require_once __DIR__ . '/class-seriously-simple-podcasting.php';
return new Seriously_Simple_Podcasting( $data );
}
return $transformer;
Expand All @@ -104,22 +100,9 @@ function ( $transformer, $data, $object_class ) {
* @return array The Stream connectors with the ActivityPub connector.
*/
function register_stream_connector( $classes ) {
require plugin_dir_path( __FILE__ ) . '/class-stream-connector.php';

$class_name = '\Activitypub\Integration\Stream_Connector';

if ( ! class_exists( $class_name ) ) {
return;
}
$class = new Stream_Connector();

wp_stream_get_instance();
$class = new $class_name();

if ( ! method_exists( $class, 'is_dependency_satisfied' ) ) {
return;
}

if ( $class->is_dependency_satisfied() ) {
if ( method_exists( $class, 'is_dependency_satisfied' ) && $class->is_dependency_satisfied() ) {
$classes[] = $class;
}

Expand All @@ -145,11 +128,4 @@ function ( $post_types ) {
*
* @see https://buddypress.org/
*/
add_action(
'bp_include',
function () {
require_once __DIR__ . '/class-buddypress.php';
Buddypress::init();
},
0
);
add_action( 'bp_include', array( __NAMESPACE__ . '\Buddypress', 'init' ), 0 );

0 comments on commit 7a8b586

Please sign in to comment.