$today, 'count' => 0 ]; } if ( ! isset( $counts['week'] ) || $counts['week']['date'] !== $week ) { $counts['week'] = [ 'date' => $week, 'count' => 0 ]; } if ( \aipub_fs()->is_trial() ) { if ( $counts['day']['count'] >= 3 ) { return [ false, __( 'Daily generation limit reached (3 per day).', 'ai-publisher' ) ]; } } elseif ( \aipub_fs()->is_free_plan() ) { if ( $counts['week']['count'] >= 1 ) { return [ false, __( 'Weekly generation limit reached (1 per week).', 'ai-publisher' ) ]; } } return [ true, '' ]; } /** * Record a successful post generation. */ public static function record_generation(): void { $counts = get_option( self::OPTION_KEY, [] ); $today = gmdate( 'Y-m-d' ); $week = gmdate( 'o-W' ); if ( ! isset( $counts['day'] ) || $counts['day']['date'] !== $today ) { $counts['day'] = [ 'date' => $today, 'count' => 0 ]; } if ( ! isset( $counts['week'] ) || $counts['week']['date'] !== $week ) { $counts['week'] = [ 'date' => $week, 'count' => 0 ]; } $counts['day']['count']++; $counts['week']['count']++; update_option( self::OPTION_KEY, $counts ); } }