PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.7.2
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.7.2
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 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / src / Integrations / IntegrationWithForms.php
hostinger-reach / src / Integrations Last commit date
Brave 6 months ago ContactForm7 6 months ago Elementor 3 months ago Forminator 3 months ago NinjaForms 7 months ago OptInMonster 6 months ago Reach 3 months ago SureForms 6 months ago ThriveLeads 6 months ago WPFormsLite 6 months ago WSForms 9 months ago WooCommerce 5 months ago ContactForm7Integration.php 11 months ago ImportManager.php 7 months ago Integration.php 6 months ago IntegrationInterface.php 10 months ago IntegrationWithForms.php 10 months ago PluginManager.php 10 months ago ReachFormIntegration.php 11 months ago WpFormsLiteIntegration.php 11 months ago
IntegrationWithForms.php
48 lines
1 <?php
2
3 namespace Hostinger\Reach\Integrations;
4
5 use Hostinger\Reach\Repositories\FormRepository;
6 use WP_Post;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 die;
10 }
11
12 abstract class IntegrationWithForms extends Integration {
13
14 public FormRepository $form_repository;
15
16 public function __construct( FormRepository $form_repository ) {
17 $this->form_repository = $form_repository;
18 }
19
20 abstract public function get_form_ids( WP_Post $post ): array;
21
22 protected function maybe_unset_forms( WP_Post $post ): void {
23 $previous_forms = $this->form_repository->all(
24 array(
25 'post_id' => $post->ID,
26 'type' => $this->get_name(),
27 )
28 );
29 $previous_form_ids = array_column( $previous_forms, 'form_id' );
30 $current_form_ids = $this->get_form_ids( $post );
31
32 foreach ( $previous_form_ids as $form_id ) {
33 if ( ! in_array( $form_id, $current_form_ids, true ) ) {
34 $this->form_repository->delete( $form_id );
35 }
36 }
37 }
38
39 protected function unset_all_forms( WP_Post $post ): void {
40 $this->form_repository->delete_all_from_post( $post->ID, $this->get_name() );
41 }
42
43 public function get_forms(): array {
44 $args['type'] = $this->get_name();
45 return $this->form_repository->all( $args );
46 }
47 }
48