PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.5.9
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.5.9
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 / Admin / Surveys / Survey.php
hostinger-reach / src / Admin / Surveys Last commit date
SatisfactionSurvey.php 8 months ago Survey.php 8 months ago
Survey.php
71 lines
1 <?php
2
3 namespace Hostinger\Reach\Admin\Surveys;
4
5 use Hostinger\Surveys\SurveyManager;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 die;
9 }
10
11 abstract class Survey {
12
13 protected const DAY_IN_SECONDS = 86400;
14
15 private SurveyManager $survey_manager;
16
17 public function __construct( SurveyManager $survey_manager ) {
18 $this->survey_manager = $survey_manager;
19 }
20
21 public function init(): void {
22 add_filter( 'hostinger_add_surveys', array( $this, 'add_survey' ) );
23 }
24
25 public function add_survey( array $surveys ): array {
26 if ( $this->should_load_survey() ) {
27 $surveys[] = $this->get_survey();
28 }
29
30 return $surveys;
31 }
32
33 protected function get_priority(): int {
34 return 100;
35 }
36
37 protected function should_load_survey(): bool {
38 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
39 return false;
40 }
41
42 $is_client_eligible = $this->survey_manager->isClientEligible();
43 $is_not_completed = $this->survey_manager->isSurveyNotCompleted( $this->get_id() );
44 $is_hidden = $this->survey_manager->isSurveyHidden();
45
46 return $is_client_eligible && $is_not_completed && ! $is_hidden;
47 }
48
49 protected function get_survey(): array {
50 return $this->survey_manager->addSurvey(
51 $this->get_id(),
52 $this->get_score_question(),
53 $this->get_comment_question(),
54 $this->get_location(),
55 $this->get_priority(),
56 $this->get_review_url(),
57 $this->get_review_min_required_score()
58 );
59 }
60
61 abstract protected function get_score_question(): string;
62
63 abstract protected function get_comment_question(): string;
64
65 abstract protected function get_id(): string;
66
67 abstract protected function get_location(): string;
68 abstract protected function get_review_url(): string;
69 abstract protected function get_review_min_required_score(): int;
70 }
71