| @@ -1,17 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Desktop Mode — Toast notification type registry. | |
| 3 | + * OpenStation — Toast notification type registry. | |
| 4 | 4 | * |
| 5 | 5 | * The shell surfaces user-visible toast notifications (save succeeded, |
| 6 | 6 | * upload failed, a plugin crashed, …). Each toast carries a `type` |
| 7 | 7 | * slug that the shell maps to a color + icon. The defaults cover |
| 8 | 8 | * `success`, `warning`, `error`, and `shell-error`; plugins and themes |
| 9 | - * extend the list via the {@see 'desktop_mode_toast_types'} filter to | |
| 9 | + * extend the list via the {@see 'openstation_toast_types'} filter to | |
| 10 | 10 | * register their own slugs (e.g. `update-available`). |
| 11 | 11 | * |
| 12 | - * @package WPDesktopMode | |
| 13 | - * @since 0.11.0 | |
| 12 | + * @package OpenStation | |
| 14 | 13 | */ |
| 15 | 14 | |
| 16 | 15 | defined( 'ABSPATH' ) || exit; |
| 17 | 16 | |
| @@ -19,19 +18,17 @@ | ||
| 19 | 18 | * Returns the map of toast-notification type slugs shipped to the shell. |
| 20 | 19 | * |
| 21 | 20 | * Each entry is an array shaped `{ id, label, icon, tone }`: |
| 22 | 21 | * |
| 23 | - * - `id` is a stable slug plugins call with `wp.desktop.toast( id, … )`. | |
| 22 | + * - `id` is a stable slug plugins call with `wp.os.toast( id, … )`. | |
| 24 | 23 | * - `label` is the default aria-label used when a toast omits one. |
| 25 | 24 | * - `icon` is a Dashicons class rendered alongside the message. |
| 26 | 25 | * - `tone` is one of `positive | warning | critical | neutral` — the |
| 27 | 26 | * shell maps this to its color palette. |
| 28 | 27 | * |
| 29 | - * @since 0.11.0 | |
| 30 | - * | |
| 31 | 28 | * @return array<int, array{id: string, label: string, icon: string, tone: string}> |
| 32 | 29 | */ |
| 33 | -function desktop_mode_get_toast_types() { | |
| 30 | +function openstation_get_toast_types() { | |
| 34 | 31 | $defaults = array( |
| 35 | 32 | array( |
| 36 | 33 | 'id' => 'success', |
| 37 | 34 | 'label' => __( 'Success', 'desktop-mode' ), |
| @@ -63,9 +60,9 @@ | ||
| 63 | 60 | /** |
| 64 | 61 | * Filters the toast-notification type map. |
| 65 | 62 | * |
| 66 | 63 | * ```php |
| 67 | - * add_filter( 'desktop_mode_toast_types', function ( $types ) { | |
| 64 | + * add_filter( 'openstation_toast_types', function ( $types ) { | |
| 68 | 65 | * $types[] = array( |
| 69 | 66 | * 'id' => 'update-available', |
| 70 | 67 | * 'label' => __( 'Update available', 'my-plugin' ), |
| 71 | 68 | * 'icon' => 'dashicons-update', |
| @@ -75,17 +72,16 @@ | ||
| 75 | 72 | * } ); |
| 76 | 73 | * ``` |
| 77 | 74 | * |
| 78 | 75 | * Non-array returns fall back to defaults. Entries whose `id` is |
| 79 | - * empty, whose `tone` is not one of `positive|warning|critical| | |
| 80 | - * neutral`, or whose `icon` isn't a sanitizable Dashicons-shaped | |
| 81 | - * class are dropped. | |
| 76 | + * empty or whose `tone` is not one of `positive|warning|critical| | |
| 77 | + * neutral` are dropped. An `icon` that doesn't survive | |
| 78 | + * `sanitize_html_class()` falls back to `dashicons-info`; a missing | |
| 79 | + * `label` falls back to the ucfirst'd `id`. | |
| 82 | 80 | * |
| 83 | - * @since 0.11.0 | |
| 84 | - * | |
| 85 | 81 | * @param array $defaults Built-in toast types. |
| 86 | 82 | */ |
| 87 | - $filtered = apply_filters( 'desktop_mode_toast_types', $defaults ); | |
| 83 | + $filtered = apply_filters( 'openstation_toast_types', $defaults ); | |
| 88 | 84 | if ( ! is_array( $filtered ) ) { |
| 89 | 85 | return $defaults; |
| 90 | 86 | } |
| 91 | 87 | |