%s
%s
', \esc_html__( 'Fediverse Stats', 'activitypub' ), \sprintf( /* translators: %d: The year */ \esc_html__( 'No stats available for %d. Stats are collected monthly and compiled at the end of each year.', 'activitypub' ), (int) $stats_year ) ); } return; } // Get comment types for dynamic display. $comment_types = Statistics::get_comment_types_for_stats(); // Calculate total engagement. $total_engagement = 0; foreach ( array_keys( $comment_types ) as $ct_slug ) { $total_engagement += $summary[ $ct_slug . '_count' ] ?? 0; } // Most active month name. $most_active_month_name = ''; if ( ! empty( $summary['most_active_month'] ) ) { $most_active_month_name = gmdate( 'F', gmmktime( 0, 0, 0, $summary['most_active_month'], 1, $stats_year ) ); } // Follower growth. $followers_start = $summary['followers_start'] ?? 0; $followers_end = $summary['followers_end'] ?? 0; $followers_net_change = $summary['followers_net_change'] ?? ( $followers_end - $followers_start ); $change_sign = $followers_net_change >= 0 ? '+' : ''; // Get actor webfinger for the card header. $actor = Actors::get_by_id( $user_id ); if ( \is_wp_error( $actor ) ) { // Fall back to direct model instantiation for blog/application actors. if ( Actors::BLOG_USER_ID === $user_id ) { $actor = new \Activitypub\Model\Blog(); } elseif ( Actors::APPLICATION_USER_ID === $user_id ) { $actor = new \Activitypub\Model\Application(); } } $actor_webfinger = ! \is_wp_error( $actor ) ? $actor->get_webfinger() : ''; // Site name for branding. $site_name = \get_bloginfo( 'name' ); $block_id = 'activitypub-stats-' . \wp_unique_id(); $title_text = \sprintf( /* translators: %d: The year */ \__( 'Fediverse Stats %d', 'activitypub' ), (int) $stats_year ); /* * Build border styles using WP_Style_Engine for sanitization. * Border serialization is skipped in block.json to avoid double * rendering in the editor, so we apply it here manually. */ $border_result = \wp_style_engine_get_styles( array( 'border' => $attributes['style']['border'] ?? array() ) ); $extra_styles = $border_result['css'] ?? ''; // Handle preset border color slug (not part of style.border). if ( ! empty( $attributes['borderColor'] ) ) { $preset_color = 'var(--wp--preset--color--' . \sanitize_key( $attributes['borderColor'] ) . ')'; $extra_styles = 'border-color:' . $preset_color . ';' . $extra_styles; } // Resolve the border color for inner elements via CSS variable. $border_color = ''; if ( ! empty( $attributes['style']['border']['color'] ) ) { $border_color = $attributes['style']['border']['color']; } elseif ( ! empty( $attributes['borderColor'] ) ) { $border_color = 'var(--wp--preset--color--' . \sanitize_key( $attributes['borderColor'] ) . ')'; } if ( $border_color ) { $extra_styles .= '--activitypub-stats--border-color:' . \esc_attr( $border_color ) . ';'; } $wrapper_attrs = array( 'id' => $block_id, 'class' => 'activitypub-stats', ); $wrapper_html = \get_block_wrapper_attributes( $wrapper_attrs ); // Merge border styles into the existing style attribute. if ( $extra_styles ) { if ( \str_contains( $wrapper_html, 'style="' ) ) { $wrapper_html = \str_replace( 'style="', 'style="' . \esc_attr( $extra_styles ), $wrapper_html ); } else { $wrapper_html .= ' style="' . \esc_attr( $extra_styles ) . '"'; } } ?>
data-year="" >

$type_info ) : ?> 0 ) : ?>