_partial
1 month ago
aios-salt-postfix-enabled.php
1 year ago
analytics-consent-failed.php
1 year ago
analytics-consent-refused.php
1 year ago
analytics-modal.php
1 week ago
backup-plugins-notice.php
8 months ago
beta.php
1 year ago
cache-directory-permission-problem.php
1 year ago
cli-integration-notice.php
2 days ago
cron-warning-notice.php
2 days ago
directory-listing-could-not-be-prevented.php
8 months ago
disabled-items-notice.php
1 year ago
disabled-optimizer-notice.php
1 year ago
elementor-cloud-notice.php
5 months ago
logs-directory-permission-problem.php
1 year ago
low-memory-limit.php
1 year ago
mu-plugin-directory-permission-problem.php
1 year ago
next-gen-engine-notice.php
1 month ago
no-db-prefix-notice.php
1 year ago
object-cache-skipped.php
1 year ago
outdated-wp-staging-hooks.php
1 year ago
outdated-wp-staging-version.php
1 year ago
pro-crons-notice.php
1 year ago
review-prompt-handlers.php
1 month ago
review-prompt-modal.php
1 month ago
settings_option_corrupt.php
1 year ago
staging-directory-permission-problem.php
2 weeks ago
staging-symlink-enabled-notice.php
11 months ago
table-tmp-prefix-conflict-notice.php
1 year ago
transient.php
1 year ago
uploads-outside-wp-root.php
1 year ago
vars-directory-permission-problem.php
1 year ago
wordfence-userini-renamed.php
7 months ago
wp-options-missing-pk.php
7 months ago
wp-version-compat-notice.php
5 months ago
wpe-permalink-issue-notice.php
1 year ago
wrong-scheme.php
1 year ago
review-prompt-handlers.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Page-level delegated handlers for the success-based review prompt. |
| 5 | * |
| 6 | * The prompt lives in content that is added at runtime — the staging listing |
| 7 | * (injected via innerHTML) and the backup completion modal (SweetAlert) — so an |
| 8 | * inline <script> inside those fragments never executes. These handlers are |
| 9 | * delegated from the document and the partial is included once on every page |
| 10 | * that can show the prompt (the staging dashboard and the Backup & Migration |
| 11 | * page). Both surfaces share the same wpstg_rating state, so dismissing or |
| 12 | * snoozing in one silences the review everywhere. |
| 13 | * |
| 14 | * Selectors (shared by the strip and the modal): |
| 15 | * .wpstg-leave-review -> opens the review page (default) + permanently dismisses |
| 16 | * .wpstg_rate_later -> progressive snooze (14 / 30 / 180 days) |
| 17 | * .wpstg_hide_rating -> permanently dismisses |
| 18 | */ |
| 19 | |
| 20 | ?> |
| 21 | <script> |
| 22 | (function () { |
| 23 | var PROMPT_SELECTOR = '.wpstg_fivestar'; |
| 24 | |
| 25 | function dismiss(action, promptEl) { |
| 26 | var body = new URLSearchParams(); |
| 27 | body.append('action', action); |
| 28 | body.append('nonce', wpstg.nonce); |
| 29 | |
| 30 | fetch(ajaxurl, { |
| 31 | method: 'POST', |
| 32 | credentials: 'same-origin', |
| 33 | headers: {'Content-Type': 'application/x-www-form-urlencoded'}, |
| 34 | body: body.toString() |
| 35 | }).then(function () { |
| 36 | if (promptEl) { |
| 37 | promptEl.style.display = 'none'; |
| 38 | } |
| 39 | }); |
| 40 | } |
| 41 | |
| 42 | document.addEventListener('click', function (event) { |
| 43 | var rateLater = event.target.closest('.wpstg_rate_later'); |
| 44 | if (rateLater) { |
| 45 | event.preventDefault(); |
| 46 | dismiss('wpstg_hide_later', rateLater.closest(PROMPT_SELECTOR)); |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | var hideRating = event.target.closest('.wpstg_hide_rating'); |
| 51 | if (hideRating) { |
| 52 | event.preventDefault(); |
| 53 | dismiss('wpstg_hide_rating', hideRating.closest(PROMPT_SELECTOR)); |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | // Keep the default action so the review page opens in a new tab, then dismiss. |
| 58 | // Class hook (not an id): the block is cloned from a hidden host into the |
| 59 | // success modal, so an id would be duplicated in the DOM while the modal is open. |
| 60 | var leaveReview = event.target.closest('.wpstg-leave-review'); |
| 61 | if (leaveReview) { |
| 62 | dismiss('wpstg_hide_rating', leaveReview.closest(PROMPT_SELECTOR)); |
| 63 | } |
| 64 | }); |
| 65 | })(); |
| 66 | </script> |
| 67 |