Skip to content

Commit 1ff8bac

Browse files
authored
add filter to check if blog is public (#504)
1 parent d564915 commit 1ff8bac

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

activitypub.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace Activitypub;
1717

18+
use function Activitypub\is_blog_public;
1819
use function Activitypub\site_supports_blocks;
1920

2021
require_once __DIR__ . '/includes/compat.php';
@@ -52,7 +53,7 @@ function rest_init() {
5253
Rest\Collection::init();
5354

5455
// load NodeInfo endpoints only if blog is public
55-
if ( \get_option( 'blog_public', 1 ) ) {
56+
if ( is_blog_public() ) {
5657
Rest\NodeInfo::init();
5758
}
5859
}

includes/functions.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,12 @@ function site_supports_blocks() {
472472
function is_json( $data ) {
473473
return \is_array( \json_decode( $data, true ) ) ? true : false;
474474
}
475+
476+
/**
477+
* Check if a blog is public based on the `blog_public` option
478+
*
479+
* @return bollean True if public, false if not
480+
*/
481+
function is_blog_public() {
482+
return (bool) apply_filters( 'activitypub_is_blog_public', \get_option( 'blog_public', 1 ) );
483+
}

0 commit comments

Comments
 (0)