ACTIVITYPUB_REST_NAMESPACE, ); $js = sprintf( 'var _activityPubOptions = %s;', wp_json_encode( $data ) ); \wp_add_inline_script( $handle, $js, 'before' ); } public static function register_blocks() { \register_block_type_from_metadata( ACTIVITYPUB_PLUGIN_DIR . '/build/followers', array( 'render_callback' => array( self::class, 'render_follower_block' ), ) ); } private static function get_user_id( $user_string ) { if ( is_numeric( $user_string ) ) { return absint( $user_string ); } // any other non-numeric falls back to 0, including the `site` string used in the UI return 0; } public static function render_follower_block( $attrs, $content, $block ) { $followee_user_id = self::get_user_id( $attrs['selectedUser'] ); $per_page = absint( $attrs['per_page'] ); $followers = Followers::get_followers( $followee_user_id, $per_page ); $title = $attrs['title']; $wrapper_attributes = get_block_wrapper_attributes( array( 'aria-label' => __( 'Fediverse Followers', 'activitypub' ), 'class' => 'activitypub-follower-block', 'data-attrs' => wp_json_encode( $attrs ), ) ); $html = '