From 1ff8bac25a176de96c53c4dfb795fdadbe2eaaf3 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Thu, 12 Oct 2023 15:52:11 +0200 Subject: [PATCH] add filter to check if blog is public (#504) --- activitypub.php | 3 ++- includes/functions.php | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/activitypub.php b/activitypub.php index 8999a0a..2c8dcdc 100644 --- a/activitypub.php +++ b/activitypub.php @@ -15,6 +15,7 @@ namespace Activitypub; +use function Activitypub\is_blog_public; use function Activitypub\site_supports_blocks; require_once __DIR__ . '/includes/compat.php'; @@ -52,7 +53,7 @@ function rest_init() { Rest\Collection::init(); // load NodeInfo endpoints only if blog is public - if ( \get_option( 'blog_public', 1 ) ) { + if ( is_blog_public() ) { Rest\NodeInfo::init(); } } diff --git a/includes/functions.php b/includes/functions.php index df630d4..d5cd9f6 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -472,3 +472,12 @@ function site_supports_blocks() { function is_json( $data ) { return \is_array( \json_decode( $data, true ) ) ? true : false; } + +/** + * Check if a blog is public based on the `blog_public` option + * + * @return bollean True if public, false if not + */ +function is_blog_public() { + return (bool) apply_filters( 'activitypub_is_blog_public', \get_option( 'blog_public', 1 ) ); +}