| @@ -34,11 +34,11 @@ | ||
| 34 | 34 | public const VERSION = '1.0.0'; |
| 35 | 35 | |
| 36 | 36 | public function ui_metadata(): array { |
| 37 | 37 | return array( |
| 38 | - 'label' => 'Bloat Control', | |
| 38 | + 'label' => __( 'Bloat Control', 'xspeed' ), | |
| 39 | 39 | 'icon' => 'Sliders', |
| 40 | - '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' ), | |
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function settings_schema(): array { |
| @@ -45,45 +45,64 @@ | ||
| 45 | 45 | return array( |
| 46 | 46 | 'disable_dashicons_frontend' => array( |
| 47 | 47 | 'type' => 'bool', |
| 48 | 48 | 'default' => false, |
| 49 | - 'label' => 'Disable Dashicons on Frontend', | |
| 50 | - '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' ), | |
| 51 | 51 | ), |
| 52 | 52 | 'disable_oembed' => array( |
| 53 | 53 | 'type' => 'bool', |
| 54 | 54 | 'default' => false, |
| 55 | - 'label' => 'Disable oEmbed Discovery + wp-embed.min.js', | |
| 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.', | |
| 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' ), | |
| 57 | 57 | ), |
| 58 | 58 | 'disable_rss_feeds' => array( |
| 59 | 59 | 'type' => 'bool', |
| 60 | 60 | 'default' => false, |
| 61 | - 'label' => 'Disable RSS Feeds', | |
| 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.', | |
| 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' ), | |
| 63 | 63 | ), |
| 64 | 64 | 'disable_xmlrpc' => array( |
| 65 | 65 | 'type' => 'bool', |
| 66 | 66 | 'default' => false, |
| 67 | - 'label' => 'Disable XML-RPC', | |
| 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).', | |
| 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' ), | |
| 69 | 69 | ), |
| 70 | 70 | 'strip_jquery_migrate' => array( |
| 71 | 71 | 'type' => 'bool', |
| 72 | 72 | 'default' => false, |
| 73 | - 'label' => 'Strip jQuery Migrate on Frontend', | |
| 74 | - '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' ), | |
| 75 | 75 | ), |
| 76 | 76 | 'restrict_rest_to_authed' => array( |
| 77 | 77 | 'type' => 'bool', |
| 78 | 78 | 'default' => false, |
| 79 | - 'label' => 'Restrict REST API to Logged-In Users', | |
| 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.', | |
| 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' ), | |
| 81 | 81 | ), |
| 82 | 82 | ); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 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 { | |
| 86 | 105 | $opts = Settings_Manager::get( self::SLUG ); |
| 87 | 106 | |
| 88 | 107 | if ( ! empty( $opts['disable_dashicons_frontend'] ) ) { |
| 89 | 108 | add_action( 'wp_enqueue_scripts', array( __CLASS__, 'dequeue_dashicons' ), 100 ); |