| @@ -265,15 +265,17 @@ | ||
| 265 | 265 | return; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | $isSelf = (int) $userId === \get_current_user_id(); |
| 269 | + $connections = Connections::all($userId); | |
| 270 | + $intro = $withIntro ? self::intro($isSelf, count($connections)) : ''; | |
| 269 | 271 | |
| 270 | - if ($withIntro) { | |
| 271 | - echo '<p class="description">' . \esc_html(self::intro($isSelf)) . '</p>'; | |
| 272 | + if ($intro !== '') { | |
| 273 | + echo '<p class="description">' . \esc_html($intro) . '</p>'; | |
| 272 | 274 | } |
| 273 | 275 | |
| 274 | 276 | if (!$isSelf) { |
| 275 | - self::renderList($userId); | |
| 277 | + self::renderList($userId, $connections); | |
| 276 | 278 | return; |
| 277 | 279 | } |
| 278 | 280 | |
| 279 | 281 | \wp_register_script('extendify-mcp-profile', false, [], false, true); |
| @@ -285,11 +287,16 @@ | ||
| 285 | 287 | self::renderReachability(); |
| 286 | 288 | self::renderPicker(); |
| 287 | 289 | echo '</div></details>'; |
| 288 | 290 | |
| 289 | - /* translators: heading over the assistants this person has authorized. */ | |
| 290 | - self::openSection(\__('Your authorized assistants', 'extendify-local')); | |
| 291 | - self::renderList($userId); | |
| 291 | + self::openSection(\_n( | |
| 292 | + /* translators: heading over the assistants this person has authorized. */ | |
| 293 | + 'Your authorized assistant', | |
| 294 | + 'Your authorized assistants', | |
| 295 | + count($connections), | |
| 296 | + 'extendify-local' | |
| 297 | + )); | |
| 298 | + self::renderList($userId, $connections); | |
| 292 | 299 | echo '</div></details>'; |
| 293 | 300 | } |
| 294 | 301 | |
| 295 | 302 | /** |
| @@ -318,16 +325,24 @@ | ||
| 318 | 325 | } |
| 319 | 326 | |
| 320 | 327 | /** |
| 321 | 328 | * @param boolean $isSelf - Whether this is the screen the viewer connects from. |
| 329 | + * @param integer $count - How many assistants the user has authorized. | |
| 322 | 330 | * @return string |
| 323 | 331 | */ |
| 324 | - private static function intro($isSelf) | |
| 332 | + private static function intro($isSelf, $count = 0) | |
| 325 | 333 | { |
| 326 | 334 | if (!$isSelf) { |
| 327 | - /* translators: shown to an administrator looking at someone else's profile. */ | |
| 328 | - return \__( | |
| 335 | + // Would contradict the "No assistants have been authorized yet." message. | |
| 336 | + if (!$count) { | |
| 337 | + return ''; | |
| 338 | + } | |
| 339 | + | |
| 340 | + return \_n( | |
| 341 | + /* translators: shown to an administrator looking at someone else's profile. */ | |
| 342 | + 'The AI assistant this user has authorized. Only they can add new ones, but you can revoke it.', | |
| 329 | 343 | 'AI assistants this user has authorized. Only they can add new ones, but you can revoke any of them.', |
| 344 | + $count, | |
| 330 | 345 | 'extendify-local' |
| 331 | 346 | ); |
| 332 | 347 | } |
| 333 | 348 | |
| @@ -641,14 +656,14 @@ | ||
| 641 | 656 | ); |
| 642 | 657 | } |
| 643 | 658 | |
| 644 | 659 | /** |
| 645 | - * @param integer $userId - The user whose connections to list. | |
| 660 | + * @param integer $userId - The user whose connections to list. | |
| 661 | + * @param array $connections - Their connections. | |
| 646 | 662 | * @return void |
| 647 | 663 | */ |
| 648 | - private static function renderList($userId) | |
| 664 | + private static function renderList($userId, array $connections) | |
| 649 | 665 | { |
| 650 | - $connections = Connections::all($userId); | |
| 651 | 666 | if (!$connections) { |
| 652 | 667 | echo '<p class="extendify-mcp-empty">' |
| 653 | 668 | /* translators: empty state under that heading. */ |
| 654 | 669 | . \esc_html__('No assistants have been authorized yet.', 'extendify-local') . '</p>'; |