PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.3.0
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.3.0
1.3.1 1.3.0 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 All 27 releases
xspeed / includes / modules / Support / SupportModule.php

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

104 lines 2.9 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.1.0';
25
26 public function ui_metadata(): array {
27 return array(
28 'label' => __( 'Help & Support', 'xspeed' ),
29 'icon' => 'LifeBuoy',
30 'description' => __( 'Open a support ticket with a one-click system snapshot already attached.', 'xspeed' ),
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://xspeedcache.com/support/',
40 'label' => __( 'Support URL', 'xspeed' ),
41 'description' => __( 'Where the "Open ticket" button takes the user.', 'xspeed' ),
42 ),
43 );
44 }
45
46 /**
47 * The ticket link moved to the dedicated xSpeed support page (#414). A
48 * site that persisted the old default keeps it in its options row, so the
49 * new default alone would not reach it — rewrite exactly the old default
50 * and leave any genuinely custom URL alone.
51 */
52 public function migrations(): array {
53 return array(
54 '1.1.0' => static function ( array $opts ): array {
55 $stored = isset( $opts['support_url'] ) ? untrailingslashit( trim( (string) $opts['support_url'] ) ) : '';
56 if ( 'https://wpdeveloper.com/support' === $stored ) {
57 $opts['support_url'] = 'https://xspeedcache.com/support/';
58 }
59 return $opts;
60 },
61 );
62 }
63
64 public function rest_routes(): array {
65 $default = parent::rest_routes();
66 return array_merge(
67 $default,
68 array(
69 array(
70 'path' => '/snapshot',
71 'methods' => 'GET',
72 'callback' => array( $this, 'rest_snapshot' ),
73 ),
74 )
75 );
76 }
77
78 public function rest_snapshot( \WP_REST_Request $request ) {
79 $snapshot = Support_Snapshot::gather();
80 return rest_ensure_response(
81 array(
82 'snapshot' => $snapshot,
83 'markdown' => Support_Snapshot::to_markdown( $snapshot ),
84 )
85 );
86 }
87
88 public function cli_commands(): array {
89 return array(
90 array(
91 'name' => 'xspeed support',
92 'callback' => array( $this, 'cli_handler' ),
93 'shortdesc' => 'Print the support snapshot.',
94 '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.',
95 'synopsis' => array(),
96 ),
97 );
98 }
99
100 public function cli_handler( array $args, array $assoc ): void {
101 \WP_CLI::log( Support_Snapshot::to_markdown( Support_Snapshot::gather() ) );
102 }
103 }
104