From 739fcdf3b8a0f29eb02331b017918290661a891f Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Thu, 10 Oct 2024 09:22:21 +0200 Subject: [PATCH] check for enum cc @mattwiebe --- includes/class-blocks.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/class-blocks.php b/includes/class-blocks.php index d4abb796..b208c03e 100644 --- a/includes/class-blocks.php +++ b/includes/class-blocks.php @@ -52,7 +52,19 @@ public static function register_postmeta() { 'show_in_rest' => true, 'single' => true, 'type' => 'string', - 'sanitize_callback' => 'sanitize_text_field', + 'sanitize_callback' => function ( $visibility ) { + $options = array( + ACTIVITYPUB_POST_VISIBILITY_PUBLIC, + ACTIVITYPUB_POST_VISIBILITY_QUIET_PUBLIC, + ACTIVITYPUB_POST_VISIBILITY_LOCAL, + ); + + if ( in_array( $visibility, $options, true ) ) { + return $visibility; + } + + return ACTIVITYPUB_POST_VISIBILITY_PUBLIC; + }, ) ); }