PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.0
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.0
4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Basic / Notices / RatingNotice.php
wp-staging / Basic / Notices Last commit date
BasicNotices.php 1 week ago GeneralProCardNotice.php 1 week ago RatingNotice.php 1 week ago
RatingNotice.php
64 lines
1 <?php
2
3 namespace WPStaging\Basic\Notices;
4
5 use DateTime;
6
7 class RatingNotice
8 {
9 /** @var string */
10 const OPTION_NAME = 'wpstg_rating';
11
12 /**
13 * Shared eligibility gate for the success-based review prompt, used by both
14 * the staging and backup completion modals (views/notices/review-prompt-modal.php).
15 *
16 * It only answers "is the user currently allowed to be asked?", i.e. the
17 * review prompt has not been permanently dismissed and is not inside a snooze
18 * window. The "value delivered" trigger (a staging site or backup was just
19 * created) is the caller's responsibility — the prompt is rendered into the
20 * success modal, never as loose dashboard text.
21 *
22 * Because every surface reads and writes the same wpstg_rating state, a
23 * "Maybe Later" or "Don't Ask Again" in one place silences the prompt
24 * everywhere, so the user is never asked twice across workflows.
25 *
26 * @return bool
27 */
28 public function isReviewPromptEligible(): bool
29 {
30 return $this->canShow(self::OPTION_NAME);
31 }
32
33 /**
34 * Check whether the prompt is currently dismissed or snoozed.
35 *
36 * @param string $option
37 * @return bool
38 */
39 private function canShow($option)
40 {
41 if (empty($option)) {
42 return false;
43 }
44
45 $dbOption = get_option($option);
46
47 // Permanently dismissed via "Don't Ask Again" / "Leave a Review".
48 if ($dbOption === "no") {
49 return false;
50 }
51
52 // Snoozed via "Maybe Later": a valid date means "do not show before then".
53 if (wpstg_is_valid_date($dbOption)) {
54 $now = new DateTime("now");
55 $show = new DateTime($dbOption);
56 if ($now < $show) {
57 return false;
58 }
59 }
60
61 return true;
62 }
63 }
64