| @@ -1,17 +1,17 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Desktop Mode — Agents: "Agent chat" native window. | |
| 3 | + * OpenStation — Agents: "Agent chat" native window. | |
| 4 | 4 | * |
| 5 | 5 | * Lazy-loaded native window the Agents section opens to talk to an |
| 6 | 6 | * agent (the chat trigger). The window is a shell — the dedicated |
| 7 | 7 | * `agent-run-window` bundle registers the render callback on |
| 8 | - * `window.desktopModeNativeWindows['desktop-mode-agent-run']`, | |
| 8 | + * `window.openStationNativeWindows['desktop-mode-agent-run']`, | |
| 9 | 9 | * subscribes to the cross-bundle `desktop-mode/agents-run` shared |
| 10 | 10 | * store, and paints the conversation for whichever agent the opener |
| 11 | 11 | * selected. |
| 12 | 12 | * |
| 13 | - * @package WPDesktopMode | |
| 13 | + * @package OpenStation | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | defined( 'ABSPATH' ) || exit; |
| 17 | 17 | |
| @@ -20,10 +20,10 @@ | ||
| 20 | 20 | * motif is consistent everywhere agents appear. |
| 21 | 21 | * |
| 22 | 22 | * @return string Data URI. |
| 23 | 23 | */ |
| 24 | -function desktop_mode_agent_run_window_icon() { | |
| 25 | - return desktop_mode_agent_avatar_url(); | |
| 24 | +function openstation_agent_run_window_icon() { | |
| 25 | + return openstation_agent_avatar_url(); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Register the bundle script + style handles. Lazy-loaded by the |
| @@ -31,24 +31,24 @@ | ||
| 31 | 31 | * recycle-bin and posts-window modules. |
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | -function desktop_mode_agent_run_register_assets() { | |
| 36 | - $version = DESKTOP_MODE_VERSION; | |
| 37 | - $suffix = desktop_mode_asset_suffix(); | |
| 35 | +function openstation_agent_run_register_assets() { | |
| 36 | + $version = OPENSTATION_VERSION; | |
| 37 | + $suffix = openstation_asset_suffix(); | |
| 38 | 38 | |
| 39 | - $css_path = DESKTOP_MODE_DIR . 'assets/css/agents.css'; | |
| 39 | + $css_path = OPENSTATION_DIR . 'assets/css/agents.css'; | |
| 40 | 40 | wp_register_style( |
| 41 | 41 | 'desktop-mode-agent-run', |
| 42 | - DESKTOP_MODE_URL . 'assets/css/agents.css', | |
| 43 | - array( 'desktop-mode-variables', 'dashicons' ), | |
| 42 | + OPENSTATION_URL . 'assets/css/agents.css', | |
| 43 | + array( 'os-variables', 'dashicons' ), | |
| 44 | 44 | file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version |
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | - $js_path = DESKTOP_MODE_DIR . 'assets/js/agent-run-window' . $suffix . '.js'; | |
| 47 | + $js_path = OPENSTATION_DIR . 'assets/js/agent-run-window' . $suffix . '.js'; | |
| 48 | 48 | wp_register_script( |
| 49 | 49 | 'desktop-mode-agent-run', |
| 50 | - DESKTOP_MODE_URL . 'assets/js/agent-run-window' . $suffix . '.js', | |
| 50 | + OPENSTATION_URL . 'assets/js/agent-run-window' . $suffix . '.js', | |
| 51 | 51 | array( 'wp-i18n' ), |
| 52 | 52 | file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version, |
| 53 | 53 | true |
| 54 | 54 | ); |
| @@ -54,24 +54,24 @@ | ||
| 54 | 54 | ); |
| 55 | 55 | wp_set_script_translations( |
| 56 | 56 | 'desktop-mode-agent-run', |
| 57 | 57 | 'desktop-mode', |
| 58 | - DESKTOP_MODE_DIR . 'languages' | |
| 58 | + OPENSTATION_DIR . 'languages' | |
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | -add_action( 'init', 'desktop_mode_agent_run_register_assets', 5 ); | |
| 61 | +add_action( 'init', 'openstation_agent_run_register_assets', 5 ); | |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Static template rendered into the window body — the bundle mounts |
| 65 | - * its UI into `[data-desktop-mode-agent-run-root]`. | |
| 65 | + * its UI into `[data-os-agent-run-root]`. | |
| 66 | 66 | * |
| 67 | 67 | * @return void |
| 68 | 68 | */ |
| 69 | -function desktop_mode_agent_run_render_template() { | |
| 69 | +function openstation_agent_run_render_template() { | |
| 70 | 70 | ?> |
| 71 | - <div class="desktop-mode-agent-run" data-desktop-mode-agent-run-root> | |
| 72 | - <div class="desktop-mode-agent-run__loading"> | |
| 73 | - <wpd-spinner></wpd-spinner> | |
| 71 | + <div class="desktop-mode-agent-run" data-os-agent-run-root> | |
| 72 | + <div class="os-agent-run__loading"> | |
| 73 | + <os-spinner></os-spinner> | |
| 74 | 74 | </div> |
| 75 | 75 | </div> |
| 76 | 76 | <?php |
| 77 | 77 | } |
| @@ -81,24 +81,24 @@ | ||
| 81 | 81 | * registries boot. |
| 82 | 82 | * |
| 83 | 83 | * @return void |
| 84 | 84 | */ |
| 85 | -function desktop_mode_agent_run_window_register() { | |
| 86 | - if ( ! function_exists( 'desktop_mode_register_window' ) ) { | |
| 85 | +function openstation_agent_run_window_register() { | |
| 86 | + if ( ! function_exists( 'openstation_register_window' ) ) { | |
| 87 | 87 | return; |
| 88 | 88 | } |
| 89 | - if ( ! desktop_mode_agents_user_can_read() ) { | |
| 89 | + if ( ! openstation_agents_user_can_read() ) { | |
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $registered = desktop_mode_register_window( | |
| 93 | + $registered = openstation_register_window( | |
| 94 | 94 | 'desktop-mode-agent-run', |
| 95 | 95 | array( |
| 96 | 96 | 'title' => __( 'Agent chat', 'desktop-mode' ), |
| 97 | - 'icon' => desktop_mode_agent_run_window_icon(), | |
| 98 | - 'template' => 'desktop_mode_agent_run_render_template', | |
| 97 | + 'icon' => openstation_agent_run_window_icon(), | |
| 98 | + 'template' => 'openstation_agent_run_render_template', | |
| 99 | 99 | 'script' => 'desktop-mode-agent-run', |
| 100 | - 'style' => 'desktop-mode-agent-run', | |
| 100 | + 'styles' => array( 'desktop-mode-agent-run' ), | |
| 101 | 101 | 'width' => 760, |
| 102 | 102 | 'height' => 620, |
| 103 | 103 | 'min_width' => 540, |
| 104 | 104 | 'min_height' => 380, |
| @@ -108,14 +108,14 @@ | ||
| 108 | 108 | 'autofocus' => true, |
| 109 | 109 | 'config' => array( |
| 110 | 110 | 'restRoot' => esc_url_raw( rest_url() ), |
| 111 | 111 | 'restNonce' => wp_create_nonce( 'wp_rest' ), |
| 112 | - 'canManage' => desktop_mode_agents_user_can_manage(), | |
| 112 | + 'canManage' => openstation_agents_user_can_manage(), | |
| 113 | 113 | // The viewer — the chat paints their avatar next to |
| 114 | 114 | // their own messages, WhatsApp-style. |
| 115 | 115 | 'currentUser' => array( |
| 116 | 116 | 'id' => (int) get_current_user_id(), |
| 117 | - 'name' => (string) wp_get_current_user()->display_name, | |
| 117 | + 'name' => openstation_plain_text_title( wp_get_current_user()->display_name ), | |
| 118 | 118 | 'avatarUrl' => (string) get_avatar_url( get_current_user_id(), array( 'size' => 96 ) ), |
| 119 | 119 | ), |
| 120 | 120 | ), |
| 121 | 121 | ) |
| @@ -121,8 +121,8 @@ | ||
| 121 | 121 | ) |
| 122 | 122 | ); |
| 123 | 123 | if ( is_wp_error( $registered ) ) { |
| 124 | 124 | // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
| 125 | - error_log( '[desktop-mode] Agent chat window registration failed: ' . $registered->get_error_message() ); | |
| 125 | + error_log( '[openstation] Agent chat window registration failed: ' . $registered->get_error_message() ); | |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | -add_action( 'init', 'desktop_mode_agent_run_window_register', 25 ); | |
| 128 | +add_action( 'init', 'openstation_agent_run_window_register', 25 ); | |