PluginProbe
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.0.4
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.0.4
1.8.0 1.7.2 1.7.1 1.7.0 1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 All 59 releases
hostinger-reach / src / Models / Form.php

Form.php in Hostinger Reach – AI-Powered Email Marketing for WordPress 1.0.4, at src/Models/Form.php

105 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hostinger\Reach\Models;
4
5 use Hostinger\Reach\Integrations\ReachFormIntegration;
6 use WP_Post;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 die;
10 }
11
12 class Form implements Model {
13 private string $form_id;
14 private int $contact_list_id = 0;
15 private string $type;
16 private WP_Post|null $post = null;
17 private bool $is_active;
18 private int $submissions = 0;
19
20
21 public function __construct( array $db_array = array() ) {
22 if ( isset( $db_array['form_id'] ) ) {
23 $this->set_form_id( $db_array['form_id'] );
24 }
25
26 $this->set_type( $db_array['type'] ?? ReachFormIntegration::INTEGRATION_NAME );
27
28 $this->set_is_active( $db_array['is_active'] ?? true );
29
30 if ( isset( $db_array['post_id'] ) ) {
31 $this->set_post( $db_array['post_id'] );
32 }
33
34 if ( isset( $db_array['submissions'] ) ) {
35 $this->set_submissions( $db_array['submissions'] );
36 }
37
38 if ( isset( $db_array['contact_list_id'] ) ) {
39 $this->set_contact_list_id( $db_array['contact_list_id'] );
40 }
41 }
42
43 public function get_form_id(): string {
44 return $this->form_id;
45 }
46
47 public function set_type( string $type ): void {
48 $this->type = $type;
49 }
50
51 public function get_type(): string {
52 return $this->type;
53 }
54
55 public function set_form_id( string $form_id ): void {
56 $this->form_id = $form_id;
57 }
58
59 public function get_is_active(): bool {
60 return $this->is_active;
61 }
62
63 public function set_is_active( bool $is_active ): void {
64 $this->is_active = $is_active;
65 }
66
67 public function get_post(): WP_Post|null {
68 return $this->post;
69 }
70
71 public function set_post( int $post_id ): void {
72 $post = get_post( $post_id, OBJECT );
73 if ( $post instanceof WP_Post ) {
74 $this->post = $post;
75 }
76 }
77
78 public function set_contact_list_id( int $id ): void {
79 $this->contact_list_id = $id;
80 }
81
82 public function get_contact_list_id(): int {
83 return $this->contact_list_id;
84 }
85
86 public function get_submissions(): int {
87 return $this->submissions;
88 }
89
90 public function set_submissions( int $submissions ): void {
91 $this->submissions = $submissions;
92 }
93
94 public function to_array(): array {
95 return array(
96 'form_id' => $this->get_form_id(),
97 'is_active' => $this->get_is_active(),
98 'type' => $this->get_type(),
99 'contact_list_id' => $this->get_contact_list_id(),
100 'post' => $this->get_post()?->to_array(),
101 'submissions' => $this->get_submissions(),
102 );
103 }
104 }
105