add filter to check if blog is public (#504)
This commit is contained in:
parent
d564915fdf
commit
1ff8bac25a
2 changed files with 11 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue