PluginProbe
MailPoet – Newsletters, Email Marketing, and Automation / 3.59.2
MailPoet – Newsletters, Email Marketing, and Automation v3.59.2
5.38.0 5.37.0 5.36.1 5.36.0 5.35.1 5.35.0 5.34.3 5.34.2 5.34.1 5.34.0 5.33.1 5.33.0 5.32.0 5.31.0 5.30.0 5.29.0 5.28.1 5.28.0 5.27.0 5.26.0 5.26.1 5.25.0 5.24.0 4.43.0 4.43.1 All 542 releases
mailpoet / lib / Models / StatisticsForms.php

StatisticsForms.php in MailPoet – Newsletters, Email Marketing, and Automation 3.59.2, at lib/Models/StatisticsForms.php

36 lines 895 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MailPoet\Models;
4
5 if (!defined('ABSPATH')) exit;
6
7
8 class StatisticsForms extends Model {
9 public static $_table = MP_STATISTICS_FORMS_TABLE; // phpcs:ignore PSR2.Classes.PropertyDeclaration
10
11 public static function getTotalSignups($formId = false) {
12 return self::where('form_id', $formId)->count();
13 }
14
15 public static function record($formId, $subscriberId) {
16 if ($formId > 0 && $subscriberId > 0) {
17 // check if we already have a record for today
18 $record = self::where('form_id', $formId)
19 ->where('subscriber_id', $subscriberId)
20 ->findOne();
21
22 if ($record === false) {
23 // create a new entry
24 $record = self::create();
25 $record->hydrate([
26 'form_id' => $formId,
27 'subscriber_id' => $subscriberId,
28 ]);
29 $record->save();
30 }
31 return $record;
32 }
33 return false;
34 }
35 }
36