PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / trunk
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN vtrunk
1.2.4 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2.0 1.2.1 1.2.2 1.2.3
xspeed / includes / modules / Support / SupportModule.php

SupportModule.php in xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN trunk, at includes/modules/Support/SupportModule.php

86 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Help & Support module — direct ticket link + paste-ready system
4 * snapshot so tickets land with full context.
5 *
6 * Tier: Free per FEATURES.md "Support & Compatibility" → Help & Support.
7 *
8 * @package XSpeed
9 */
10
11 declare(strict_types=1);
12
13 namespace XSpeed\Modules\Support;
14
15 defined( 'ABSPATH' ) || exit;
16
17 use XSpeed\Module;
18 use XSpeed\Support_Snapshot;
19
20 final class SupportModule extends Module {
21
22 public const SLUG = 'support';
23 public const TIER = self::TIER_FREE;
24 public const VERSION = '1.0.0';
25
26 public function ui_metadata(): array {
27 return array(
28 'label' => 'Help & Support',
29 'icon' => 'LifeBuoy',
30 'description' => 'Open a support ticket with a one-click system snapshot already attached.',
31 'custom_panel' => 'SupportPanel',
32 );
33 }
34
35 public function settings_schema(): array {
36 return array(
37 'support_url' => array(
38 'type' => 'string',
39 'default' => 'https://wpdeveloper.com/support',
40 'label' => 'Support URL',
41 'description' => 'Where the "Open ticket" button takes the user.',
42 ),
43 );
44 }
45
46 public function rest_routes(): array {
47 $default = parent::rest_routes();
48 return array_merge(
49 $default,
50 array(
51 array(
52 'path' => '/snapshot',
53 'methods' => 'GET',
54 'callback' => array( $this, 'rest_snapshot' ),
55 ),
56 )
57 );
58 }
59
60 public function rest_snapshot( \WP_REST_Request $request ) {
61 $snapshot = Support_Snapshot::gather();
62 return rest_ensure_response(
63 array(
64 'snapshot' => $snapshot,
65 'markdown' => Support_Snapshot::to_markdown( $snapshot ),
66 )
67 );
68 }
69
70 public function cli_commands(): array {
71 return array(
72 array(
73 'name' => 'xspeed support',
74 'callback' => array( $this, 'cli_handler' ),
75 'shortdesc' => 'Print the support snapshot.',
76 'ai_hint' => 'Generate a diagnostic snapshot (environment, settings, active plugins, recent errors) to attach to a support request. Use when a problem needs escalating and the user is asked for their configuration.',
77 'synopsis' => array(),
78 ),
79 );
80 }
81
82 public function cli_handler( array $args, array $assoc ): void {
83 \WP_CLI::log( Support_Snapshot::to_markdown( Support_Snapshot::gather() ) );
84 }
85 }
86