Skip to content

Commit 7a8b586

Browse files
authored
Integrations: Use Autoloader (#1052)
* Use WP Autoloader class * Load Autoloader first thing so it can be used at any time after that. * Integrations: Use Autoloader
1 parent f07cb12 commit 7a8b586

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

integration/load.php

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Activitypub\Integration;
99

10+
\Activitypub\Autoloader::register_path( __NAMESPACE__, __DIR__ );
11+
1012
/**
1113
* Initialize the ActivityPub integrations.
1214
*/
@@ -19,7 +21,6 @@ function plugin_init() {
1921
*
2022
* @see https://wordpress.org/plugins/webfinger/
2123
*/
22-
require_once __DIR__ . '/class-webfinger.php';
2324
Webfinger::init();
2425

2526
/**
@@ -30,7 +31,6 @@ function plugin_init() {
3031
*
3132
* @see https://wordpress.org/plugins/nodeinfo/
3233
*/
33-
require_once __DIR__ . '/class-nodeinfo.php';
3434
Nodeinfo::init();
3535

3636
/**
@@ -41,7 +41,6 @@ function plugin_init() {
4141
* @see https://wordpress.org/plugins/enable-mastodon-apps/
4242
*/
4343
if ( \defined( 'ENABLE_MASTODON_APPS_VERSION' ) ) {
44-
require_once __DIR__ . '/class-enable-mastodon-apps.php';
4544
Enable_Mastodon_Apps::init();
4645
}
4746

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

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

@@ -84,7 +81,6 @@ function ( $transformer, $data, $object_class ) {
8481
'WP_Post' === $object_class &&
8582
\get_post_meta( $data->ID, 'audio_file', true )
8683
) {
87-
require_once __DIR__ . '/class-seriously-simple-podcasting.php';
8884
return new Seriously_Simple_Podcasting( $data );
8985
}
9086
return $transformer;
@@ -104,22 +100,9 @@ function ( $transformer, $data, $object_class ) {
104100
* @return array The Stream connectors with the ActivityPub connector.
105101
*/
106102
function register_stream_connector( $classes ) {
107-
require plugin_dir_path( __FILE__ ) . '/class-stream-connector.php';
108-
109-
$class_name = '\Activitypub\Integration\Stream_Connector';
110-
111-
if ( ! class_exists( $class_name ) ) {
112-
return;
113-
}
103+
$class = new Stream_Connector();
114104

115-
wp_stream_get_instance();
116-
$class = new $class_name();
117-
118-
if ( ! method_exists( $class, 'is_dependency_satisfied' ) ) {
119-
return;
120-
}
121-
122-
if ( $class->is_dependency_satisfied() ) {
105+
if ( method_exists( $class, 'is_dependency_satisfied' ) && $class->is_dependency_satisfied() ) {
123106
$classes[] = $class;
124107
}
125108

@@ -145,11 +128,4 @@ function ( $post_types ) {
145128
*
146129
* @see https://buddypress.org/
147130
*/
148-
add_action(
149-
'bp_include',
150-
function () {
151-
require_once __DIR__ . '/class-buddypress.php';
152-
Buddypress::init();
153-
},
154-
0
155-
);
131+
add_action( 'bp_include', array( __NAMESPACE__ . '\Buddypress', 'init' ), 0 );

0 commit comments

Comments
 (0)