add filter to check if blog is public (#504)

This commit is contained in:
Matthias Pfefferle 2023-10-12 15:52:11 +02:00 committed by GitHub
parent d564915fdf
commit 1ff8bac25a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -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();
}
}

View file

@ -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 ) );
}