Only return nodeinfo data if site is public

This commit is contained in:
Django Doucet 2020-05-18 17:32:17 -04:00
parent 19a7bddc5f
commit 3d573aa140

View file

@ -13,10 +13,12 @@ class Nodeinfo {
* Initialize the class, registering WordPress hooks
*/
public static function init() {
if ( 1 === get_option('blog_public') ) {
\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
@ -90,6 +92,9 @@ class Nodeinfo {
'email' => \get_option( 'admin_email' ),
);
$nodeinfo['blog_public'] = array(
'blog_public' => \get_option('blog_public') );
return new \WP_REST_Response( $nodeinfo, 200 );
}