ACTIVITYPUB_REST_NAMESPACE, 'enabled' => array( 'site' => ! is_user_type_disabled( 'blog' ), 'users' => ! is_user_type_disabled( 'user' ), ), ); $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' ), ) ); \register_block_type_from_metadata( ACTIVITYPUB_PLUGIN_DIR . '/build/follow-me', array( 'render_callback' => array( self::class, 'render_follow_me_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_follow_me_block( $attrs, $content, $block ) { return '
lol!!!!
'; } 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 = '
'; if ( $title ) { $html .= '

' . $title . '

'; } $html .= '
'; return $html; } public static function render_follower( $follower ) { $external_svg = ''; $template = ' %s / @%s %s '; $data = $follower->to_array(); return sprintf( $template, esc_url( $data['url'] ), esc_attr( $data['name'] ), esc_attr( $data['icon']['url'] ), esc_html( $data['name'] ), esc_html( $data['preferredUsername'] ), $external_svg ); } }