PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.3.3
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.3.3
1.3.3 1.3.2 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 All 29 releases
← All changes | includes/modules/Bloat/BloatModule.php +48 -15 1.0.21.3.3 View file →
@@ -21,8 +21,10 @@
21 21 declare(strict_types=1);
22 22
23 23 namespace XSpeed\Modules\Bloat;
24 24
25 +defined( 'ABSPATH' ) || exit;
26 +
25 27 use XSpeed\Module;
26 28 use XSpeed\Settings_Manager;
27 29
28 30 final class BloatModule extends Module {
@@ -32,11 +34,11 @@
32 34 public const VERSION = '1.0.0';
33 35
34 36 public function ui_metadata(): array {
35 37 return array(
36 - 'label' => 'Disable Bloat',
38 + 'label' => __( 'Bloat Control', 'xspeed' ),
37 39 'icon' => 'Sliders',
38 - 'description' => 'Turn off WordPress defaults you do not use — saves bytes, requests, and attack surface.',
40 + 'description' => __( 'Turn off WordPress defaults you do not use — saves bytes, requests, and attack surface.', 'xspeed' ),
39 41 );
40 42 }
41 43
42 44 public function settings_schema(): array {
@@ -43,45 +45,64 @@
43 45 return array(
44 46 'disable_dashicons_frontend' => array(
45 47 'type' => 'bool',
46 48 'default' => false,
47 - 'label' => 'Disable Dashicons on Frontend',
48 - 'description' => 'Drop the dashicons stylesheet from non-admin pages. Most themes do not need it. Saves ~45 KB per visitor.',
49 + 'label' => __( 'Disable Dashicons on Frontend', 'xspeed' ),
50 + 'description' => __( 'Drop the dashicons stylesheet from non-admin pages. Most themes do not need it. Saves ~45 KB per visitor.', 'xspeed' ),
49 51 ),
50 52 'disable_oembed' => array(
51 53 'type' => 'bool',
52 54 'default' => false,
53 - 'label' => 'Disable oEmbed Discovery + wp-embed.min.js',
54 - 'description' => 'Strip the auto-embed handlers + the embed script. Posts that paste a YouTube URL will no longer auto-render the player — embed it via a block instead. Saves a request per page.',
55 + 'label' => __( 'Disable oEmbed Discovery + wp-embed.min.js', 'xspeed' ),
56 + 'description' => __( 'Strip the auto-embed handlers + the embed script. Posts that paste a YouTube URL will no longer auto-render the player — embed it via a block instead. Saves a request per page.', 'xspeed' ),
55 57 ),
56 58 'disable_rss_feeds' => array(
57 59 'type' => 'bool',
58 60 'default' => false,
59 - 'label' => 'Disable RSS Feeds',
60 - 'description' => 'Return a 404 on /feed/ and similar endpoints. Useful for sites that do not publish feeds and want to cut feed-fetcher traffic.',
61 + 'label' => __( 'Disable RSS Feeds', 'xspeed' ),
62 + 'description' => __( 'Return a 404 on /feed/ and similar endpoints. Useful for sites that do not publish feeds and want to cut feed-fetcher traffic.', 'xspeed' ),
61 63 ),
62 64 'disable_xmlrpc' => array(
63 65 'type' => 'bool',
64 66 'default' => false,
65 - 'label' => 'Disable XML-RPC',
66 - 'description' => 'Disable the legacy xmlrpc.php endpoint. Cuts pingback brute-force noise; safe to disable unless you use a remote WP client (Jetpack, WordPress mobile app).',
67 + 'label' => __( 'Disable XML-RPC', 'xspeed' ),
68 + 'description' => __( 'Disable the legacy xmlrpc.php endpoint. Cuts pingback brute-force noise; safe to disable unless you use a remote WP client (Jetpack, WordPress mobile app).', 'xspeed' ),
67 69 ),
68 70 'strip_jquery_migrate' => array(
69 71 'type' => 'bool',
70 72 'default' => false,
71 - 'label' => 'Strip jQuery Migrate on Frontend',
72 - 'description' => 'Remove the jquery-migrate compatibility shim from non-admin pages. Saves ~10 KB; safe on modern themes / plugins.',
73 + 'label' => __( 'Strip jQuery Migrate on Frontend', 'xspeed' ),
74 + 'description' => __( 'Remove the jquery-migrate compatibility shim from non-admin pages. Saves ~10 KB; safe on modern themes / plugins.', 'xspeed' ),
73 75 ),
74 76 'restrict_rest_to_authed' => array(
75 77 'type' => 'bool',
76 78 'default' => false,
77 - 'label' => 'Restrict REST API to Logged-In Users',
78 - 'description' => 'Block /wp-json/ for anonymous requests. WooCommerce checkout, contact-form submissions, and many block-editor previews need anonymous REST — keep this off unless you know your site does not depend on it.',
79 + 'label' => __( 'Restrict REST API to Logged-In Users', 'xspeed' ),
80 + 'description' => __( 'Block /wp-json/ for anonymous requests. WooCommerce checkout, contact-form submissions, and many block-editor previews need anonymous REST — keep this off unless you know your site does not depend on it.', 'xspeed' ),
79 81 ),
80 82 );
81 83 }
82 84
83 85 public function boot(): void {
86 + /*
87 + * Deferred to `init` priority 0. This reads the module's settings,
88 + * which builds settings_schema(), whose labels go through __(), and
89 + * boot() runs on `plugins_loaded` — before `after_setup_theme`, the
90 + * earliest point WordPress 6.7+ treats as safe to translate.
91 + *
92 + * Priority 0 (not the default 10) because the body itself registers
93 + * an `init` callback at priority 9: adding a hook to the action that
94 + * is currently running only takes effect if the new priority is still
95 + * ahead of the running position, so we have to be first. Every other
96 + * hook it registers fires later than `init`.
97 + */
98 + add_action( 'init', array( $this, 'boot_on_init' ), 0 );
99 + }
100 +
101 + /**
102 + * The real boot body — see boot() for why it runs on `init`.
103 + */
104 + public function boot_on_init(): void {
84 105 $opts = Settings_Manager::get( self::SLUG );
85 106
86 107 if ( ! empty( $opts['disable_dashicons_frontend'] ) ) {
87 108 add_action( 'wp_enqueue_scripts', array( __CLASS__, 'dequeue_dashicons' ), 100 );
@@ -176,9 +197,12 @@
176 197 /**
177 198 * @param \WP_Scripts $scripts
178 199 */
179 200 public static function strip_jquery_migrate( $scripts ): void {
180 - if ( is_admin() || ! isset( $scripts->registered['jquery'] ) ) {
201 + // Builders and their add-ons still rely on jQuery Migrate shims; a
202 + // builder editing screen is a front-end URL, so is_admin() misses it
203 + // and the editor loses methods it calls. (#281)
204 + if ( is_admin() || \XSpeed\Builder_Editor::is_active() || ! isset( $scripts->registered['jquery'] ) ) {
181 205 return;
182 206 }
183 207 $jquery = $scripts->registered['jquery'];
184 208 if ( is_array( $jquery->deps ?? null ) ) {
@@ -212,8 +236,9 @@
212 236 array(
213 237 'name' => 'xspeed bloat',
214 238 'callback' => array( $this, 'cli_handler' ),
215 239 'shortdesc' => 'Show which bloat-removal toggles are active.',
240 + 'ai_hint' => 'What unnecessary WordPress output is being stripped (emojis, embeds, jQuery Migrate, dashicons)? Use when asked why extra scripts still load on the frontend, or before recommending bloat removal.',
216 241 'synopsis' => array(),
217 242 ),
218 243 );
219 244 }
@@ -222,6 +247,14 @@
222 247 $opts = Settings_Manager::get( self::SLUG );
223 248 foreach ( $opts as $key => $value ) {
224 249 \WP_CLI::log( sprintf( '%-30s %s', $key, $value ? 'on' : 'off' ) );
225 250 }
251 + }
252 +
253 + /**
254 + * Bloat has no master switch -- it is on when any of its disable_* /
255 + * strip_* / restrict_* flags is set. (#363)
256 + */
257 + public function is_active(): ?bool {
258 + return $this->any_bool_flag_on();
226 259 }
227 260 }