do not load NodeInfo class if blog is private

This commit is contained in:
Matthias Pfefferle 2020-05-23 12:34:42 +02:00
parent 827aacc450
commit 2a1cc45124
2 changed files with 8 additions and 7 deletions

View file

@ -52,8 +52,11 @@ function init() {
require_once \dirname( __FILE__ ) . '/includes/rest/class-webfinger.php';
\Activitypub\Rest\Webfinger::init();
// load NodeInfo endpoints only if blog is public
if ( 1 === get_option( 'blog_public', 1 ) ) {
require_once \dirname( __FILE__ ) . '/includes/rest/class-nodeinfo.php';
\Activitypub\Rest\NodeInfo::init();
}
require_once \dirname( __FILE__ ) . '/includes/class-admin.php';
\Activitypub\Admin::init();

View file

@ -13,12 +13,10 @@ class Nodeinfo {
* Initialize the class, registering WordPress hooks
*/
public static function init() {
if ( 1 === get_option( 'blog_public', 1 ) ) {
\add_action( 'rest_api_init', array( '\Activitypub\Rest\Nodeinfo', 'register_routes' ) );
\add_filter( 'nodeinfo_data', array( '\Activitypub\Rest\Nodeinfo', 'add_nodeinfo_discovery' ), 10, 2 );
\add_filter( 'nodeinfo2_data', array( '\Activitypub\Rest\Nodeinfo', 'add_nodeinfo2_discovery' ), 10 );
}
}
/**
* Register routes