prefix; } /** * Resolves table name with or without WP prefix. * Default: without prefix. */ private static function resolve( string $table, bool $with_prefix = false ): string { return $with_prefix ? self::prefix() . $table : $table; } // --- Table Methods --- public static function ADFUZ_ADS( bool $with_prefix = false ): string { return self::resolve( 'adfuz_ads', $with_prefix ); } public static function ADFUZ_ADS_META( bool $with_prefix = false ): string { return self::resolve( 'adfuz_ads_meta', $with_prefix ); } public static function ADFUZ_AD_SPACES( bool $with_prefix = false ): string { return self::resolve( 'adfuz_ad_spaces', $with_prefix ); } public static function ADFUZ_AD_SPACES_META( bool $with_prefix = false ): string { return self::resolve( 'adfuz_ad_spaces_meta', $with_prefix ); } public static function ADFUZ_CAMPAIGNS( bool $with_prefix = false ): string { return self::resolve( 'adfuz_campaigns', $with_prefix ); } public static function ADFUZ_CAMPAIGN_ADS( bool $with_prefix = false ): string { return self::resolve( 'adfuz_campaign_ads', $with_prefix ); } public static function ADFUZ_CAMPAIGN_AD_SPACES( bool $with_prefix = false ): string { return self::resolve( 'adfuz_campaign_ad_spaces', $with_prefix ); } public static function ADFUZ_CAMPAIGNS_META( bool $with_prefix = false ): string { return self::resolve( 'adfuz_campaigns_meta', $with_prefix ); } public static function ADFUZ_AUDIT_LOGS( bool $with_prefix = false ): string { return self::resolve( 'adfuz_audit_logs', $with_prefix ); } public static function ADFUZ_AUDIT_LOGS_META( bool $with_prefix = false ): string { return self::resolve( 'adfuz_audit_logs_meta', $with_prefix ); } public static function ADFUZ_URLS( bool $with_prefix = false ): string { return self::resolve( 'adfuz_urls', $with_prefix ); } public static function ADFUZ_EVENT_DEDUP( bool $with_prefix = false ): string { return self::resolve( 'adfuz_event_dedup', $with_prefix ); } public static function ADFUZ_STATS_AGGREGATION_STATE( bool $with_prefix = false ): string { return self::resolve( 'adfuz_stats_aggregation_state', $with_prefix ); } public static function ADFUZ_STATS( bool $with_prefix = false ): string { return self::resolve( 'adfuz_stats', $with_prefix ); } public static function ADFUZ_DAILY_STATS( bool $with_prefix = false ): string { return self::resolve( 'adfuz_daily_stats', $with_prefix ); } public static function ADFUZ_DAILY_STATS_COUNTRY( bool $with_prefix = false ): string { return self::resolve( 'adfuz_daily_stats_country', $with_prefix ); } public static function ADFUZ_DAILY_STATS_DEVICE( bool $with_prefix = false ): string { return self::resolve( 'adfuz_daily_stats_device', $with_prefix ); } public static function ADFUZ_CAMPAIGN_TARGET_COUNTRIES( bool $with_prefix = false ): string { return self::resolve( 'adfuz_campaign_target_countries', $with_prefix ); } /** * Device-targeting: allowed devices per campaign. * Columns: campaign_id, device_type * * @param bool $with_prefix * * @return string */ public static function ADFUZ_CAMPAIGN_TARGET_DEVICES( bool $with_prefix = false ): string { return self::resolve( 'adfuz_campaign_target_devices', $with_prefix ); } public static function ADFUZ_STATS_EXPORT_QUEUE( bool $with_prefix = false ): string { return self::resolve( 'adfuz_stats_export_queue', $with_prefix ); } public static function ADFUZ_JOBS( bool $with_prefix = false ): string { return self::resolve( 'adfuz_jobs', $with_prefix ); } public static function adfuz_definitions( bool $with_prefix = true ) { $definitions = array( // Ads array( 'table' => self::ADFUZ_ADS( $with_prefix ), 'group' => 'Ads', 'description' => 'Core ad records', ), array( 'table' => self::ADFUZ_ADS_META( $with_prefix ), 'group' => 'Ads', 'description' => 'Ad metadata', ), // Ad Spaces array( 'table' => self::ADFUZ_AD_SPACES( $with_prefix ), 'group' => 'Ad Spaces', 'description' => 'Ad placement zones', ), array( 'table' => self::ADFUZ_AD_SPACES_META( $with_prefix ), 'group' => 'Ad Spaces', 'description' => 'Ad space metadata', ), // Campaigns array( 'table' => self::ADFUZ_CAMPAIGNS( $with_prefix ), 'group' => 'Campaigns', 'description' => 'Campaign definitions', ), array( 'table' => self::ADFUZ_CAMPAIGNS_META( $with_prefix ), 'group' => 'Campaigns', 'description' => 'Campaign metadata', ), array( 'table' => self::ADFUZ_CAMPAIGN_ADS( $with_prefix ), 'group' => 'Campaigns', 'description' => 'Campaign → Ad mapping', ), array( 'table' => self::ADFUZ_CAMPAIGN_AD_SPACES( $with_prefix ), 'group' => 'Campaigns', 'description' => 'Campaign → Ad Space mapping', ), // Audit array( 'table' => self::ADFUZ_AUDIT_LOGS( $with_prefix ), 'group' => 'Audit & Stats', 'description' => 'Activity audit trail', ), array( 'table' => self::ADFUZ_AUDIT_LOGS_META( $with_prefix ), 'group' => 'Audit & Stats', 'description' => 'Audit log metadata', ), // Campaign Targeting. array( 'table' => self::ADFUZ_CAMPAIGN_TARGET_COUNTRIES( $with_prefix ), 'group' => 'Campaigns', 'description' => 'Country targeting rules for campaigns', ), array( 'table' => self::ADFUZ_CAMPAIGN_TARGET_DEVICES( $with_prefix ), 'group' => 'Campaigns', 'description' => 'Device targeting rules for campaigns', ), // Stats & Reporting. array( 'table' => self::ADFUZ_URLS( $with_prefix ), 'group' => 'Stats & Reporting', 'description' => 'Normalized page URLs used by tracked ad events', ), array( 'table' => self::ADFUZ_EVENT_DEDUP( $with_prefix ), 'group' => 'Stats & Reporting', 'description' => 'Processed event keys used to prevent duplicate stats events', ), array( 'table' => self::ADFUZ_STATS( $with_prefix ), 'group' => 'Stats & Reporting', 'description' => 'Partitioned raw ad interaction events for analytics and reporting', ), array( 'table' => self::ADFUZ_STATS_AGGREGATION_STATE( $with_prefix ), 'group' => 'Stats & Reporting', 'description' => 'Aggregation cursor state for incremental stats rollups', ), array( 'table' => self::ADFUZ_DAILY_STATS( $with_prefix ), 'group' => 'Stats & Reporting', 'description' => 'Daily ad performance rollups by ad, campaign, placement, country, and device', ), array( 'table' => self::ADFUZ_DAILY_STATS_COUNTRY( $with_prefix ), 'group' => 'Stats & Reporting', 'description' => 'Daily ad performance rollups grouped by country', ), array( 'table' => self::ADFUZ_DAILY_STATS_DEVICE( $with_prefix ), 'group' => 'Stats & Reporting', 'description' => 'Daily ad performance rollups grouped by device type', ), array( 'table' => self::ADFUZ_STATS_EXPORT_QUEUE( $with_prefix ), 'group' => 'Stats & Reporting', 'description' => 'Queued and generated stats export jobs', ), array( 'table' => self::ADFUZ_JOBS( $with_prefix ), 'group' => 'Background Jobs & Queue', 'description' => 'Unified asynchronous background jobs for AI generation and heavy processing', ), ); return $definitions; } /** * Get ALL tables as array. * Pass true to include WP prefix. */ public static function definitions( bool $with_prefix = true ): array { return apply_filters( 'adfuz/table_name/definitions', self::adfuz_definitions( $with_prefix ), $with_prefix ); } /** * Returns a flat array of table names (existing behaviour preserved). * Now delegates to definitions() — no duplication. */ public static function all( bool $with_prefix = false ): array { return array_column( self::definitions( $with_prefix ), 'table' ); } }