| @@ -1,18 +1,26 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * OpenStation — feedback module bootstrap. |
| 4 | 4 | * |
| 5 | - * The deactivation feedback dialog: one optional question asked when a | |
| 6 | - * site admin deactivates OpenStation, forwarded server-side to the | |
| 7 | - * intake plugin on openstation.blog. Nothing in this module writes to the site — no | |
| 8 | - * option, no user meta, no transient, no table — which is why | |
| 9 | - * `docs/data-model.md` has no row for it. The only state is the | |
| 10 | - * submission itself, and it leaves the site the moment it is sent. | |
| 5 | + * Two dialogs, both forwarded server-side to the intake plugin on | |
| 6 | + * openstation.blog: | |
| 11 | 7 | * |
| 12 | - * Consent is per submission: nothing goes out unless the admin clicks | |
| 13 | - * "Send", and both dialog buttons deactivate the plugin either way. | |
| 8 | + * - The deactivation feedback dialog (`deactivation.php`, `rest.php`): | |
| 9 | + * one optional question asked when a site admin deactivates | |
| 10 | + * OpenStation. Writes nothing to the site — no option, no user meta, | |
| 11 | + * no transient, no table — which is why `docs/data-model.md` has no | |
| 12 | + * row for it. The only state is the submission itself, and it | |
| 13 | + * leaves the site the moment it is sent. | |
| 14 | + * - Usage feedback (`usage.php`): once a user has had OpenStation on | |
| 15 | + * for a while, the shell asks whether they have two minutes to say | |
| 16 | + * how it is going, and a yes opens a short optional form. Its only | |
| 17 | + * state on the site is the `usage-feedback` slug in the seen-intros | |
| 18 | + * registry. | |
| 14 | 19 | * |
| 20 | + * Consent is per submission: nothing goes out unless the user clicks | |
| 21 | + * "Send", and every other way out of either dialog sends nothing. | |
| 22 | + * | |
| 15 | 23 | * Loaded unconditionally from `desktop-mode.php` (not inside the |
| 16 | 24 | * admin-modules gate) so the REST route registers on REST requests. |
| 17 | 25 | * |
| 18 | 26 | * @package OpenStation |
| @@ -30,8 +38,15 @@ | ||
| 30 | 38 | */ |
| 31 | 39 | const OPENSTATION_FEEDBACK_ENDPOINT = 'https://openstation.blog/wp-json/openstation-feedback/v1/deactivation'; |
| 32 | 40 | |
| 33 | 41 | /** |
| 42 | + * Where a usage feedback submission is forwarded: the same intake | |
| 43 | + * plugin, its `usage` route. Filterable through | |
| 44 | + * `openstation_usage_feedback_endpoint`. | |
| 45 | + */ | |
| 46 | +const OPENSTATION_USAGE_FEEDBACK_ENDPOINT = 'https://openstation.blog/wp-json/openstation-feedback/v1/usage'; | |
| 47 | + | |
| 48 | +/** | |
| 34 | 49 | * Whether the deactivation feedback dialog is on for this site. |
| 35 | 50 | * |
| 36 | 51 | * Gates everything: the script on the Plugins screen, the Plugins |
| 37 | 52 | * app's config block, and the REST route's permission callback. A |
| @@ -48,6 +63,25 @@ | ||
| 48 | 63 | */ |
| 49 | 64 | return (bool) apply_filters( 'openstation_deactivation_feedback_enabled', true ); |
| 50 | 65 | } |
| 51 | 66 | |
| 67 | +/** | |
| 68 | + * Whether the usage feedback prompt is on for this site. | |
| 69 | + * | |
| 70 | + * Gates the shell config key that shows the prompt and the REST | |
| 71 | + * route's permission callback. A host that returns `false` here | |
| 72 | + * ships no prompt and answers 403 on the route. | |
| 73 | + * | |
| 74 | + * @return bool | |
| 75 | + */ | |
| 76 | +function openstation_usage_feedback_enabled() { | |
| 77 | + /** | |
| 78 | + * Filters whether the usage feedback prompt is enabled. | |
| 79 | + * | |
| 80 | + * @param bool $enabled Default true. | |
| 81 | + */ | |
| 82 | + return (bool) apply_filters( 'openstation_usage_feedback_enabled', true ); | |
| 83 | +} | |
| 84 | + | |
| 52 | 85 | require_once __DIR__ . '/deactivation.php'; |
| 53 | 86 | require_once __DIR__ . '/rest.php'; |
| 87 | +require_once __DIR__ . '/usage.php'; | |