PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.11
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.11
1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 All 35 releases
← All changes | includes/framework/app/class-effects.php +14 -7 1.1.61.1.11 View file →
@@ -30,19 +30,26 @@
30 30
31 31 /**
32 32 * Show a toast.
33 33 *
34 - * There is no tone: the shell renders every toast the same way
35 - * (`wp.os.showToast()` takes no severity), so a `$tone` argument
36 - * here would be a promise the platform cannot keep. Say what
37 - * happened in the message, and use `<os-notice tone="…">` in the
38 - * body when a state needs a colour.
34 + * `$type` is an id from the toast-type registry the shell ships
35 + * (`openstation_get_toast_types()`, filterable through
36 + * `openstation_toast_types`): `success`, `warning`, `error`,
37 + * `shell-error`, or one a plugin registered. The shell maps it to
38 + * the tone the toast wears; an empty or unknown id is the plain
39 + * toast, so say what happened in the message either way.
39 40 *
40 41 * @param string $message Text.
42 + * @param string $type Toast-type id, or '' for the plain toast.
41 43 * @return self
42 44 */
43 - public function toast( $message ) {
44 - return $this->add( 'toast', array( 'message' => (string) $message ) );
45 + public function toast( $message, $type = '' ) {
46 + $effect = array( 'message' => (string) $message );
47 + if ( '' !== (string) $type ) {
48 + // `type` is the effect kind on the wire; the toast type rides as `toastType`.
49 + $effect['toastType'] = (string) $type;
50 + }
51 + return $this->add( 'toast', $effect );
45 52 }
46 53
47 54 /**
48 55 * Retitle the window for this session.