[ $this, 'render' ], ] ); } /** * Server-side render callback. * * @param array $attributes Block attributes from the editor. * @param string $content Inner blocks HTML (unused). */ public function render( array $attributes, string $content = '' ): string { $post_id = (int) ( $attributes['postId'] ?? get_the_ID() ); $style = (int) ( $attributes['style'] ?? 1 ); $period = (string) ( $attributes['period'] ?? 'total' ); $size = (string) ( $attributes['size'] ?? 'md' ); if ( ! $post_id ) { return ''; } $repo = new ViewsRepository(); $views = $repo->get_post_views( $post_id, $period ); return StyleRegistry::render( $style, $views, [ 'post_id' => $post_id, 'size' => $size, ] ); } }