GeniXCMS

Stats Class

categoryAPI edit_calendar31 Mar 2026

System Analytics & Statistics Class


The Stats class is the primary data-aggregation engine for GeniXCMS. It provides a comprehensive set of methods for gathering system-wide intelligence, including content volume, user growth metrics, and advanced post-view tracking with built-in heuristic bot detection.


⚡ Content Metrics

The following methods are critical for populating administration dashboards and site-wide report summaries.

Method Role Logic
totalPost($type) Volume Total record count for the specified type (e.g., post, page).
activePost($type) Production Counts only published and public records (Status 1).
inactivePost($type) Moderation Counts drafts, hidden, or scheduled records (Status 0).
totalCat($type) Taxonomy Counts all active categories for the specified context.

👥 User Engagement Analytics

Monitor your community's growth and administrative overhead.

  • Stats::totalUser(): Returns the total number of registered general members.
  • Stats::totalAdmin(): Returns the count of accounts with Level 0 (Administrator) access.
  • Stats::activeUser(): Counts verified and active user profiles.
  • Stats::pendingUser(): Counts users currently awaiting email verification steps.

📈 Content Popularity Tracking

GeniXCMS features a robust, human-focused view tracking system.

Stats::addViews(int $post_id)

Increments the views counter for a specific content record.

  • Bot Protection: The method automatically filters and discards requests from over 50 common search engine crawlers (Googlebot, Bingbot, etc.) to ensure your analytics represent real human engagement.
  • Implementation: Typically called at the beginning of your theme's single.php.

Stats::mostViewed(int $limit, ...)

Retrieves a collection of post objects ranked by their accumulated view counts.

// Fetch the top 5 most popular blog posts
$trending = Stats::mostViewed(5, 'post');

💬 Comment & Interaction Metrics

Method Description
totalComments() Cumulative count of all reader submissions.
activeComments() Counts approved and live comments.
pendingComments() Counts submissions currently held in the moderation queue.

priority_high
ImportantPerformance Architecture: The Stats class methods are optimized to perform single-metric SQL queries. When building heavy report dashboards, consider Caching the returned values if your database volume is extremely high.

lightbulb
TipDashboard Utility: Use these methods in your custom Programmable Dashboard widgets to provide your clients with real-time site updates.

See Also